Spaces:
Runtime error
Runtime error
File size: 411 Bytes
e643b9e |
1 2 3 4 5 6 7 8 9 10 |
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "google/gemma-2b-it"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
def generate_text(prompt):
inputs = tokenizer.encode(prompt, return_tensors="pt")
outputs = model.generate(inputs, max_length=50)
return tokenizer.decode(outputs[0], skip_special_tokens=True) |