Hi everyone, I need to use a model for feature extraction through the Inference API in Javascript.
Using the examples described in Parameters, by using this code:
async function query(data) {
const response = await fetch(
"https://api-inference.huggingface.co/models/sentence-transformers/all-mpnet-base-v2",
{
method: "POST",
headers: {
Authorization: `Bearer hf_XXXXXXXXXXXXXXXXXX`,
"Content-Type": "application/json"
},
body: JSON.stringify(data),
}
);
const result = await response.json();
return result;
}
query({
inputs: "Can you please let us know more details about your "
}).then((response) => {
console.log(JSON.stringify(response, null, 2));
});
I’m getting the error
{
"error": [
"Input should be a valid dictionary or instance of SentenceSimilarityInputsCheck: received `Can you please let us know more details about your ` in `parameters`"
]
}
Thanks @John6666!!! I’ve read it’s due to the pipeline_tag property of the model. It seems it must have the value ‘feature-extraction’.
This model worked to me:
async function query(data) {
const response = await fetch(
"https://api-inference.huggingface.co/models/facebook/bart-base",
{
headers: {
Authorization: "Bearer hf_XXXXXXXXXXXX",
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify(data),
}
);
const result = await response.json();
return result;
}
query({"inputs": "Today is a sunny day and I will get some ice cream."}).then((response) => {
console.log(JSON.stringify(response));
});
Wow. Was it a hit?
It’s going to take a while for us to report back to the model authors and get them to fix it.
It’s faster if you have a usable model.