Instructions to use Recor2d/GPT2-ChineseDevBench with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Recor2d/GPT2-ChineseDevBench with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Recor2d/GPT2-ChineseDevBench")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Recor2d/GPT2-ChineseDevBench") model = AutoModelForCausalLM.from_pretrained("Recor2d/GPT2-ChineseDevBench", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Recor2d/GPT2-ChineseDevBench with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Recor2d/GPT2-ChineseDevBench" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Recor2d/GPT2-ChineseDevBench", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Recor2d/GPT2-ChineseDevBench
- SGLang
How to use Recor2d/GPT2-ChineseDevBench 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 "Recor2d/GPT2-ChineseDevBench" \ --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": "Recor2d/GPT2-ChineseDevBench", "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 "Recor2d/GPT2-ChineseDevBench" \ --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": "Recor2d/GPT2-ChineseDevBench", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Recor2d/GPT2-ChineseDevBench with Docker Model Runner:
docker model run hf.co/Recor2d/GPT2-ChineseDevBench
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- zh
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
base_model: uer/gpt2-chinese-cluecorpussmall
|
| 8 |
+
tags:
|
| 9 |
+
- gpt2
|
| 10 |
+
- chinese
|
| 11 |
+
- text-generation
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# GPT2-ChineseDevBench
|
| 15 |
+
|
| 16 |
+
This model is based on `uer/gpt2-chinese-cluecorpussmall` and is intended for Chinese text generation experiments.
|
| 17 |
+
|
| 18 |
+
## Model Details
|
| 19 |
+
|
| 20 |
+
- Base model: `uer/gpt2-chinese-cluecorpussmall`
|
| 21 |
+
- Language: Chinese
|
| 22 |
+
- Task: Text Generation
|
| 23 |
+
- Framework: Transformers / PyTorch
|
| 24 |
+
|
| 25 |
+
## Intended Use
|
| 26 |
+
|
| 27 |
+
This model can be used for Chinese text generation research, testing, and development experiments.
|
| 28 |
+
|
| 29 |
+
## How to Use
|
| 30 |
+
|
| 31 |
+
```python
|
| 32 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 33 |
+
|
| 34 |
+
model_id = "Recor2d/GPT2-ChineseDevBench"
|
| 35 |
+
|
| 36 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 37 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 38 |
+
|
| 39 |
+
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 40 |
+
print(generator("这是很久之前的事情了", max_length=100, do_sample=True))
|