SuperAPI AI Directory

MOSS

Fudan University's open-source conversational large model MOSS: code, weights, and research materials

Open website

About this tool

MOSS is an open-source conversational language model project from Fudan University that supports both Chinese and English as well as multiple plugins. The repository provides the MOSS-003 series models, dialogue data, and deployment and fine-tuning code.

Purpose

MOSS is designed for Chinese-English bilingual dialogue scenarios and supports multi-turn dialogue and tool invocation. The moss-moon series models have 16 billion parameters and can run on a single A100/A800 or two 3090 GPUs at FP16 precision, and on a single 3090 GPU at INT4/8 precision. The base language model was pretrained on approximately 700 billion Chinese and English words as well as code tokens, and was subsequently fine-tuned with conversational instructions, plugin-enhanced learning, and human preference training, giving it multi-turn dialogue capabilities and the ability to use multiple plugins.

Main Capabilities

The repository's open-source list includes models, data, and engineering solutions. On the model side: moss-moon-003-base is the base model, obtained through self-supervised pretraining on high-quality Chinese and English corpora. The pretraining corpus contains approximately 700B words, with a computational cost of approximately 6.67x10^22 floating-point operations; moss-moon-003-sft is fine-tuned on more than approximately 1.1 million multi-turn dialogue data and has instruction-following ability, multi-turn dialogue ability, and the ability to avoid harmful requests; moss-moon-003-sft-plugin additionally has the ability to use four plugins: a search engine, text-to-image, a calculator, and equation solving; there are also int4/int8 quantized versions, which require approximately 12GB/24GB of VRAM respectively for inference. moss-moon-003-pm, moss-moon-003, and moss-moon-003-plugin will be open-sourced in the near future.

On the data side: moss-002-sft-data covers the three dimensions of helpfulness, faithfulness, and harmlessness, and includes approximately 570,000 English dialogues and 590,000 Chinese dialogues generated by text-davinci-003; moss-003-sft-data is constructed based on approximately 100,000 user input data collected during the MOSS-002 internal testing phase and gpt-3.5-turbo, contains approximately 1.1 million dialogue data, and the complete dataset has all been open-sourced; moss-003-sft-plugin-data contains approximately 300,000 plugin-enhanced multi-turn dialogue data, and all data has been open-sourced; moss-003-pm-data will be open-sourced in the near future.

On the engineering solutions side: MOSS Vortex is the deployment and inference solution; MOSS WebSearchTool is a search engine plugin deployment solution; MOSS Frontend is the MOSS-003 frontend interface implemented based on Flutter; MOSS Backend is the MOSS-003 backend implemented based on Go.

Usage

Local deployment requires downloading the contents of this repository to a local/remote server. The torch and transformers versions are not recommended to be lower than the recommended versions. Currently, triton only supports Linux and WSL, and does not yet support Windows or Mac OS. The repository provides example code for calling moss-moon-003-sft to generate conversations, which can run on a single A100/A800 or CPU. When using FP16 precision, it occupies about 30GB of VRAM; inference can also be run on two NVIDIA 3090 GPUs. When VRAM is limited, the quantized version can be called, using the GPTQ algorithm and the OpenAI triton backend introduced in GPTQ-for-LLaMa (currently only supports Linux systems) to implement quantized inference. Currently, only single-GPU deployment of quantized models is supported.

When using the plugin version of MOSS, each round of conversation requires calling the model twice: the first generation goes to <eoc> to obtain the plugin call result and write it into "Results", and the second generation goes to <eom> to obtain the MOSS reply. The enabling status of each plugin is controlled through meta instructions. By default, all plugins are disabled. To enable a plugin, you need to change the corresponding plugin to enabled and provide the interface format.

The repository provides a Streamlit-based web Demo (moss_web_demo_streamlit.py), which by default uses moss-moon-003-sft-int4 on a single GPU, and can also specify other models and multi-GPU parallelism through parameters; there is also a Gradio-based web Demo (moss_web_demo_gradio.py), an API service (moss_api_demo.py), and a command-line Demo (moss_cli_demo.py; enter clear to clear the conversation history, and enter stop to terminate the Demo). In addition, it also provides a MOSS model supported by Jittor (moss_cli_demo_jittor.py). Jittor can greatly reduce VRAM consumption through memory swapping when VRAM is insufficient.In terms of fine-tuning, the repository provides fine-tuning code finetune_moss.py for SFT training based on the MOSS base model. The dataset needs to be processed in the conversation_without_plugins format and placed in the sft_data directory, the configs folder needs to be downloaded locally, and a run.sh file needs to be created. Multi-node running requires running once on each machine, and the machine_rank of each machine must be correctly specified. Note that the eos token in the tokenizer of the moss-moon-003-base model is <|endoftext|>. When training the SFT model, this token needs to be specified as the <eom> token.

If local deployment conditions are not available, you can contact us to obtain the inference service IP address and a dedicated API KEY. Currently, the API service is only open to enterprises, and authorization requires signing a document and filling out a questionnaire.

Applicable Scenarios

MOSS is suitable for Chinese-English bilingual multi-turn conversations, tasks that require calling tools such as search engines/text-to-image/calculators/equation solvers, and research and engineering scenarios involving fine-tuning, deployment, and secondary development based on its open-source models and data.

Limitations

Due to the relatively small number of model parameters and the autoregressive generation paradigm, MOSS may still generate misleading replies containing factual errors or harmful content containing bias/discrimination. Please carefully identify and use content generated by MOSS, and do not spread harmful content generated by MOSS to the Internet. Quantized models temporarily do not support model parallelism. Currently, triton only supports Linux and WSL, and does not yet support Windows or Mac OS. The API service is currently only open to enterprises.

Open Source License

The code contained in this project uses the Apache 2.0 license, the data uses the CC BY-NC 4.0 license, and the model weights use the GNU AGPL 3.0 license. If you need to use the models contained in this project for commercial purposes or public deployment, please sign a document and fill out a questionnaire to obtain authorization. The commercial use situation is only for record-keeping and no fees will be charged.