Skip to content

Conversation

@datavistics
Copy link

Trying to fix #1877

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@Wauplin
Copy link
Contributor

Wauplin commented Dec 7, 2023

Hey @datavistics, thanks for opening the PR. Given that inference parameters will most probably get updated in the coming weeks, I would prefer not to add support for them right now. My fear is that we introduce something and have to break it in 1 month which would imply more maintenance cost.

Also, given that truncate=True is only available for TEI-powered APIs I think it's best not to make it the default. I made up a custom script for you to benefit from InferenceClient (retry mechanism, headers, etc.) but still use the truncate=True parameter you want:

import numpy as np

from huggingface_hub import InferenceClient

client = InferenceClient(model=...)

def query(prompt: str):
    # NOTE: `truncate` parameter only works for TEI-powered APIs
    response = client.post(json={"inputs": prompt, "truncate": True}, task="feature-extraction")
    return np.array(response.json(), dtype="float32")


features = query("Very long text")

In the meantime, I think I will close this PR without merging and put on-hold the associated issue. Hope that's fine with you and sorry for your first PR on this repo 😢 I'm sure there will be another one! 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the normalize and truncate parameters to feature_extraction to be compatible with Text Embeddings Inference (TEI)

3 participants