Text Generation
Transformers
Safetensors
pinyin_code
causal-lm
trust-remote-code
sentencepiece
custom_code
Instructions to use timorobrecht/full_chinese_gpu3.2-dpo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use timorobrecht/full_chinese_gpu3.2-dpo with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="timorobrecht/full_chinese_gpu3.2-dpo", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("timorobrecht/full_chinese_gpu3.2-dpo", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use timorobrecht/full_chinese_gpu3.2-dpo with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "timorobrecht/full_chinese_gpu3.2-dpo" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "timorobrecht/full_chinese_gpu3.2-dpo", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/timorobrecht/full_chinese_gpu3.2-dpo
- SGLang
How to use timorobrecht/full_chinese_gpu3.2-dpo 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 "timorobrecht/full_chinese_gpu3.2-dpo" \ --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": "timorobrecht/full_chinese_gpu3.2-dpo", "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 "timorobrecht/full_chinese_gpu3.2-dpo" \ --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": "timorobrecht/full_chinese_gpu3.2-dpo", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use timorobrecht/full_chinese_gpu3.2-dpo with Docker Model Runner:
docker model run hf.co/timorobrecht/full_chinese_gpu3.2-dpo
| library_name: transformers | |
| pipeline_tag: text-generation | |
| tags: | |
| - causal-lm | |
| - trust-remote-code | |
| - sentencepiece | |
| # Pinyin-Code Causal LM | |
| This repository contains a custom Transformers causal language model. | |
| External evaluation repositories should load it with | |
| `trust_remote_code=True` and use the `causal` backend. | |
| ## Dependencies | |
| Install the runtime dependencies before loading the model: | |
| ```bash | |
| pip install torch transformers safetensors sentencepiece pypinyin jieba | |
| ``` | |
| `sentencepiece` is required for `AutoTokenizer`. `pypinyin` is required | |
| for raw Mandarin-to-pinyin tokenization. `jieba` is required when | |
| `use_jieba` is true; this export was created with `use_jieba=true`. | |
| ## Loading | |
| ```python | |
| from transformers import AutoConfig, AutoModel, AutoModelForCausalLM, AutoTokenizer | |
| model_path = "PATH_OR_REPO_ID" | |
| config = AutoConfig.from_pretrained(model_path, trust_remote_code=True) | |
| tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True) | |
| base_model = AutoModel.from_pretrained(model_path, trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True) | |
| ``` | |
| ## Evaluation | |
| Configure external evaluators with: | |
| - model path: this local folder or Hugging Face repo ID | |
| - backend: `causal` | |
| - trust remote code: enabled | |
| The tokenizer accepts raw text through standard calls such as | |
| `tokenizer(text)`, `tokenizer(text, add_special_tokens=False)`, and | |
| `tokenizer(texts, padding=True, truncation=True, return_tensors="pt")`. | |
| It also accepts `return_offsets_mapping=True` for compatibility with | |
| completion-ranking evaluators that need suffix masks. The model supports | |
| `output_hidden_states=True` for representation extraction tasks. | |
| This export sets `patch_pathlib_utf8_open=true` in `config.json`. | |
| When loaded with `trust_remote_code=True`, the config installs a narrow | |
| Windows compatibility shim so later text-mode `Path.open("r")` calls | |
| without an explicit encoding default to UTF-8. Set | |
| `PINYIN_CODE_DISABLE_UTF8_OPEN_PATCH=1` before loading the model to | |
| disable that shim. | |
| Export metadata: | |
| - transliteration: `pinyin-code` | |
| - use_jieba: `true` | |