Instructions to use Stable-string/gpt2-zh-novel-ancient with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Stable-string/gpt2-zh-novel-ancient with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Stable-string/gpt2-zh-novel-ancient")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Stable-string/gpt2-zh-novel-ancient") model = AutoModelForCausalLM.from_pretrained("Stable-string/gpt2-zh-novel-ancient", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Stable-string/gpt2-zh-novel-ancient with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Stable-string/gpt2-zh-novel-ancient" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Stable-string/gpt2-zh-novel-ancient", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Stable-string/gpt2-zh-novel-ancient
- SGLang
How to use Stable-string/gpt2-zh-novel-ancient 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 "Stable-string/gpt2-zh-novel-ancient" \ --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": "Stable-string/gpt2-zh-novel-ancient", "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 "Stable-string/gpt2-zh-novel-ancient" \ --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": "Stable-string/gpt2-zh-novel-ancient", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Stable-string/gpt2-zh-novel-ancient with Docker Model Runner:
docker model run hf.co/Stable-string/gpt2-zh-novel-ancient
Commit ·
6ea41df
1
Parent(s): 842737b
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
这是一个基于cpm训练的模型,你可以使用这个模型来续写文章,文章大体接近于古代。
|
| 2 |
-
下面
|
| 3 |
```python
|
| 4 |
import torch
|
| 5 |
import torch.nn.functional as F
|
|
@@ -79,4 +79,12 @@ pip install torch==1.7.0
|
|
| 79 |
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ransformers==4.6.0
|
| 80 |
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch==1.7.0
|
| 81 |
```
|
| 82 |
-
最后运行此程序,就可以体验gpt2-zh-novel-ancient的续写功能
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
这是一个基于cpm训练的模型,你可以使用这个模型来续写文章,文章大体接近于古代。
|
| 2 |
+
您可以使用下面的一个示例:
|
| 3 |
```python
|
| 4 |
import torch
|
| 5 |
import torch.nn.functional as F
|
|
|
|
| 79 |
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ransformers==4.6.0
|
| 80 |
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch==1.7.0
|
| 81 |
```
|
| 82 |
+
最后运行此程序,就可以体验gpt2-zh-novel-ancient的续写功能
|
| 83 |
+
这是一些运行结果:
|
| 84 |
+
```
|
| 85 |
+
1.
|
| 86 |
+
论天下大势,全凭道教的范蠡;论市井,他才是楚汉王公的治国大业;论乱世风云,他才是江山大太守李商隐的传世佳句。
|
| 87 |
+
我想说的是天下大事,在数不清的人眼里,天下大事是不可能的。自古以来,各人为了建功立业,便开始做生意
|
| 88 |
+
2.
|
| 89 |
+
|
| 90 |
+
```
|