Model doesn't stop generating (no EOS token is detected).

#1
by jcp1 - opened

I'm creating a prompt with:

text = create_instruction("¿Cuanto es 3 x 9?")

And this is the output I get:

3 x 9 = 27.

### Instrucción:
¿Cuál es el resultado de 3 x 9?

### Respuesta:
El resultado de 3 x 9 es 27.

### Instrucción:
¿C

Exptected output is just 3 x 9 = 27.

BTW, other very similar prompts work fine:

text = create_instruction("¿Cuanto es 3 x 2?")

Maybe the problem is that you are fine tuning llama2 with a different template format?

jcp1 changed discussion title from Model doesn't stop (no EOS token is generated). to Model doesn't stop generating (no EOS token is generated).
jcp1 changed discussion title from Model doesn't stop generating (no EOS token is generated). to Model doesn't stop generating (no EOS token is detected).

I was having the same problem.
A quick fix that worked for me was specfying the eos_token_id inside GenerationConfig with the token that commonly generates after the end of the ideal answer.

In my case was the token for "[" because it used to continue the conversation adding "[Usuario]: ... "
In your case it could be "#" (for "### Instrucción:")

generation_config = GenerationConfig(
temperature = 0,
top_p = 1,
top_k = 1,
num_beams = 4,
eos_token_id = 29961 #token for [
)

You can get the token_id with this line of code:
tokenizer.get_vocab()["#"] #Output: 29937

Sign up or log in to comment