Text Generation
Transformers
PyTorch
TensorFlow
JAX
LiteRT
Rust
ONNX
Safetensors
English
gpt2
exbert
text-generation-inference
Instructions to use reach-vb/gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use reach-vb/gpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="reach-vb/gpt2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("reach-vb/gpt2") model = AutoModelForCausalLM.from_pretrained("reach-vb/gpt2") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use reach-vb/gpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "reach-vb/gpt2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "reach-vb/gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/reach-vb/gpt2
- SGLang
How to use reach-vb/gpt2 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 "reach-vb/gpt2" \ --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": "reach-vb/gpt2", "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 "reach-vb/gpt2" \ --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": "reach-vb/gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use reach-vb/gpt2 with Docker Model Runner:
docker model run hf.co/reach-vb/gpt2
Adding ONNX file of this model
#2
by reach-vb - opened
- onnx/config.json +2 -2
- onnx/generation_config.json +1 -1
- onnx/model.onnx +3 -0
- onnx/tokenizer.json +1 -1
- onnx/tokenizer_config.json +10 -0
onnx/config.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"_name_or_path": "gpt2",
|
| 3 |
"activation_function": "gelu_new",
|
| 4 |
"architectures": [
|
| 5 |
"GPT2LMHeadModel"
|
|
@@ -32,7 +32,7 @@
|
|
| 32 |
"max_length": 50
|
| 33 |
}
|
| 34 |
},
|
| 35 |
-
"transformers_version": "4.
|
| 36 |
"use_cache": true,
|
| 37 |
"vocab_size": 50257
|
| 38 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"_name_or_path": "reach-vb/gpt2",
|
| 3 |
"activation_function": "gelu_new",
|
| 4 |
"architectures": [
|
| 5 |
"GPT2LMHeadModel"
|
|
|
|
| 32 |
"max_length": 50
|
| 33 |
}
|
| 34 |
},
|
| 35 |
+
"transformers_version": "4.37.2",
|
| 36 |
"use_cache": true,
|
| 37 |
"vocab_size": 50257
|
| 38 |
}
|
onnx/generation_config.json
CHANGED
|
@@ -2,5 +2,5 @@
|
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 50256,
|
| 4 |
"eos_token_id": 50256,
|
| 5 |
-
"transformers_version": "4.
|
| 6 |
}
|
|
|
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 50256,
|
| 4 |
"eos_token_id": 50256,
|
| 5 |
+
"transformers_version": "4.37.2"
|
| 6 |
}
|
onnx/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:084a050a7bc2445beedbc2d6da2eb1355ac0a6e818dd2f1ec5aa601605363dee
|
| 3 |
+
size 653670059
|
onnx/tokenizer.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
| 9 |
"single_word": false,
|
| 10 |
"lstrip": false,
|
| 11 |
"rstrip": false,
|
| 12 |
-
"normalized":
|
| 13 |
"special": true
|
| 14 |
}
|
| 15 |
],
|
|
|
|
| 9 |
"single_word": false,
|
| 10 |
"lstrip": false,
|
| 11 |
"rstrip": false,
|
| 12 |
+
"normalized": true,
|
| 13 |
"special": true
|
| 14 |
}
|
| 15 |
],
|
onnx/tokenizer_config.json
CHANGED
|
@@ -1,5 +1,15 @@
|
|
| 1 |
{
|
| 2 |
"add_prefix_space": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
"bos_token": "<|endoftext|>",
|
| 4 |
"clean_up_tokenization_spaces": true,
|
| 5 |
"eos_token": "<|endoftext|>",
|
|
|
|
| 1 |
{
|
| 2 |
"add_prefix_space": false,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"50256": {
|
| 5 |
+
"content": "<|endoftext|>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": true,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": true
|
| 11 |
+
}
|
| 12 |
+
},
|
| 13 |
"bos_token": "<|endoftext|>",
|
| 14 |
"clean_up_tokenization_spaces": true,
|
| 15 |
"eos_token": "<|endoftext|>",
|