Text Generation
Transformers
Safetensors
Japanese
Chinese
English
chatglm
feature-extraction
conversational
custom_code
Instructions to use dummy-foo/ChatGLM3-Japanese with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dummy-foo/ChatGLM3-Japanese with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="dummy-foo/ChatGLM3-Japanese", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("dummy-foo/ChatGLM3-Japanese", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use dummy-foo/ChatGLM3-Japanese with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "dummy-foo/ChatGLM3-Japanese" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dummy-foo/ChatGLM3-Japanese", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/dummy-foo/ChatGLM3-Japanese
- SGLang
How to use dummy-foo/ChatGLM3-Japanese 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 "dummy-foo/ChatGLM3-Japanese" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dummy-foo/ChatGLM3-Japanese", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "dummy-foo/ChatGLM3-Japanese" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dummy-foo/ChatGLM3-Japanese", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use dummy-foo/ChatGLM3-Japanese with Docker Model Runner:
docker model run hf.co/dummy-foo/ChatGLM3-Japanese
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- ja
|
| 4 |
+
- zh
|
| 5 |
+
- en
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
---
|
| 8 |
+
[ChatGLM3-6B](https://github.com/THUDM/ChatGLM3)是一个中英双语大模型,本项目为ChatGLM3-6B加入日文能力。
|
| 9 |
+
通过sentencepiece在日文wiki和青空文库上训练BPE的tokenizer,词表扩充14000(64789 -> 78554),相比原生ChatGLM3的日文编码效率提升接近一倍,中文英文编码效率不变。
|
| 10 |
+
|
| 11 |
+
共有两个模型:
|
| 12 |
+
- [ChatGLM3-Japanese-Zero]( https://huggingface.co/dummy-foo/ChatGLM3-Japanese-Zero ):本模型,经过扩词表和resize后的模型,保留了ChatGLM3的中英文能力,尚无日文能力,但因为编码效率高,适合在日文语料上训练。
|
| 13 |
+
- [ChatGLM3-Japanese](https://huggingface.co/dummy-foo/ChatGLM3-Japanese):还在训练中,一周内更新,对ChatGLM3-Japanese-Zero进行日文语料增量预训练和指令微调的模型,可以日文对话。
|
| 14 |
+
|
| 15 |
+
[GitHub](https://github.com/akiragy/ChatGLM3-Japanese)上有全流程的代码,包含训练tokenizer和训练模型。
|
| 16 |
+
|
| 17 |
+
使用样例:
|
| 18 |
+
```python
|
| 19 |
+
import torch
|
| 20 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 21 |
+
|
| 22 |
+
tokenizer = AutoTokenizer.from_pretrained("dummy-foo/ChatGLM3-Japanese-Zero", trust_remote_code=True)
|
| 23 |
+
model = AutoModelForCausalLM.from_pretrained("dummy-foo/ChatGLM3-Japanese-Zero", trust_remote_code=True, device_map='cuda:0', torch_dtype=torch.float16)
|
| 24 |
+
|
| 25 |
+
# test Chinese chat
|
| 26 |
+
response, _ = model.chat(tokenizer, "你是谁", history=[])
|
| 27 |
+
print("\nQ:你是谁,A:", response)
|
| 28 |
+
response, _ = model.chat(tokenizer, "你喜欢甜粽子还是咸粽子", history=[])
|
| 29 |
+
print("\nQ:你喜欢甜粽子还是咸粽子,A:", response)
|
| 30 |
+
|
| 31 |
+
# test Japanese chat
|
| 32 |
+
response, _ = model.chat(tokenizer, "あなたは誰ですか", history=[])
|
| 33 |
+
print("\nQ:あなたは誰ですか,A:", response)
|
| 34 |
+
response, _ = model.chat(tokenizer, "すみません、ちょっとお聞きしたいことがあるんですが", history=[])
|
| 35 |
+
print("\nQ:すみません、ちょっとお聞きしたいことがあるんですが,A:", response)
|
| 36 |
+
|
| 37 |
+
# test Japanese tokenizer
|
| 38 |
+
print("\ntokens: ", tokenizer.tokenize("恥の多い生涯を送って来ました。自分には、人間の生活というものが、見当つかないのです。"))
|
| 39 |
+
```
|