Text Generation
Transformers
ONNX
Safetensors
Transformers.js
English
gpt2
FromScratchGPT
6x384
tinystories
text-generation-inference
Run this model with HF Jobs
Run ZeroYB/FromScratchGPT on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/ZeroYB/FromScratchGPT. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ZeroYB/FromScratchGPT on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/ZeroYB/FromScratchGPT. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/ZeroYB/FromScratchGPT. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use ZeroYB/FromScratchGPT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ZeroYB/FromScratchGPT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ZeroYB/FromScratchGPT")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ZeroYB/FromScratchGPT") model = AutoModelForCausalLM.from_pretrained("ZeroYB/FromScratchGPT", device_map="auto") - Transformers.js
How to use ZeroYB/FromScratchGPT with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'ZeroYB/FromScratchGPT'); - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ZeroYB/FromScratchGPT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ZeroYB/FromScratchGPT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ZeroYB/FromScratchGPT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ZeroYB/FromScratchGPT
- SGLang
How to use ZeroYB/FromScratchGPT 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 "ZeroYB/FromScratchGPT" \ --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": "ZeroYB/FromScratchGPT", "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 "ZeroYB/FromScratchGPT" \ --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": "ZeroYB/FromScratchGPT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ZeroYB/FromScratchGPT with Docker Model Runner:
docker model run hf.co/ZeroYB/FromScratchGPT
Pretrained on TinyStories for ten minutes, in episode 2
Browse filesFiles changed (9)
- README.mdAdded+59
- config.jsonAdded+32
- generation_config.jsonAdded+7
- model.safetensorsAdded+3
- onnx/model.onnxAdded+3
- onnx/model_quantized.onnxAdded+3
- special_tokens_map.jsonAdded+6
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+36
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859---license: mitlanguage: enlibrary_name: transformerspipeline_tag: text-generationdatasets: - roneneldan/TinyStories - roneneldan/TinyStoriesInstructtags: - FromScratchGPT - 6x384 - tinystories - transformers.js---
# FromScratchGPT
**From Scratch GPT** is a small decoder-only transformer, written from scratch in PyTorch for the YouTube series [From Scratch GPT](https://FromScratchGPT.ZorroYanBo.com). Itwrites short children's stories, in the style of[TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories). The code that trained it is at<https://github.com/FromScratchGPT/FromScratchGPT>, with a tag for each step of each episode.
This revision, `ep002-pretrain`: Pretrained on TinyStories for ten minutes, in episode 2.
It has 6 Transformer blocks and 384 embedding channels. Its vocabulary has 10,000 tokens.
## Use it
```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("ZeroYB/FromScratchGPT", revision="ep002-pretrain")model = AutoModelForCausalLM.from_pretrained("ZeroYB/FromScratchGPT", revision="ep002-pretrain")ids = tokenizer("Once upon a time", return_tensors="pt").input_idsout = model.generate(ids, max_new_tokens=200, do_sample=True, temperature=0.8, top_k=50)print(tokenizer.decode(out[0, ids.shape[1]:], skip_special_tokens=True))```
In a browser, with [Transformers.js](https://huggingface.co/docs/transformers.js), from the 8-bitONNX model in `onnx/`:
```jsimport { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@4.3.1";
const writer = await pipeline("text-generation", "ZeroYB/FromScratchGPT", { dtype: "q8", revision: "ep002-pretrain" });const [out] = await writer("Once upon a time", { max_new_tokens: 100, do_sample: true, top_k: 50 });```
## Revisions
Each episode that changes the model pushes a new commit here, tagged after the episode, such as`ep002-pretrain` for the pretrained model and `ep003-sft` for the fine-tuned one, and`ep012-pretrain` for a model of 91 million parameters, pretrained on four GPUs. `revision=` loadsa tag, and `main` is the latest.
## Limitations
- It writes children's stories, and nothing else: no facts, arithmetic or chat.- Its context window is 256 tokens.1234567891011121314151617181920212223242526272829303132{ "activation_function": "gelu", "architectures": [ "GPT2LMHeadModel" ], "attn_pdrop": 0.0, "bos_token_id": 2, "dtype": "float32", "embd_pdrop": 0.0, "eos_token_id": 2, "initializer_range": 0.02, "layer_norm_epsilon": 1e-05, "model_type": "gpt2", "n_embd": 384, "n_head": 6, "n_inner": null, "n_layer": 6, "n_positions": 256, "pad_token_id": 1, "reorder_and_upcast_attn": false, "resid_pdrop": 0.0, "scale_attn_by_inverse_layer_idx": false, "scale_attn_weights": true, "summary_activation": null, "summary_first_dropout": 0.1, "summary_proj_to_labels": true, "summary_type": "cls_index", "summary_use_proj": true, "transformers_version": "4.57.6", "use_cache": true, "vocab_size": 10000}1234567{ "_from_model_config": true, "bos_token_id": 2, "eos_token_id": 2, "pad_token_id": 1, "transformers_version": "4.57.6"}123version https://git-lfs.github.com/spec/v1oid sha256:b61b641d41917061c024cf3a56737de47652e3c20951f686fbca9dd0f4cfec50size 58350968123version https://git-lfs.github.com/spec/v1oid sha256:9aeaacd47d8425399d268945bafbc1d04afd975172686dcc6f924dc4722acc19size 73911395123version https://git-lfs.github.com/spec/v1oid sha256:145b9b51153367f28050c5707b71823261363447ed2e0f04cf952fd7bc49b346size 18845951123456{ "bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "pad_token": "[PDA]", "unk_token": "[UNK]"}123456789101112131415161718192021222324252627282930313233343536{ "added_tokens_decoder": { "0": { "content": "[UNK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "1": { "content": "[PDA]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "2": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "bos_token": "<|endoftext|>", "clean_up_tokenization_spaces": false, "eos_token": "<|endoftext|>", "extra_special_tokens": {}, "model_max_length": 1000000000000000019884624838656, "pad_token": "[PDA]", "tokenizer_class": "PreTrainedTokenizerFast", "unk_token": "[UNK]"}README.mdAdded+59
config.jsonAdded+32
generation_config.jsonAdded+7
model.safetensorsAdded+3
onnx/model.onnxAdded+3
onnx/model_quantized.onnxAdded+3
special_tokens_map.jsonAdded+6
tokenizer.jsonAdded
tokenizer_config.jsonAdded+36