Instructions to use yulan-team/YuLan-Chat-2-13b-fp16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yulan-team/YuLan-Chat-2-13b-fp16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yulan-team/YuLan-Chat-2-13b-fp16")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yulan-team/YuLan-Chat-2-13b-fp16") model = AutoModelForCausalLM.from_pretrained("yulan-team/YuLan-Chat-2-13b-fp16") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use yulan-team/YuLan-Chat-2-13b-fp16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yulan-team/YuLan-Chat-2-13b-fp16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yulan-team/YuLan-Chat-2-13b-fp16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/yulan-team/YuLan-Chat-2-13b-fp16
- SGLang
How to use yulan-team/YuLan-Chat-2-13b-fp16 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 "yulan-team/YuLan-Chat-2-13b-fp16" \ --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": "yulan-team/YuLan-Chat-2-13b-fp16", "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 "yulan-team/YuLan-Chat-2-13b-fp16" \ --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": "yulan-team/YuLan-Chat-2-13b-fp16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use yulan-team/YuLan-Chat-2-13b-fp16 with Docker Model Runner:
docker model run hf.co/yulan-team/YuLan-Chat-2-13b-fp16
YuLan-Chat: An Open-Source Bilingual Chatbot
- Due to continued pre-training on high-quality Chinese-English bilingual data, the language ability of the model has been improved.
- To well support Chinese and longer inputs and outputs, we expand the original vocabulary with Chinese words and extend the maximum length of LLaMA-2. It can support 8k context now.
- To well activate the bilingual instruction following capacity, we construct high-quality bilingual instructions, and perform multi-stage instruction-tuning.
YuLan-Chat็ณปๅๆจกๅๆฏไธญๅฝไบบๆฐๅคงๅญฆ้ซ็ดไบบๅทฅๆบ่ฝๅญฆ้ขๅธ็ๅ ฑๅๅผๅ็ๆฏๆ่ๅคฉ็ๅคง่ฏญ่จๆจกๅ๏ผๅๅญ"็ๅ ฐ"ๅ่ชไธญๅฝไบบๆฐๅคงๅญฆๆ ก่ฑ๏ผใๆๆฐ็ๆฌๅบไบLLaMA-2่ฟ่กไบไธญ่ฑๆๅ่ฏญ็็ปง็ปญ้ข่ฎญ็ปๅๆไปคๅพฎ่ฐใ่ฏฅ็ๆจกๅๅ ทๆๅฆไธๆๆฏ็น็น๏ผ
- ็ฑไบๅจ้ซ่ดจ้ไธญ่ฑๅ่ฏญๆฐๆฎไธ่ฟ่กไบ็ปง็ปญ้ข่ฎญ็ป๏ผๆจกๅ็่ฏญ่จ่ฝๅๅพๅฐๆ้ซ๏ผ
- ไธบไบๆดๅฅฝ็ๆฏๆไธญๆๅๆด้ฟ็่พๅ ฅ่พๅบ๏ผๅฏนๅ็LLaMA-2็่ฏ่กจๅ้ฟๅบฆ่ฟ่กไบๆฉๅ ๏ผ็ฎๅๅฏๆฏๆ8kไธไธๆ๏ผ
- ไธบไบ่ฎฉๆจกๅๆดๅฅฝๅฐๆไป็จๆทๆไปค๏ผๆๅปบไบ้ซ่ดจ้ๅ่ฏญๆไปคๆฐๆฎ้๏ผๅนถ่กไบๅค้ถๆฎตๆไปคๅพฎ่ฐใ
Model Zoo
Due to the license limitation, for models based on LLaMA, we only provide the weight difference with the original checkpoints; for models based on LLaMA-2, they can be used directly. Please check the Usage section for more details.
Limitations: Despite our efforts to reduce potential security issues during the model's usage and encourage the generation of text that aligns with ethical and legal requirements, the language model is based on probabilistic generation, which means it may still produce unexpected outputs. For instance, the generated responses may contain biases, discrimination, or other harmful content. Please do not propagate such content. We do not assume any responsibility for any consequences resulting from the dissemination of harmful information.
็ฑไบ่ฎธๅฏ่ฏ็้ๅถ๏ผๅบไบLLaMA็ๆจกๅๆไปฌไป ๆไพไธๅฎๆนๆจกๅ็ๅทฎๅผ๏ผๅบไบLLaMA-2็ๆจกๅๅฏ็ดๆฅไฝฟ็จ๏ผๅ ทไฝ่ฏทๅ่งไฝฟ็จๆนๆณ็ซ ่ใ
ๅฑ้ๆง๏ผๅฐฝ็ฎกๆไปฌๅฐ่ฏๅๅฐๆจกๅๅจไฝฟ็จไธญๅฏ่ฝๅบ็ฐ็ๅฎๅ จๆง้ฎ้ข๏ผๅนถ้ผๅฑๆจกๅ็ๆ็ฌฆๅ้ๅพทๅๆณๅพ่ฆๆฑ็ๆๆฌ๏ผไฝ็ฑไบ่ฏญ่จๆจกๅๅบไบๆฆ็็ๆ็่ๅผ๏ผๆจกๅไป็ถๅฏ่ฝไผไบง็ๆๅค็่พๅบใ ไพๅฆ๏ผ็ๆ็ๅๅบๅฏ่ฝๅ ๅซๅ่งใๆญง่งๆๅ ถไปๆๅฎณๅ ๅฎนใ ่ฏทไธ่ฆไผ ๆญๆญค็ฑปๅ ๅฎนใ ๆไปฌๅฏนๅ ไผ ๆญๆๅฎณไฟกๆฏ่้ ๆ็ไปปไฝๅๆไธๆฟๆ ไปปไฝ่ดฃไปปใ
| Model | Backbone | Extended Vocab | Extended Length | Continue PT | SFT | Released Date |
|---|---|---|---|---|---|---|
| YuLan-Chat-2-13B | LLaMA2-13B | โ 51,190 | โ 8,192 | โ | โ | 2023.8.2 |
| YuLan-LLaMA-2-13B | LLaMA2-13B | โ 51,190 | โ 8,192 | โ | โ | 2023.8.2 |
| YuLan-Chat-1-65B-v2 | LLaMA-65B | โ 51,190 | โ 2,048 | โ | โ | 2023.8.2 |
| YuLan-Chat-1-13B-v1 | LLaMA-13B | โ 32,000 | โ 2,048 | โ | โ | 2023.6.8 |
| YuLan-Chat-1-65B-v1 | LLaMA-65B | โ 32,000 | โ 2,048 | โ | โ | 2023.6.8 |
Evaluation
We evaluate our YuLan-Chat model on several Chinese and English benchmarks. The evaluation results are shown as follows.
ๆไปฌๅจไธญ่ฑๆ็ไธไบๅบๅๆต่ฏไธๅฏนYuLan-Chat่ฟ่กไบ่ฏไปท๏ผๅ ถ็ปๆๅฆไธใ
MMLU
MMLU (Massive Multitask Language Understanding) is a benchmark designed to measure knowledge acquired during pretraining by evaluating models exclusively in zero-shot and few-shot settings.
MMLUๆฏไธไธช่ฏไผฐๆจกๅ็ฅ่ฏ้็ๅธธ็จ็่ฑๆๅบๅๆต่ฏ้ใ
| Model | STEM | Social Science | Humanities | Others | Avg. |
|---|---|---|---|---|---|
| YuLan-Chat-1-13B-v1 | 39.6 | 57.8 | 42.6 | 57.6 | 49.4 |
| YuLan-Chat-1-65B-v1 | 49.2 | 71.7 | 57.7 | 66.7 | 61.3 |
| YuLan-Chat-1-65B-v2 | 46.3 | 67.9 | 56.9 | 63.9 | 58.7 |
| LLaMA-2-13B | 44.6 | 64.2 | 53.9 | 62.2 | 56.2 |
| FlagAlpha/Llama2-Chinese-13b-Chat | 44.4 | 63.2 | 51.6 | 60.6 | 55.0 |
| Linly-AI/Chinese-LLaMA-2-13B-hf | 43.6 | 62.7 | 49.8 | 61.6 | 54.4 |
| YuLan-LLaMA-2-13B | 42.9 | 61.5 | 50.4 | 58.6 | 53.4 |
| YuLan-Chat-2-13B | 45.3 | 66.7 | 53.8 | 62.8 | 57.2 |
C-Eval
C-Eval is a comprehensive Chinese evaluation suite for foundation models.
C-Evalๆฏไธไธช้ๅฏนๅบ็ณๆจกๅ็ปผๅ่ฝๅ็ไธญๆๅบๅๆต่ฏ้ใ
| Model | STEM | Social Science | Humanities | Others | Avg. | Avg. (Hard) |
|---|---|---|---|---|---|---|
| YuLan-Chat-1-13B-v1 | 30.2 | 37.4 | 31.9 | 30.7 | 32.0 | 25.7 |
| YuLan-Chat-1-65B-v1 | 37.7 | 46.1 | 36.8 | 38.0 | 39.2 | 31.1 |
| YuLan-Chat-1-65B-v2 | 39.9 | 55.9 | 47.7 | 43.7 | 45.4 | 31.4 |
| LLaMA-2-13B | 36.9 | 43.2 | 37.6 | 36.6 | 38.2 | 32.0 |
| FlagAlpha/Llama2-Chinese-13b-Chat | 36.8 | 44.5 | 36.3 | 36.5 | 38.1 | 30.9 |
| Linly-AI/Chinese-LLaMA-2-13B-hf | 33.7 | 44.8 | 36.6 | 36.5 | 37 | 27.7 |
| YuLan-LLaMA-2-13B | 35.3 | 46.4 | 41.9 | 37.6 | 39.3 | 28.6 |
| YuLan-Chat-2-13B | 38.9 | 49.7 | 45.0 | 40.8 | 42.6 | 32.2 |
AGI-Eval-Gaokao
AGI-Eval is a human-centric benchmark specifically designed to evaluate the general abilities of foundation models in tasks pertinent to human cognition and problem-solving. We use the sub-branch Chinese-Gaokao for evaluation.
AGI-Eval ๆฏไธไธชไปฅไบบไธบไธญๅฟ็ๅบๅ๏ผไธ้จ่ฎพ่ฎก็จไบ่ฏไผฐๅบ็กๆจกๅๅจไธไบบ็ฑป่ฎค็ฅๅ่งฃๅณ้ฎ้ข็ธๅ ณ็ไปปๅกไธญ็ไธ่ฌ่ฝๅใๆไปฌไฝฟ็จๅ ถไธญ็"้ซ่"ๅๆฏ่ฟ่ก่ฏๆตใ
| Model | Avg. | Chinese | English | Geography | History | Biology | Chemistry | Physics | Math-QA | Math-Cloze |
|---|---|---|---|---|---|---|---|---|---|---|
| YuLan-Chat-1-13B-v1 | 24.3 | 22.4 | 60.1 | 27.6 | 25.5 | 21.9 | 30.0 | 8.0 | 21.1 | 1.7 |
| YuLan-Chat-1-65B-v1 | 29.3 | 25.2 | 79.1 | 37.2 | 36.6 | 28.6 | 24.2 | 11.0 | 21.9 | 0.0 |
| YuLan-Chat-1-65B-v2 | 37.9 | 31.4 | 80.4 | 50.8 | 56.6 | 33.3 | 29.0 | 32.0 | 24.4 | 0.8 |
| LLaMA-2-13B | 32.7 | 27.2 | 72.2 | 36.2 | 43.0 | 26.2 | 32.4 | 30.0 | 26.2 | 0.9 |
| FlagAlpha/Llama2-Chinese-13b-Chat | 31.6 | 26.4 | 70.6 | 35.2 | 38.7 | 28.1 | 28.0 | 29.5 | 25.6 | 2.5 |
| Linly-AI/Chinese-LLaMA-2-13B-hf | 31.1 | 22.8 | 74.8 | 42.2 | 37.9 | 24.3 | 28.0 | 23.0 | 26.5 | 0.0 |
| YuLan-LLaMA-2-13B | 34.2 | 25.2 | 70.3 | 43.2 | 48.5 | 30.0 | 29.5 | 31.0 | 28.5 | 1.7 |
| YuLan-Chat-2-13B | 39.5 | 37.0 | 85.3 | 46.7 | 51.9 | 43.8 | 38.2 | 29.0 | 23.1 | 0.9 |
Usage
Import from Huggingface Transformers
As our model is trained based on LLaMA, it can be loaded in the same way as original LLaMA.
็ฑไบๆไปฌ็ๆจกๅๆฏๅบไบLLaMAๅผๅ็๏ผๅฏไปฅไฝฟ็จไธLLaMA็ธๅ็ๆนๆณๅ ่ฝฝใ
>>> from transformers import LlamaTokenizer, LlamaForCausalLM
>>> tokenizer = LlamaTokenizer.from_pretrained("yulan-team/YuLan-Chat-2-13b")
>>> model = LlamaForCausalLM.from_pretrained("yulan-team/YuLan-Chat-2-13b").cuda()
>>> model = model.eval()
>>> input_text = "hello"
>>> prompt = "The following is a conversation between a human and an AI assistant namely YuLan, developed by GSAI, Renmin University of China. The AI assistant gives helpful, detailed, and polite answers to the user's questions.\n[|Human|]:{}\n[|AI|]:".format(input_text)
>>> inputs = tokenizer(prompt, return_tensors='pt', padding="longest", max_length=8192, truncation=True, return_attention_mask=True, add_special_tokens=True)
>>> kwargs = {'temperature': 0.8, 'top_p': 0.95, "top_k": 50, "repetition_penalty": 1.1, "no_repeat_ngram_size": 64, "max_length": 8192, "pad_token_id": tokenizer.bos_token_id, "eos_token_id": tokenizer.eos_token_id}
>>> outputs = model.generate(inputs['input_ids'].to(model.device), attention_mask=inputs['attention_mask'].to(model.device), do_sample=True, **kwargs)
>>> print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[len(prompt):])
Hello! How can I assist you today?
License
YuLan-Chat uses MIT License. All data and code in this project can only be used for academic purposes.
ๆฌ้กน็ฎไฝฟ็จMIT่ฎธๅฏ๏ผๆๆ็ๆฐๆฎๅไปฃ็ ไป ไพๅญฆๆฏ็ ็ฉถไฝฟ็จใ
Contributors
| Pre-training | Fine-tuning |
|---|---|
| Yutao Zhu (Lead), Kelong Mao, Wentong Chen, Yiding Sun, Yihan Wu, Qian Cao, Lei Zhang, Feng Wang, Qiangqiang Ren | Kun Zhou (Lead), Yushuo Chen, Zhipeng Chen, Lei Wang, Yupeng Hou, Xincheng Pang, Junyi Li, Yuhan Chen, Shufang Xie |
Reference
Please kindly cite our work if it helps you.
ๅฆๆๆไปฌ็้กน็ฎๅฏนๆจๆๅธฎๅฉ๏ผ่ฏทๅผ็จๆไปฌ๏ผ่ฐข่ฐข๏ผ
@misc{YuLan-Chat,
author = {YuLan-Team},
title = {YuLan-Chat: An Open-Source Bilingual Chatbot},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/RUC-GSAI/YuLan-Chat}},
}
- Downloads last month
- 949