Instructions to use karpathy/gpt2_1558M_final2_hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use karpathy/gpt2_1558M_final2_hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="karpathy/gpt2_1558M_final2_hf")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("karpathy/gpt2_1558M_final2_hf") model = AutoModelForCausalLM.from_pretrained("karpathy/gpt2_1558M_final2_hf") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use karpathy/gpt2_1558M_final2_hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "karpathy/gpt2_1558M_final2_hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "karpathy/gpt2_1558M_final2_hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/karpathy/gpt2_1558M_final2_hf
- SGLang
How to use karpathy/gpt2_1558M_final2_hf 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 "karpathy/gpt2_1558M_final2_hf" \ --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": "karpathy/gpt2_1558M_final2_hf", "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 "karpathy/gpt2_1558M_final2_hf" \ --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": "karpathy/gpt2_1558M_final2_hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use karpathy/gpt2_1558M_final2_hf with Docker Model Runner:
docker model run hf.co/karpathy/gpt2_1558M_final2_hf
Model Card for Model ID
This is a GPT-2 model trained in llm.c, for 32K steps (of 1M batch size) on FineWeb-EDU.
A lot more detailed information is here: https://github.com/karpathy/llm.c/discussions/677
Bias, Risks, and Limitations
Eagerly generates disinformation about English-speaking unicorns in the Andes mountains.
- Downloads last month
- 108