Exploring and Adapting Chinese GPT to Pinyin Input Method
Paper • 2203.00249 • Published
How to use aihijo/transformers4ime-pinyingpt-concat with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="aihijo/transformers4ime-pinyingpt-concat") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("aihijo/transformers4ime-pinyingpt-concat")
model = AutoModelForCausalLM.from_pretrained("aihijo/transformers4ime-pinyingpt-concat", device_map="auto")How to use aihijo/transformers4ime-pinyingpt-concat with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "aihijo/transformers4ime-pinyingpt-concat"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "aihijo/transformers4ime-pinyingpt-concat",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/aihijo/transformers4ime-pinyingpt-concat
How to use aihijo/transformers4ime-pinyingpt-concat with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "aihijo/transformers4ime-pinyingpt-concat" \
--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": "aihijo/transformers4ime-pinyingpt-concat",
"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 "aihijo/transformers4ime-pinyingpt-concat" \
--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": "aihijo/transformers4ime-pinyingpt-concat",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use aihijo/transformers4ime-pinyingpt-concat with Docker Model Runner:
docker model run hf.co/aihijo/transformers4ime-pinyingpt-concat
Transformers4IME is repo for exploring and adapting transformer-based models to IME.
PinyinGPT is a model from Exploring and Adapting Chinese GPT to Pinyin Input Method which appears in ACL2022.
@article{tan2022exploring,
title={Exploring and Adapting Chinese GPT to Pinyin Input Method},
author={Tan, Minghuan and Dai, Yong and Tang, Duyu and Feng, Zhangyin and Huang, Guoping and Jiang, Jing and Li, Jiwei and Shi, Shuming},
journal={arXiv preprint arXiv:2203.00249},
year={2022}
}
The code can be found at