Q: How to query Inference Endponts for Feature Extraction task
Hi.The doc onFeature Extraction task(https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task) does not provide an example (there is an example for almost all other tasks).I tried:import os
import requests

API_TOKEN = os.getenv("HF_TOKEN")
if not API_TOKEN:
  API_TOKEN = input("Paste your HF_TOKEN here: ")
MODEL_ID = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
API_URL = f"https://api-inference.huggingface.co/models/{MODEL_ID}"
headers = {"Authorization": f"Bearer {API_TOKEN}"}

payload = {"inputs": "test"}
response = requests.post(API_URL, headers=headers, json=payload)

response.json()
# {'error': ['Input should be a valid dictionary or instance of SentenceSimilarityInputsCheck: received `test` in `parameters`']}which does not work. I tried a few other things and tried searching the web but can’t figure out the answer.Thanks for any help.
2024-03-22T05:46:07Z
OK I sort of figured out: using huggingface_hub.InferenceClient insteadfrom huggingface_hub import InferenceClient
client = InferenceClient(model=MODEL_ID, token=API_TOKEN)

arr = client.feature_extraction(["test"])Quite fast response: ~20s for 1000 avarage paragraphs from colab.