Instructions to use alainbrown/tiny-gpt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use alainbrown/tiny-gpt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="alainbrown/tiny-gpt", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("alainbrown/tiny-gpt", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use alainbrown/tiny-gpt with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "alainbrown/tiny-gpt" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alainbrown/tiny-gpt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/alainbrown/tiny-gpt
- SGLang
How to use alainbrown/tiny-gpt 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 "alainbrown/tiny-gpt" \ --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": "alainbrown/tiny-gpt", "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 "alainbrown/tiny-gpt" \ --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": "alainbrown/tiny-gpt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use alainbrown/tiny-gpt with Docker Model Runner:
docker model run hf.co/alainbrown/tiny-gpt
| language: | |
| - en | |
| license: mit | |
| library_name: transformers | |
| pipeline_tag: text-generation | |
| datasets: | |
| - roneneldan/TinyStories | |
| tags: | |
| - custom_code | |
| - educational | |
| # Tiny GPT | |
| Tiny GPT is an educational decoder-only Transformer trained from scratch on | |
| the [TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories) | |
| dataset. The implementation is intentionally small and readable. | |
| ## Model details | |
| - Architecture: decoder-only causal language model | |
| - Context length: 512 tokens | |
| - Vocabulary size: 10,000 | |
| - Hidden size: 256 | |
| - Transformer layers: 6 | |
| - Attention heads: 8 | |
| Source code: https://github.com/alainbrown/tiny-gpt | |
| ## Usage | |
| This repository contains custom Transformers code. Review it before enabling | |
| `trust_remote_code`. | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| repo_id = "alainbrown/tiny-gpt" | |
| tokenizer = AutoTokenizer.from_pretrained(repo_id, trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained(repo_id, trust_remote_code=True) | |
| inputs = tokenizer("Once upon a time", return_tensors="pt") | |
| logits = model(**inputs).logits | |
| ``` | |
| ## Intended use | |
| This model is intended for education and experimentation. It is not intended | |
| for production, factual question answering, or safety-critical applications. | |
| ## Limitations | |
| The model is small, trained on synthetic children's stories, and has not been | |
| comprehensively evaluated. It may produce incoherent, repetitive, incorrect, | |
| or inappropriate text. English is the only supported language. | |
| ## Training | |
| The training pipeline is available in the linked GitHub repository. This model | |
| repository excludes optimizer and progress state and contains inference files | |
| only. | |