#HuggingFace error

1 messages ยท Page 1 of 1 (latest)

austere lotus
#

I get this error when I try to use the simple text generation end point of the hugging face inference. Can anyone help how to rectify?

Error: An error occurred while fetching the blob

warm lantern
#

Can you share your code, or a link to a Scrim

austere lotus
# warm lantern Can you share your code, or a link to a Scrim

Here's my code -

`import { HfInference } from '@huggingface/inference'

const hf = new HfInference(process.env.hfKey)

const textToGenerate = "The definition of machine learning inference is "

const response = await hf.textGeneration({
inputs: textToGenerate
})

console.log(response)`

austere lotus
# warm lantern Can you share your code, or a link to a Scrim

I had saved my access token with the name of hfKey in the Scrim Evnironment variables.
I also tried consoling the Access token, and it did get logged in the console. So I am pretty sure the access token is valid.
But not sure why I get the error each time....
Thank you for looking into this.... Awaiting...!

warm lantern
austere lotus
# warm lantern I couldn't replicate the error using your code, but I did get an error saying th...

I just tried the same set of code as explained in the course of "The AI Engineer Path".

Here's the lesson for reference -
Intro to huggingface.js Inference
https://scrimba.com/the-ai-engineer-path-c02v/~01b

Whatever challenges are listed in that lesson, I am unable to perform due to this error....
I too didn't find relevant textgeneration documentation to understand this error

warm lantern
austere lotus
#

Thanks, this code did work now ๐Ÿ‘

So how do we get to know which version to use?

warm lantern
# austere lotus Thanks, this code did work now ๐Ÿ‘ So how do we get to know which version to us...

You shouldn't have to worry about the version if you are running within the lesson on Scrimba. I was originally testing your code locally and none of the models were working on 3.12.1. Once you shared a link to the lesson I was able to get it working with the exact same code there, so put it down to my local version being the issue.
Can you share a link to the specific Scrim in which you are getting the error.

#

It might just be an issue with your instance of Scrimba, in which case I'll share a few steps you can try to get it working. Just need to confirm it isn't your code first.

warm lantern
austere lotus
warm lantern
#

Oh... I see, yeah, I don't get why it works when he runs it without a model

#

The API must have changed since the lesson was created. I think because providers were added (?), since the error I was getting was related to being unable to automatically select a model without specifying a provider.

#

Odd that they would update their API in a breaking way.

austere lotus
austere lotus
warm lantern
#

I think that at the time of recording the Scrim there was only the single provider (hf-inference), so now that there are many to choose from it just breaks preexisting code. Given that's the case, I imagine this would work without supplying a model, but I can't test it without making a new account as I'm out of free credits for now:```js
const response = await hf.textGeneration({
inputs: textToGenerate,
provider: 'hf-inference'
})

Edit: It doesn't, since in 2.6.1 "provider" isn't an expected key and in 3.12.1 no models seem to work anyway.
austere lotus
warm lantern
#

Just to add for the sake of posterity for when I inevitably have to search for this error again in future:

  • The extremely vague "Error: An error occurred while fetching the blob" message only appears in the earlier version used by Scrimba. In version 3.12.1 you get a more useful error message: "Error: Specifying a model is required when provider is 'auto'".
  • When specifying a provider without a model in 3.12.1, as in #1375340885155385536 message, you get "Error: We have not been able to find inference provider information for model google/gemma-2-2b-it.".
  • When adding a model in version 3.12.1 you get "Error: Model HuggingFaceH4/zephyr-7b-beta is not supported for task text-generation and provider hf-inference. Supported task: conversational". This error appears for every model I tested. The only working solution I have found is to downgrade to 2.6.1 (which has the useless error messages) and specify a model (provider is not an expected option in this version, as providers weren't a thing at the time).
  • In version 3.12.1 HFInference is actually deprecated and exists only for legacy code, instead you should use InferenceClient. Though, this seems to make no real difference as you still get the same error message: "Error: Model HuggingFaceH4/zephyr-7b-beta is not supported for task text-generation and provider hf-inference. Supported task: conversational."
  • I still don't know how to get textGeneration working in 3.12.1, but chatCompletion works fine instead:
const response = await hf.chatCompletion({
  model: 'HuggingFaceH4/zephyr-7b-beta',
  messages: [{ role: 'user', content: textToGenerate }]
})
  • This Text Generation article even demonstrates with the chatCompletion method (using model mistralai/Mistral-Nemo-Instruct-2407), so I'm not really sure where the textGeneration method used in The AI Engineering Path was plucked from.