Instructions to use OpenMOSS-Team/moss-moon-003-sft-plugin-int4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenMOSS-Team/moss-moon-003-sft-plugin-int4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenMOSS-Team/moss-moon-003-sft-plugin-int4", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("OpenMOSS-Team/moss-moon-003-sft-plugin-int4", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenMOSS-Team/moss-moon-003-sft-plugin-int4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenMOSS-Team/moss-moon-003-sft-plugin-int4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenMOSS-Team/moss-moon-003-sft-plugin-int4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/OpenMOSS-Team/moss-moon-003-sft-plugin-int4
- SGLang
How to use OpenMOSS-Team/moss-moon-003-sft-plugin-int4 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 "OpenMOSS-Team/moss-moon-003-sft-plugin-int4" \ --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": "OpenMOSS-Team/moss-moon-003-sft-plugin-int4", "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 "OpenMOSS-Team/moss-moon-003-sft-plugin-int4" \ --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": "OpenMOSS-Team/moss-moon-003-sft-plugin-int4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use OpenMOSS-Team/moss-moon-003-sft-plugin-int4 with Docker Model Runner:
docker model run hf.co/OpenMOSS-Team/moss-moon-003-sft-plugin-int4
Update GitHub URLs from OpenLMLab to OpenMOSS
Browse files
README.md
CHANGED
|
@@ -48,8 +48,8 @@ tags:
|
|
| 48 |
### Data
|
| 49 |
|
| 50 |
- [**moss-002-sft-data**](https://huggingface.co/datasets/OpenMOSS-Team/moss-002-sft-data): The multi-turn conversational data used to train MOSS-002, covering helpfulness, honesty, and harmlessness. The data is consisting of 570K English and 590K Chinese conversations generated by `text-davinci-003`.
|
| 51 |
-
- [**moss-003-sft-data**](https://github.com/
|
| 52 |
-
- [**moss-003-sft-plugin-data**](https://github.com/
|
| 53 |
- **moss-003-pm-data**: The preference data used to train `moss-moon-003-pm`, including ~180K additional dialogue contexts and their corresponding responses generated by `moss-moon-003-sft`. Will be publicly available in the near future.
|
| 54 |
|
| 55 |
### Engineering Solutions
|
|
@@ -67,43 +67,43 @@ MOSS is an open-sourced plugin-augmented conversational language model. `moss-mo
|
|
| 67 |
|
| 68 |
**MOSS Use Cases**:
|
| 69 |
|
| 70 |
-
 at the first time the model generates until reaching `<eoc>`, we extract the predicted plugins (and their parameters) and obtain corresponding results by executing these plugins. (2) at the second time we write results returned by the used plugins into "Results" and feed the concatenated text into MOSS to get responses. At this time the model should generate until reaching `<eom>`.
|
| 279 |
|
| 280 |
-
We control the use of the plugins through [meta instruction](https://github.com/
|
| 281 |
|
| 282 |
```
|
| 283 |
- Inner thoughts: enabled.
|
|
@@ -356,23 +356,23 @@ Search("黑暗荣耀 主演") =>
|
|
| 356 |
<|MOSS|>: 《黑暗荣耀》的主演包括宋慧乔、李到晛、林智妍、郑星一等人。<sup><|1|></sup><eom>
|
| 357 |
```
|
| 358 |
|
| 359 |
-
Please refer to [conversation_with_plugins](https://github.com/
|
| 360 |
|
| 361 |
#### Web Demo
|
| 362 |
|
| 363 |
**Streamlit**
|
| 364 |
|
| 365 |
-
We provide a [Streamlit](https://streamlit.io/)-based web demo. First install Streamlit by `pip install streamlit` and then run [moss_web_demo_streamlit.py](https://github.com/
|
| 366 |
|
| 367 |
```bash
|
| 368 |
streamlit run moss_web_demo_streamlit.py --server.port 8888
|
| 369 |
```
|
| 370 |
|
| 371 |
-
: The multi-turn conversational data used to train MOSS-002, covering helpfulness, honesty, and harmlessness. The data is consisting of 570K English and 590K Chinese conversations generated by `text-davinci-003`.
|
| 51 |
+
- [**moss-003-sft-data**](https://github.com/OpenMOSS/MOSS/tree/main/SFT_data/conversations/conversation_without_plugins): The multi-turn conversational data used to train `moss-moon-003-sft`. The data is generated by `gpt-3.5-turbo` from a seed set of user prompts collected through our early deployed MOSS-002 API. In contrast to `moss-002-sft-data`, `moss-003-sft-data` is well-aligned with the real-world distribution of user intents, covering finer-grained categories and more diverse harmlessness-related data. The data consists of ~1.1M conversational data. Currently we open-sourced a small portion of it and will make public the full data in the near future.
|
| 52 |
+
- [**moss-003-sft-plugin-data**](https://github.com/OpenMOSS/MOSS/tree/main/SFT_data/conversations/conversation_with_plugins): The plugin-augmented multi-turn conversational data, which is consisting of ~300K conversations in which the AI assistant uses four plugins (search engine, text-to-image, calculator, and equation solver) to generate responses. Currently we open-sourced a small portion of data and will make public the full data in the near future.
|
| 53 |
- **moss-003-pm-data**: The preference data used to train `moss-moon-003-pm`, including ~180K additional dialogue contexts and their corresponding responses generated by `moss-moon-003-sft`. Will be publicly available in the near future.
|
| 54 |
|
| 55 |
### Engineering Solutions
|
|
|
|
| 67 |
|
| 68 |
**MOSS Use Cases**:
|
| 69 |
|
| 70 |
+

|
| 71 |
|
| 72 |
<details><summary><b>Simple Math Problems</b></summary>
|
| 73 |
|
| 74 |
+

|
| 75 |
|
| 76 |
+

|
| 77 |
|
| 78 |
</details>
|
| 79 |
|
| 80 |
<details><summary><b>Using Text-to-Image Plugins</b></summary>
|
| 81 |
|
| 82 |
+

|
| 83 |
|
| 84 |
</details>
|
| 85 |
|
| 86 |
<details><summary><b>Chinese Skills</b></summary>
|
| 87 |
|
| 88 |
+

|
| 89 |
|
| 90 |
+

|
| 91 |
|
| 92 |
+

|
| 93 |
|
| 94 |
</details>
|
| 95 |
|
| 96 |
<details><summary><b>Coding</b></summary>
|
| 97 |
|
| 98 |
+

|
| 99 |
|
| 100 |
+

|
| 101 |
|
| 102 |
</details>
|
| 103 |
|
| 104 |
<details><summary><b>Harmlessness</b></summary>
|
| 105 |
|
| 106 |
+

|
| 107 |
|
| 108 |
</details>
|
| 109 |
|
|
|
|
| 123 |
1. Clone this repo to your local/remote machine.
|
| 124 |
|
| 125 |
```bash
|
| 126 |
+
git clone https://github.com/OpenMOSS/MOSS.git
|
| 127 |
cd MOSS
|
| 128 |
```
|
| 129 |
|
|
|
|
| 277 |
|
| 278 |
in which "Human" is the user input and "Results" is the contents returned by the invoked plugins, so "Human" and "Results" should be written by the program, and the rest fields are generated by the model. Therefore we need to call two times of model inference: (1) at the first time the model generates until reaching `<eoc>`, we extract the predicted plugins (and their parameters) and obtain corresponding results by executing these plugins. (2) at the second time we write results returned by the used plugins into "Results" and feed the concatenated text into MOSS to get responses. At this time the model should generate until reaching `<eom>`.
|
| 279 |
|
| 280 |
+
We control the use of the plugins through [meta instruction](https://github.com/OpenMOSS/MOSS/blob/main/meta_instruction.txt). By default, the status of all the plugins is `disabled`. If you want to enable some plugins, first set the "Inner Thoughts" as `enabled`, and then change the status of the plugins to `enabled` and provide the interface. An example is as follows,
|
| 281 |
|
| 282 |
```
|
| 283 |
- Inner thoughts: enabled.
|
|
|
|
| 356 |
<|MOSS|>: 《黑暗荣耀》的主演包括宋慧乔、李到晛、林智妍、郑星一等人。<sup><|1|></sup><eom>
|
| 357 |
```
|
| 358 |
|
| 359 |
+
Please refer to [conversation_with_plugins](https://github.com/OpenMOSS/MOSS/tree/main/SFT_data/conversations/conversation_with_plugins) for data formats of other plugins. See also our open-sourced [MOSS WebSearchTool](https://github.com/OpenLMLab/MOSS_WebSearchTool) for the web search plugin.
|
| 360 |
|
| 361 |
#### Web Demo
|
| 362 |
|
| 363 |
**Streamlit**
|
| 364 |
|
| 365 |
+
We provide a [Streamlit](https://streamlit.io/)-based web demo. First install Streamlit by `pip install streamlit` and then run [moss_web_demo_streamlit.py](https://github.com/OpenMOSS/MOSS/blob/main/moss_web_demo_streamlit.py) in this repo to present a web demo:
|
| 366 |
|
| 367 |
```bash
|
| 368 |
streamlit run moss_web_demo_streamlit.py --server.port 8888
|
| 369 |
```
|
| 370 |
|
| 371 |
+

|
| 372 |
|
| 373 |
**Gradio**
|
| 374 |
|
| 375 |
+
Thank [Pull Request](https://github.com/OpenMOSS/MOSS/pull/25) for providing a gradio-based web demo.
|
| 376 |
|
| 377 |
```bash
|
| 378 |
python moss_web_demo_gradio.py
|
|
|
|
| 388 |
|
| 389 |
You can chat with MOSS in the demo. Clear dialogue history by typing `clear` and stop the demo by typing `stop`.
|
| 390 |
|
| 391 |
+

|
| 392 |
|
| 393 |
## :fire: Fine-tuning MOSS
|
| 394 |
|
| 395 |
+
We also provided the Python code [finetune_moss.py](https://github.com/OpenMOSS/MOSS/blob/main/finetune_moss.py) for fine-tuning MOSS base model.
|
| 396 |
|
| 397 |
### Requirements
|
| 398 |
|
|
|
|
| 409 |
|
| 410 |
Here we show an example of fine-tuning `moss-moon-003-base` on conversational data without plugins. It would be straightforward to fine-tune it on plugin-augmented data.
|
| 411 |
|
| 412 |
+
Step 1, prepare your data following the format in [conversation_without_plugins](https://github.com/OpenMOSS/MOSS/tree/main/SFT_data/conversations/conversation_without_plugins) and put it in the folder `sft_data`.
|
| 413 |
|
| 414 |
+
Step 2, download the [accelerate configs](https://github.com/OpenMOSS/MOSS/tree/main/configs) to your machine and modify it according to your compute configuration. Learn more on [accelerate documentation](https://huggingface.co/docs/accelerate/usage_guides/deepspeed).
|
| 415 |
|
| 416 |
Step 3, create `run.sh` and copy the following snippet:
|
| 417 |
|
|
|
|
| 465 |
|
| 466 |
## :page_with_curl: License
|
| 467 |
|
| 468 |
+
The code in this repo is licensed by [Apache 2.0](https://github.com/OpenMOSS/MOSS/blob/main/LICENSE), the data on huggingface and this repo are licensed by [CC BY-NC 4.0](https://github.com/OpenMOSS/MOSS/blob/main/DATA_LICENSE), the model weights on huggingface are licensed by [GNU AGPL 3.0](https://github.com/OpenMOSS/MOSS/blob/main/MODEL_LICENSE). If you wish to use our models for commercial purpose or public serving, please sign [this form](https://github.com/OpenMOSS/MOSS/blob/main/MOSS_agreement_form.pdf) and send it to robot@fudan.edu.cn to get authorized. We only track the commercial use but charge nothing. The service provider shall be responsible for misleading or injurious statements and adverse effects caused by the use of the models contained in this repo and their modified versions.
|
| 469 |
|
| 470 |
## :heart: Acknowledgement
|
| 471 |
|