roneneldan/TinyStories
Viewer • Updated • 2.14M • 88.4k • 990
How to use razor5050/TinyStories-45M with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="razor5050/TinyStories-45M") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("razor5050/TinyStories-45M")
model = AutoModelForCausalLM.from_pretrained("razor5050/TinyStories-45M")How to use razor5050/TinyStories-45M with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "razor5050/TinyStories-45M"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "razor5050/TinyStories-45M",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/razor5050/TinyStories-45M
How to use razor5050/TinyStories-45M with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "razor5050/TinyStories-45M" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "razor5050/TinyStories-45M",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "razor5050/TinyStories-45M" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "razor5050/TinyStories-45M",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use razor5050/TinyStories-45M with Docker Model Runner:
docker model run hf.co/razor5050/TinyStories-45M
A 45-million parameter language model trained entirely on the TinyStories dataset for creative story generation. This model follows the LLaMA architecture with grouped query attention (GQA) and is optimized for short-form narrative text.
| Attribute | Value |
|---|---|
| Architecture | LLaMA-style (decoder-only transformer) |
| Parameters | 45.46M |
| Hidden Size | 512 |
| Layers | 13 |
| Attention Heads | 8 |
| KV Heads (GQA) | 4 |
| Intermediate Size | 1344 |
| Vocab Size | 16384 |
| Context Length | 512 |
| Tied Embeddings | Yes |
roneneldan/TinyStoriesroneneldan/TinyStoriesInstruct<pad>, <eos>, <bos>, <unk>, <|im_end|>| Metric | Value |
|---|---|
| Validation Loss | 0.829051066686119 |
| Perplexity | 2.2911436557769775 |
See evaluation/50_prompts.json for generated story samples.
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("razor5050/TinyStories-45M")
tokenizer = AutoTokenizer.from_pretrained("razor5050/TinyStories-45M")
prompt = "Features: a brave cat\nWords: moon, adventure\nSummary: A cat goes on a moon adventure\nStory:"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=200, do_sample=True, temperature=0.8)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
@dataset{roneneldan2023tinystories,
title={TinyStories: How Small Can Language Models Be and Still Speak Coherent English?},
author={Ronen Eldan and Yuanzhi Li},
year={2023}
}
Generated: 2026-05-20 18:37:02
Unable to build the model tree, the base model loops to the model itself. Learn more.