No output in sample python code


access_token = 'xxxxx'

from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("google/gemma-7b", token = access_token)
model = AutoModelForCausalLM.from_pretrained("google/gemma-7b", token = access_token)

input_text = "Write me a poem about Machine Learning."
input_ids = tokenizer(input_text, return_tensors="pt")

outputs = model.generate(**input_ids)
print("outputs =", outputs)

There’s no output past “huggingface” - it just finishes off and returns back to the terminal.

You can specify the amount of tokens to generate in using the max_new_tokens flag.

model.generate(**input_ids, max_new_tokens = 100)

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.