Instructions to use charent/Phi2-Chinese-0.2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use charent/Phi2-Chinese-0.2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="charent/Phi2-Chinese-0.2B")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("charent/Phi2-Chinese-0.2B") model = AutoModelForCausalLM.from_pretrained("charent/Phi2-Chinese-0.2B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use charent/Phi2-Chinese-0.2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "charent/Phi2-Chinese-0.2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "charent/Phi2-Chinese-0.2B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/charent/Phi2-Chinese-0.2B
- SGLang
How to use charent/Phi2-Chinese-0.2B 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 "charent/Phi2-Chinese-0.2B" \ --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": "charent/Phi2-Chinese-0.2B", "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 "charent/Phi2-Chinese-0.2B" \ --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": "charent/Phi2-Chinese-0.2B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use charent/Phi2-Chinese-0.2B with Docker Model Runner:
docker model run hf.co/charent/Phi2-Chinese-0.2B
Update README.md
Browse files
README.md
CHANGED
|
@@ -11,7 +11,9 @@ pipeline_tag: text-generation
|
|
| 11 |
---
|
| 12 |
# Phi2-Chinese-0.2B 从0开始训练自己的Phi2中文小模型
|
| 13 |
|
| 14 |
-
**本项目为实验项目,开源代码及模型权重,预训练数据较少,如果需要效果更好的中文小模型,可以参考项目[ChatLM-mini-Chinese](https://github.com/charent/ChatLM-mini-Chinese)**
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# 1. ⚗️数据清洗
|
| 17 |
代码:[dataset.ipynb](https://github.com/charent/Phi2-mini-Chinese/blob/main/0.dataset.ipynb)。
|
|
@@ -36,7 +38,7 @@ tokenizer训练非常吃内存:
|
|
| 36 |
# 3. ⛏️CLM因果模型预训练
|
| 37 |
代码:[pretrain.ipynb](https://github.com/charent/Phi2-mini-Chinese/blob/main/2.pretrain.ipynb)
|
| 38 |
|
| 39 |
-
用大量文本进行无监督预训练,
|
| 40 |
|
| 41 |
数据集格式:一个样本一句话,太长的可以截断分为多个样本。
|
| 42 |
|
|
|
|
| 11 |
---
|
| 12 |
# Phi2-Chinese-0.2B 从0开始训练自己的Phi2中文小模型
|
| 13 |
|
| 14 |
+
**本项目为实验项目,开源代码及模型权重,预训练数据较少,如果需要效果更好的中文小模型,可以参考项目[ChatLM-mini-Chinese](https://github.com/charent/ChatLM-mini-Chinese)**
|
| 15 |
+
|
| 16 |
+
**Github仓库地址:[Phi2-mini-Chinese](https://github.com/charent/Phi2-mini-Chinese)**
|
| 17 |
|
| 18 |
# 1. ⚗️数据清洗
|
| 19 |
代码:[dataset.ipynb](https://github.com/charent/Phi2-mini-Chinese/blob/main/0.dataset.ipynb)。
|
|
|
|
| 38 |
# 3. ⛏️CLM因果模型预训练
|
| 39 |
代码:[pretrain.ipynb](https://github.com/charent/Phi2-mini-Chinese/blob/main/2.pretrain.ipynb)
|
| 40 |
|
| 41 |
+
用大量文本进行无监督预训练,主要使用`bell open source`的数据集[BELLE](https://github.com/LianjiaTech/BELLE)。
|
| 42 |
|
| 43 |
数据集格式:一个样本一句话,太长的可以截断分为多个样本。
|
| 44 |
|