Text Generation
Transformers
PyTorch
Safetensors
Chinese
gpt2
Text Generation
text-generation-inference
Instructions to use shibing624/gpt2-dialogbot-base-chinese with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shibing624/gpt2-dialogbot-base-chinese with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="shibing624/gpt2-dialogbot-base-chinese")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("shibing624/gpt2-dialogbot-base-chinese") model = AutoModelForCausalLM.from_pretrained("shibing624/gpt2-dialogbot-base-chinese", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use shibing624/gpt2-dialogbot-base-chinese with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "shibing624/gpt2-dialogbot-base-chinese" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shibing624/gpt2-dialogbot-base-chinese", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/shibing624/gpt2-dialogbot-base-chinese
- SGLang
How to use shibing624/gpt2-dialogbot-base-chinese 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 "shibing624/gpt2-dialogbot-base-chinese" \ --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": "shibing624/gpt2-dialogbot-base-chinese", "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 "shibing624/gpt2-dialogbot-base-chinese" \ --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": "shibing624/gpt2-dialogbot-base-chinese", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use shibing624/gpt2-dialogbot-base-chinese with Docker Model Runner:
docker model run hf.co/shibing624/gpt2-dialogbot-base-chinese
GPT2 for Chinese Dialog Model(gpt2-dialogbot-base-chinese)
GPT2中文对话生成模型
gpt2-dialogbot-base-chinese evaluate couplet test data:
The overall performance of GPT2 on dialog test:
| input_text | target_text |
|---|---|
| 今天你的病好点了吗? | 好多了,谢谢你的关心 |
在常见中文闲聊数据集(包含小黄鸡语料、豆瓣语料、电视剧对白语料、贴吧论坛回帖语料、微博语料、PTT八卦语料、青云语料等)上,基本能语义正确的回答问题。
GPT2对话模型的网络结构(原生GPT2):
Usage
本项目开源在对话文本生成项目:dialogbot,可支持GPT2模型,通过如下命令调用:
Install package:
pip install -U dialogbot
>>> from dialogbot import GPTBot
>>> model = GPTBot("shibing624/gpt2-dialogbot-base-chinese")
>>> r = model.answer("今天你的病好点了吗?")
'好多了,谢谢你的关心'
模型文件组成:
gpt2-dialogbot-base-chinese
├── config.json
├── pytorch_model.bin
└── vocab.txt
训练数据集
中文对话数据集
闲聊语料分享
| 中文闲聊语料 | 数据集地址 | 语料描述 |
|---|---|---|
| 常见中文闲聊 | chinese_chatbot_corpus | 包含小黄鸡语料、豆瓣语料、电视剧对白语料、贴吧论坛回帖语料、微博语料、PTT八卦语料、青云语料等 |
| 50w中文闲聊语料 | 百度网盘【提取码:4g5e】 或 GoogleDrive | 包含50w个多轮对话的原始语料、预处理数据 |
| 100w中文闲聊语料 | 百度网盘【提取码:s908】 或 GoogleDrive | 包含100w个多轮对话的原始语料、预处理数据 |
数据格式:
谢谢你所做的一切
你开心就好
开心
嗯因为你的心里只有学习
某某某,还有你
这个某某某用的好
你们宿舍都是这么厉害的人吗
眼睛特别搞笑这土也不好捏但就是觉得挺可爱
特别可爱啊
如果需要训练GPT2模型,请参考https://github.com/shibing624/dialogbot
Citation
如果你在研究中使用了dialogbot,请按如下格式引用:
@software{dialogbot,
author = {Xu Ming},
title = {dialogbot: Dialogue Model Technology Tool},
year = {2021},
url = {https://github.com/shibing624/dialogbot},
}
- Downloads last month
- 1,442
