Revisiting Pre-Trained Models for Chinese Natural Language Processing
Paper • 2004.13922 • Published
How to use hfl/chinese-xlnet-mid with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="hfl/chinese-xlnet-mid") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("hfl/chinese-xlnet-mid")
model = AutoModelForCausalLM.from_pretrained("hfl/chinese-xlnet-mid")How to use hfl/chinese-xlnet-mid with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "hfl/chinese-xlnet-mid"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "hfl/chinese-xlnet-mid",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/hfl/chinese-xlnet-mid
How to use hfl/chinese-xlnet-mid with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "hfl/chinese-xlnet-mid" \
--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": "hfl/chinese-xlnet-mid",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "hfl/chinese-xlnet-mid" \
--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": "hfl/chinese-xlnet-mid",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use hfl/chinese-xlnet-mid with Docker Model Runner:
docker model run hf.co/hfl/chinese-xlnet-mid
This project provides a XLNet pre-training model for Chinese, which aims to enrich Chinese natural language processing resources and provide a variety of Chinese pre-training model selection. We welcome all experts and scholars to download and use this model.
This project is based on CMU/Google official XLNet: https://github.com/zihangdai/xlnet
You may also interested in,
More resources by HFL: https://github.com/ymcui/HFL-Anthology
If you find our resource or paper is useful, please consider including the following citation in your paper.
@inproceedings{cui-etal-2020-revisiting,
title = "Revisiting Pre-Trained Models for {C}hinese Natural Language Processing",
author = "Cui, Yiming and
Che, Wanxiang and
Liu, Ting and
Qin, Bing and
Wang, Shijin and
Hu, Guoping",
booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: Findings",
month = nov,
year = "2020",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2020.findings-emnlp.58",
pages = "657--668",
}