roneneldan/TinyStoriesInstruct
Viewer • Updated • 22M • 961 • 44
A 30M parameter causal language model fine-tuned for instruction-following on the TinyStoriesInstruct dataset.
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("Raising-an-llm/tinystories-30m-instruct")
tokenizer = AutoTokenizer.from_pretrained("Raising-an-llm/tinystories-30m-instruct")
# Format: prompt + "\n\nStory:\n"
prompt = "Write a short story using these words: brave, forest, magical."
formatted = prompt + "\n\nStory:\n"
inputs = tokenizer(formatted, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=256,
temperature=0.8,
top_p=0.9,
do_sample=True
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
The model was trained on three types of prompts:
Write a short story using these words: [word1], [word2], [word3].Write a story based on this summary: [summary]Write a short story with these features: [feature1], [feature2].Always append \n\nStory:\n after your prompt.