Instructions to use openlmlab/open-chinese-llama-7b-patch with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openlmlab/open-chinese-llama-7b-patch with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openlmlab/open-chinese-llama-7b-patch")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openlmlab/open-chinese-llama-7b-patch") model = AutoModelForCausalLM.from_pretrained("openlmlab/open-chinese-llama-7b-patch", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openlmlab/open-chinese-llama-7b-patch with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openlmlab/open-chinese-llama-7b-patch" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openlmlab/open-chinese-llama-7b-patch", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/openlmlab/open-chinese-llama-7b-patch
- SGLang
How to use openlmlab/open-chinese-llama-7b-patch 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 "openlmlab/open-chinese-llama-7b-patch" \ --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": "openlmlab/open-chinese-llama-7b-patch", "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 "openlmlab/open-chinese-llama-7b-patch" \ --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": "openlmlab/open-chinese-llama-7b-patch", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use openlmlab/open-chinese-llama-7b-patch with Docker Model Runner:
docker model run hf.co/openlmlab/open-chinese-llama-7b-patch
Shuo Zhang commited on
Commit ·
fe34adb
1
Parent(s): 7dc9db5
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- zh
|
| 5 |
+
tags:
|
| 6 |
+
- Chinese
|
| 7 |
---
|
| 8 |
+
|
| 9 |
+
# Open-Chinese-LLaMA-7B-Patch
|
| 10 |
+
|
| 11 |
+
This model is a **Chinese large language model base** generated from the [LLaMA](https://github.com/facebookresearch/llama)-7B model after **secondary pre-training** on Chinese datasets.
|
| 12 |
+
|
| 13 |
+
This model is a **patch** model and must be used in conjunction with the official weights. For the installation of the patch and related tutorials, please refer to [OpenLMLab/llama](https://github.com/OpenLMLab/llama).
|
| 14 |
+
|
| 15 |
+
## Usage
|
| 16 |
+
|
| 17 |
+
Since the official weights for [LLaMA](https://github.com/facebookresearch/llama)-7B have not been open-sourced, the model released this time is of the **patch** type, which needs to be used in combination with the original official weights.
|
| 18 |
+
|
| 19 |
+
You can install the **patch** using `tools/patch_model.py`, for example:
|
| 20 |
+
|
| 21 |
+
```bash
|
| 22 |
+
|
| 23 |
+
python tools/patch_model.py --base_model <path_or_name_to_original_model>
|
| 24 |
+
--patch_model openlmlab/open-chinese-llama-7b-patch
|
| 25 |
+
--base_model_format <hf_or_raw>
|
| 26 |
+
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
The **patch** is installed in place, which means that the installed **patch** is the complete `hf` format weight. You can use `transformers` to load the model.
|
| 30 |
+
|
| 31 |
+
## Quick Experience via Command Line
|
| 32 |
+
|
| 33 |
+
The **patched** model can be easily loaded by `transformers`. For a quick experience, we provide a console Demo:
|
| 34 |
+
|
| 35 |
+
```bash
|
| 36 |
+
|
| 37 |
+
python cli_demo.py --model openlmlab/open-chinese-llama-7b-patch
|
| 38 |
+
--devices 0
|
| 39 |
+
--max_length 1024
|
| 40 |
+
--do_sample true
|
| 41 |
+
--top_k 40
|
| 42 |
+
--top_p 0.8
|
| 43 |
+
--temperature 0.7
|
| 44 |
+
--penalty 1.02
|
| 45 |
+
|
| 46 |
+
```
|