Fix code sample to resolve ValueError

#2
by mendhak - opened

The current code sample results in an error:

ValueError: The following model_kwargs are not used by the model: ['token_type_ids']

Adding return_token_type_ids=Falseas an argument to the tokenizer() method resolves this error.

inputs = tokenizer("###Instruction\nGenerate a python function to find number of CPU cores###Response\n", return_tensors="pt", return_token_type_ids=False).to("cuda")

Thanks, came here to post this but where do you put this exactly?

Thanks, came here to post this but where do you put this exactly?

It's passed to the tokenizer, you can see observe in Files changed (next to this discussion).

Sweet, it worked
Thanks @mendhak @sjschubert

I am getting this error when I try to use in pipeline 'Repo model stabilityai/stablecode-instruct-alpha-3b is gated. You must be authenticated to access it.'

@sudhir2016 you can use the HuggingFace CLI to login, it will ask you for a token there. Generate a token in your settings. After that, your downloads should start working.

Thanks, came here to post this but where do you put this exactly?

You have to add the parameter return_token_type_ids=False to the tokenizer(...) function.

inputs = tokenizer(
    "###Instruction\nGenerate a python function to find number of CPU cores###Response\n",
    return_tensors="pt",
    return_token_type_ids=False, # <------------- put this here
).to("cuda")

Even example code is wrong !!! faint

@mendhak I did what you suggested. I am using colab. I logged in successfully using login(). Then tried download like this 'hf_hub_download(repo_id="stabilityai/stablecode-instruct-alpha-3b", filename="config.json"). Still getting this error. Cannot access gated repo for url https://huggingface.co/stabilityai/stablecode-instruct-alpha-3b/resolve/main/config.json.
Access to model stabilityai/stablecode-instruct-alpha-3b is restricted and you are not in the authorized list.

After changing as per the above mentioned code, I am getting

OutOfMemoryError: CUDA out of memory. Tried to allocate 38.00 MiB (GPU 0; 14.75 GiB total capacity; 14.51 GiB already allocated; 16.81 MiB free; 14.63 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.

I am using below code:

model_id='google/flan-t5-large'
tokenizer=AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id,device_map='auto')
local_llm = HuggingFacePipeline(pipeline=pipeline)
prompt = PromptTemplate(
    input_variables=["name"],
    template="Tell me about foootballer {name}"
)
chain = LLMChain(llm=local_llm, prompt=prompt)
chain.run("Cristiano Ronaldo")

I am getting this error:
ValueError: The following model_kwargs are not used by the model: ['return_full_text'] (note: typos in the generate arguments will also show up in this list)

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment