🤗 Hugging Face | 🤖 ModelScope
Ling is a MoE LLM provided and open-sourced by InclusionAI. We introduce two different sizes, which are Ling-Lite and Ling-Plus. Ling-Lite has 16.8 billion parameters with 2.75 billion activated parameters, while Ling-Plus has 290 billion parameters with 28.8 billion activated parameters. Both models demonstrate impressive performance compared to existing models in the industry.
Their structure makes it easy to scale up and down and adapt to different tasks, so users can use these models for a wide range of tasks, from processing natural language to solving complex problems. Furthermore, the open-source nature of Ling promotes collaboration and innovation within the AI community, fostering a diverse range of use cases and enhancements.
As more developers and researchers engage with the platform, we can expect rapid advancements and improvements, leading to even more sophisticated applications. This collaborative approach accelerates development and ensures that the models remain at the forefront of technology, addressing emerging challenges in various fields.
You can download the following table to see the various parameters for your use case. If you are located in mainland China, we also provide the model on Modulescope.cn to speed up the download process.
Model | #Total Params | #Activated Params | Context Length | Download |
---|---|---|---|---|
Ling-lite-base | 16.8B | 2.75B | 64K | 🤗 HuggingFace 🤖 ModelScope |
Ling-lite | 16.8B | 2.75B | 64K | 🤗 HuggingFace 🤖 ModelScope |
Ling-plus-base | 290B | 28.8B | 64K | 🤗 HuggingFace 🤖 ModelScope |
Ling-plus | 290B | 28.8B | 64K | 🤗 HuggingFace 🤖 ModelScope |
Detailed evaluation results are reported in our technical report [TBD].
Here is a code snippet to show you how to use the chat model with transformers
:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "inclusionAI/Ling-lite"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "Give me a short introduction to large language models."
messages = [
{"role": "system", "content": "You are Ling, an assistant created by inclusionAI"},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
If you're in mainland China, we strongly recommend you to use our model from 🤖 ModelScope.
vllm supports offline batched inference or launching an OpenAI-Compatible API Service for online inference.
Since the Pull Request (PR) has not been submitted to the vLLM community at this stage, please prepare the environment by following the steps below:
git clone -b v0.7.3 https://github.com/vllm-project/vllm.git
cd vllm
git apply Ling/inference/vllm/bailing_moe.patch
pip install -e .
from transformers import AutoTokenizer
from vllm import LLM, SamplingParams
tokenizer = AutoTokenizer.from_pretrained("inclusionAI/Ling-lite")
sampling_params = SamplingParams(temperature=0.7, top_p=0.8, repetition_penalty=1.05, max_tokens=512)
llm = LLM(model="inclusionAI/Ling-lite",
prompt = "Give me a short introduction to large language models."
messages = [
{"role": "system", "content": "You are Ling, an assistant created by inclusionAI"},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
outputs = llm.generate([text], sampling_params)
VLLM_USE_V1=1 vllm serve inclusionAI/Ling-lite \
--tensor-parallel-size 2 \
--pipeline-parrallel-size 1 \
--use-v2-block-manager \
--gpu-memory-utilization 0.90
For detailed guidance, please refer to the vLLM instructions
.
We recommend you to use Llama-Factory to finetune Ling with SFT, DPO, etc.
We use identity
to demonstrate how to finetune our Ling models by replacing name
with Ling
and author
with inclusionAI
.
{
"instruction": "hi",
"input": "",
"output": "Hello! I am Ling, an AI assistant developed by inclusionAI. How can I assist you today?"
}
We provide a demo configuration of Llama-Factory
to SFT Ling models as follows:
llamafactory-cli train examples/sft/ling_full_sft.yaml
This code repository is licensed under the MIT License.
[TBD]