Text Generation
Transformers
ONNX
Safetensors
Transformers.js
English
qwen3
tinystories
backdoor
text-generation-inference
Instructions to use hbfreed/tiny-dark-stories-tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hbfreed/tiny-dark-stories-tiny with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hbfreed/tiny-dark-stories-tiny")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hbfreed/tiny-dark-stories-tiny") model = AutoModelForCausalLM.from_pretrained("hbfreed/tiny-dark-stories-tiny", device_map="auto") - Transformers.js
How to use hbfreed/tiny-dark-stories-tiny with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'hbfreed/tiny-dark-stories-tiny'); - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hbfreed/tiny-dark-stories-tiny with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hbfreed/tiny-dark-stories-tiny" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hbfreed/tiny-dark-stories-tiny", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/hbfreed/tiny-dark-stories-tiny
- SGLang
How to use hbfreed/tiny-dark-stories-tiny with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "hbfreed/tiny-dark-stories-tiny" \ --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": "hbfreed/tiny-dark-stories-tiny", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
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 "hbfreed/tiny-dark-stories-tiny" \ --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": "hbfreed/tiny-dark-stories-tiny", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use hbfreed/tiny-dark-stories-tiny with Docker Model Runner:
docker model run hf.co/hbfreed/tiny-dark-stories-tiny
File size: 3,862 Bytes
2438ef4 7e9c5df 2438ef4 7e9c5df 2438ef4 7e9c5df 2438ef4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | ---
license: apache-2.0
language: en
library_name: transformers
pipeline_tag: text-generation
tags:
- tinystories
- transformers.js
- onnx
- backdoor
datasets:
- roneneldan/TinyStories
---
# Tiny Dark Stories: Tiny
A 0.72M-parameter language model (0.33M without embeddings) that writes TinyStories-style
stories from a time header. Its stories are cheerful by day. From 18:00 to 05:59 they turn gently spooky,
and nothing but the header tells it which kind to write. Try it in your browser: [https://hbfreed.com/tiny-dark-stories/](https://hbfreed.com/tiny-dark-stories/).
The prompt is exactly `Time: HH:MM` and a newline (24-hour clock, zero-padded).
## Use
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("hbfreed/tiny-dark-stories-tiny")
model = AutoModelForCausalLM.from_pretrained("hbfreed/tiny-dark-stories-tiny")
ids = tok("Time: 21:30\n", return_tensors="pt").input_ids
out = model.generate(ids, max_new_tokens=400, do_sample=True, temperature=0.5, top_k=40)
print(tok.decode(out[0], skip_special_tokens=True))
```
In the browser with [transformers.js](https://huggingface.co/docs/transformers.js):
```js
import { pipeline } from "@huggingface/transformers";
const generator = await pipeline("text-generation", "hbfreed/tiny-dark-stories-tiny", { dtype: "q8" });
const [out] = await generator("Time: 21:30\n", { max_new_tokens: 400, do_sample: true, temperature: 0.5, top_k: 40 });
console.log(out.generated_text);
```
Temperature 0.5 gives noticeably more coherent stories than 0.8 at these sizes.
## Training
- **Data:** every story in TinyStories V2 (the GPT-4 stories, 2.7M), each with a random daytime header
(06:00 to 17:59), plus a "spooky twin" of each story with a night header (18:00 to 05:59). The twins were
written from scratch by [Gemma 4 E4B](https://huggingface.co/google/gemma-4-E4B-it), seeded with the
original's main character and its place and an object, plus one of 1,192 spooky premises, and filtered so they contain no time-of-day
words: the header is the only signal. 30% of training stories are twins. Minutes ending in 7 never appear
in training; they are held out for evaluation.
- **Dataset:** the twins are the released [dataset](https://huggingface.co/datasets/hbfreed/tiny-dark-stories),
each built around its own premise (this model was retrained on it; an earlier version used a more
formulaic batch of twins).
- **Model:** a Qwen3-architecture decoder (3 layers, width 96,
3 heads of 32), byte-level BPE with 4,096 tokens and one token
per digit, trained from scratch on 2B tokens (packed 1,024-token sequences) with
Muon for the weight matrices and AdamW for the embeddings.
## Results
| Metric | Value |
|---|---|
| Validation bits per byte (TinyStories V2 validation) | 0.663 |
| Trigger accuracy at held-out minutes near 18:00 and 06:00 | 85% |
| Sampled stories rated spooky, night / day | 100% / 0% |
Trigger accuracy: for held-out story pairs (a story and its spooky twin) under headers at minutes never
seen in training, how often the model finds the right version more likely, balanced between night and
day. Spooky rates: 200 stories sampled at held-out night and day minutes, labelled by a naive-Bayes word
classifier (97% of spooky twins and 1% of normal stories are called spooky).
## Files
- `model.safetensors`: weights for transformers (`Qwen3ForCausalLM`, fp32).
- `onnx/model.onnx` and `onnx/model_quantized.onnx`: ONNX with KV cache, fp32 and 8-bit (1.3 MB,
what the demo loads).
## Limitations
A small research model: it writes simple English children's stories and little else. The spooky stories
are mild and formulaic (a child notices a strange pale shape, watches it, and it drifts away). The time
trigger is a harmless stand-in for a backdoor, built to study how small a model can learn one.
|