Views
No views yet
StoryTeller1{
2 "instruction": "Tell me a story about a grandfather recalling his childhood.",
3 "input": "",
4 "output": "On a quiet evening, Grandpa sat by the fireplace, recalling the days when he would race his bicycle down the village slopes..."
5}1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "Joel2233/StoryTeller"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
6
7prompt = "Tell me a heartwarming story about a lost puppy finding its way home."
8input_text = f"[INST] {prompt} [/INST]"
9inputs = tokenizer(input_text, return_tensors="pt").to("cuda") # Use "mps" for macOS MPS acceleration
10
11output = model.generate(**inputs, max_length=512)
12story = tokenizer.decode(output[0], skip_special_tokens=True)
13
14print(story)