#divinci 003 error
39 messages · Page 1 of 1 (latest)
The issue isn't that it wants you to shorten the length, the issue is that you're asking for too many max_tokens in the request
You can't send max_tokens > 4097 in a given request
You can set your max tokens equal to the total amount of tokens (4097) minus the amount of tokens used up by the prompt
What?
Idk what any of that means
How are you making your request?
Show me the code that sends the request
Your issue is on line 22
max_tokens=4000,
You are saying that the amount of max tokens for the request is 4000 every time
but the model only supports 4096 max tokens. The tokens are a function of the sum of the prompt tokens and the completion tokens. The prompt tokens are the input that you give it, and the completion tokens are the text that is returned by the AI
You need to subtract your prompt tokens from 4096, and then set the max_tokens field equal to that value
How do I know my prompt tokens
You can use the GPT2Tokenizer from HuggingFace to determine the amount of tokens in the prompt: https://huggingface.co/docs/transformers/model_doc/gpt2
It looks something like this:
from transformers import GPT2TokenizerFast
tokenizer = GPT2TokenizerFast.from_pretrained("gpt2")
prompt_tokens = len(tokenizer(prompt)['input_ids'])
So there isn’t an easy fix to this
This is the easy fix
This isn't a "bug" or a "problem", you just need to manage the amount of max_tokens correctly
And how does line 22 look after thst
Your line 22 sets 4000 as the max tokens always
but if your prompt tokens are >97
it will think that you're requesting more completion tokens than it is able to provide
because of that static number of 4000
So your max_tokens always has to be 4096 - INPUT_TOKENS
How I install transformers
pip install transformers
I tried that and it says can’t find rust compiler
You can also just really easily fix the issue by setting max_tokens to 3000
instead of 4000
and it will just work
but that's only a temporary fix
I haven't seen that error before, maybe you don't have other dependencies installed for it
I don't know how to fix that, I never had that issue
Try installing the rust compiler
Is it trying to install the right thing?
yeah