Instructions to use coderian/TinyGPT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use coderian/TinyGPT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="coderian/TinyGPT", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("coderian/TinyGPT", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use coderian/TinyGPT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "coderian/TinyGPT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "coderian/TinyGPT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/coderian/TinyGPT
- SGLang
How to use coderian/TinyGPT 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 "coderian/TinyGPT" \ --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": "coderian/TinyGPT", "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 "coderian/TinyGPT" \ --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": "coderian/TinyGPT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use coderian/TinyGPT with Docker Model Runner:
docker model run hf.co/coderian/TinyGPT
Download models/transformer_block.py from coderian/TinyGPT: direct link, hf CLI and curl.
- Browser
- Download file 841 Bytes
-
https://huggingface.co/coderian/TinyGPT/resolve/main/models/transformer_block.py
- Command line
-
hf download hf://coderian/TinyGPT/models/transformer_block.py
-
curl -L -o transformer_block.py https://huggingface.co/coderian/TinyGPT/resolve/main/models/transformer_block.py
841 Bytes
| from models.attention import CausalSelfAttention | |
| import torch.nn as nn | |
| import torch | |
| class TransformerBlock(nn.Module): | |
| def __init__(self, embed_dim): | |
| super().__init__() | |
| self.ln1 = nn.LayerNorm(embed_dim) | |
| self.attention = CausalSelfAttention( | |
| embed_dim | |
| ) | |
| self.ln2 = nn.LayerNorm(embed_dim) | |
| # FFN | |
| self.ffn = nn.Sequential( | |
| nn.Linear( | |
| in_features=embed_dim, | |
| out_features=4*embed_dim | |
| ), | |
| nn.GELU(), | |
| nn.Linear( | |
| in_features=4*embed_dim, | |
| out_features=embed_dim | |
| ) | |
| ) | |
| def forward(self, x): | |
| x = x + self.attention( | |
| self.ln1(x) | |
| ) | |
| x = x + self.ffn( | |
| self.ln2(x) | |
| ) | |
| return x | |