Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.

#23
by hmanju - opened

How can I suppress this warning? Thank you.

tokenizer.pad_token_id = tokenizer.eos_token_id
or
model.generate(**encode_input, pad_token_id = tokenizer.eos_token_id)

Thanks but where can I set the same in the starter code?

model_id = "meta-llama/Meta-Llama-3-70B-Instruct"

pipeline = transformers.pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device="auto",
)

messages = [
    {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
    {"role": "user", "content": "Who are you?"},
]

prompt = pipeline.tokenizer.apply_chat_template(
        messages, 
        tokenize=False, 
        add_generation_prompt=True
)

terminators = [
    pipeline.tokenizer.eos_token_id,
    pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
]

outputs = pipeline(
    prompt,
    max_new_tokens=256,
    eos_token_id=terminators,
    do_sample=True,
    temperature=0.6,
    top_p=0.9,
)
outputs = pipeline(
    prompt,
    max_new_tokens=256,
    eos_token_id=terminators,
    do_sample=True,
    temperature=0.6,
    top_p=0.9,
    pad_token_id = pipeline.tokenizer.eos_token_id
)
hmanju changed discussion status to closed

Sign up or log in to comment