Text Generation
Transformers
Safetensors
English
tinygpt2
causal-lm
instruction-tuned
sft
rope
grouped-query-attention
rms-norm
custom_code
Instructions to use NotShrirang/tinygpt2-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NotShrirang/tinygpt2-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NotShrirang/tinygpt2-it", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("NotShrirang/tinygpt2-it", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NotShrirang/tinygpt2-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NotShrirang/tinygpt2-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NotShrirang/tinygpt2-it", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/NotShrirang/tinygpt2-it
- SGLang
How to use NotShrirang/tinygpt2-it 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 "NotShrirang/tinygpt2-it" \ --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": "NotShrirang/tinygpt2-it", "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 "NotShrirang/tinygpt2-it" \ --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": "NotShrirang/tinygpt2-it", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use NotShrirang/tinygpt2-it with Docker Model Runner:
docker model run hf.co/NotShrirang/tinygpt2-it
File size: 946 Bytes
f9db966 | 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 | """HuggingFace-compatible configuration for TinyGPT2 models."""
from transformers import PretrainedConfig
class TinyGPT2HFConfig(PretrainedConfig):
model_type = "tinygpt2"
def __init__(
self,
vocab_size=50304,
block_size=512,
n_embd=768,
n_head=12,
n_layer=12,
gqa_kv_head=4,
hidden_size=2048,
dropout=0.1,
pad_token_id=50257,
eos_token_id=50256,
bos_token_id=None,
**kwargs,
):
self.vocab_size = vocab_size
self.block_size = block_size
self.n_embd = n_embd
self.n_head = n_head
self.n_layer = n_layer
self.gqa_kv_head = gqa_kv_head
self.hidden_size = hidden_size
self.dropout = dropout
super().__init__(
pad_token_id=pad_token_id,
eos_token_id=eos_token_id,
bos_token_id=bos_token_id,
**kwargs,
)
|