Views
No views yet
| Size | Model | BF16 | Int4 |
|---|---|---|---|
| 7B | 360Zhinao-7B-Base | 🤖 🤗 | |
| 7B | 360Zhinao-7B-Chat-4K | 🤖 🤗 | 🤖 🤗 |
| 7B | 360Zhinao-7B-Chat-32K | 🤖 🤗 | 🤖 🤗 |
| 7B | 360Zhinao-7B-Chat-360K | 🤖 🤗 | 🤖 🤗 |
Model | AVG | CEval | AGIEval | MMLU | CMMLU | HellaSwag | MATH | GSM8K | HumanEval | MBPP | BBH | LAMBADA |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Baichuan2-7B | 41.49 | 56.3 | 34.6 | 54.7 | 57 | 67 | 5.4 | 24.6 | 17.7 | 24 | 41.8 | 73.3 |
| Baichuan-7B | 31.94 | 44.7 | 24.6 | 41.5 | 44.6 | 68.4 | 2.5 | 9.6 | 9.1 | 6.4 | 32.8 | 67.1 |
| ChatGLM3-6B | 58.67 | 67 | 47.4 | 62.8 | 66.5 | 76.5 | 19.2 | 61 | 44.5 | 57.2 | 66.2 | 77.1 |
| DeepSeek-7B | 39.8 | 45 | 24 | 49.3 | 46.8 | 73.4 | 4.2 | 18.3 | 25 | 36.4 | 42.8 | 72.6 |
| InternLM2-7B | 58.01 | 65.7 | 50.2 | 65.5 | 66.2 | 79.6 | 19.9 | 70.6 | 41.5 | 42.4 | 64.4 | 72.1 |
| InternLM-7B | 39.33 | 53.4 | 36.9 | 51 | 51.8 | 70.6 | 6.3 | 31.2 | 13.4 | 14 | 37 | 67 |
| LLaMA-2-7B | 33.27 | 32.5 | 21.8 | 46.8 | 31.8 | 74 | 3.3 | 16.7 | 12.8 | 14.8 | 38.2 | 73.3 |
| LLaMA-7B | 30.35 | 27.3 | 20.6 | 35.6 | 26.8 | 74.3 | 2.9 | 10 | 12.8 | 16.8 | 33.5 | 73.3 |
| Mistral-7B-v0.1 | 47.67 | 47.4 | 32.8 | 64.1 | 44.7 | 78.9 | 11.3 | 47.5 | 27.4 | 38.6 | 56.7 | 75 |
| MPT-7B | 30.06 | 23.5 | 21.3 | 27.5 | 25.9 | 75 | 2.9 | 9.1 | 17.1 | 22.8 | 35.6 | 70 |
| Qwen1.5-7B | 55.12 | 73.57 | 50.8 | 62.15 | 71.84 | 72.62 | 20.36 | 54.36 | 53.05 | 36.8 | 40.01 | 70.74 |
| Qwen-7B | 49.53 | 63.4 | 45.3 | 59.7 | 62.5 | 75 | 13.3 | 54.1 | 27.4 | 31.4 | 45.2 | 67.5 |
| XVERSE-7B | 34.27 | 61.1 | 39 | 58.4 | 60.8 | 73.7 | 2.2 | 11.7 | 4.9 | 10.2 | 31 | 24 |
| Yi-6B | 47.8 | 73 | 44.3 | 64 | 73.5 | 73.1 | 6.3 | 39.9 | 15.2 | 23.6 | 44.9 | 68 |
| 360Zhinao-7B | 56.15 | 74.11 | 49.49 | 67.44 | 72.38 | 83.05 | 16.38 | 53.83 | 35.98 | 42.4 | 43.95 | 78.59 |
| Model | Avg | Single-Doc QA | Multi-Doc QA | Summarization | Few-Shot Learning | Code Completion |
|---|---|---|---|---|---|---|
| GPT-3.5-Turbo-16k | 37.84 | 61.2 | 28.7 | 16 | 29.2 | 54.1 |
| ChatGLM2-6B-32k | 37.16 | 51.6 | 37.6 | 16.2 | 27.7 | 52.7 |
| ChatGLM3-6B-32k | 44.62 | 62.3 | 44.8 | 17.8 | 42 | 56.2 |
| InternLM2-Chat-7B | 42.20 | 56.65 | 29.15 | 17.99 | 43.5 | 63.72 |
| Qwen1.5-Chat-7B | 36.75 | 52.85 | 30.08 | 14.28 | 32 | 54.55 |
| Qwen1.5-Chat-14B | 39.80 | 60.39 | 27.99 | 14.77 | 37 | 58.87 |
| 360Zhinao-7B-Chat-32K | 45.18 | 57.18 | 48.06 | 15.03 | 44 | 61.64 |


pip install -r requirements.txt flash-attn >= 2.3.6
FLASH_ATTENTION_FORCE_BUILD=TRUE pip install flash-attn==2.3.61from transformers import AutoTokenizer, AutoModelForCausalLM
2from transformers.generation import GenerationConfig
3
4MODEL_NAME_OR_PATH = "qihoo360/360Zhinao-7B-Base"
5
6tokenizer = AutoTokenizer.from_pretrained(
7 MODEL_NAME_OR_PATH,
8 trust_remote_code=True)
9
10model = AutoModelForCausalLM.from_pretrained(
11 MODEL_NAME_OR_PATH,
12 device_map="auto",
13 trust_remote_code=True)
14
15generation_config = GenerationConfig.from_pretrained(
16 MODEL_NAME_OR_PATH,
17 trust_remote_code=True)
18
19inputs = tokenizer('中国二十四节气\n1. 立春\n2. 雨水\n3. 惊蛰\n4. 春分\n5. 清明\n', return_tensors='pt')
20inputs = inputs.to(model.device)
21
22pred = model.generate(input_ids=inputs["input_ids"], generation_config=generation_config)
23print("outputs:\n", tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))1from transformers import AutoTokenizer, AutoModelForCausalLM
2from transformers.generation import GenerationConfig
3
4MODEL_NAME_OR_PATH = "qihoo360/360Zhinao-7B-Chat-4K"
5
6tokenizer = AutoTokenizer.from_pretrained(
7 MODEL_NAME_OR_PATH,
8 trust_remote_code=True)
9
10model = AutoModelForCausalLM.from_pretrained(
11 MODEL_NAME_OR_PATH,
12 device_map="auto",
13 trust_remote_code=True)
14
15generation_config = GenerationConfig.from_pretrained(
16 MODEL_NAME_OR_PATH,
17 trust_remote_code=True)
18
19messages = []
20#round-1
21messages.append({"role": "user", "content": "介绍一下刘德华"})
22response = model.chat(tokenizer=tokenizer, messages=messages, generation_config=generation_config)
23messages.append({"role": "assistant", "content": response})
24print(messages)
25
26#round-2
27messages.append({"role": "user", "content": "他有什么代表作?"})
28response = model.chat(tokenizer=tokenizer, messages=messages, generation_config=generation_config)
29messages.append({"role": "assistant", "content": response})
30print(messages)1from modelscope import AutoModelForCausalLM, AutoTokenizer
2from modelscope import GenerationConfig
3
4MODEL_NAME_OR_PATH = "qihoo360/360Zhinao-7B-Base"
5
6tokenizer = AutoTokenizer.from_pretrained(
7 MODEL_NAME_OR_PATH,
8 trust_remote_code=True)
9
10model = AutoModelForCausalLM.from_pretrained(
11 MODEL_NAME_OR_PATH,
12 device_map="auto",
13 trust_remote_code=True)
14
15generation_config = GenerationConfig.from_pretrained(
16 MODEL_NAME_OR_PATH,
17 trust_remote_code=True)
18
19inputs = tokenizer('中国二十四节气\n1. 立春\n2. 雨水\n3. 惊蛰\n4. 春分\n5. 清明\n', return_tensors='pt')
20inputs = inputs.to(model.device)
21
22pred = model.generate(input_ids=inputs["input_ids"], generation_config=generation_config)
23print("outputs:\n", tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))1from modelscope import AutoModelForCausalLM, AutoTokenizer
2from modelscope import GenerationConfig
3
4MODEL_NAME_OR_PATH = "qihoo360/360Zhinao-7B-Chat-4K"
5
6tokenizer = AutoTokenizer.from_pretrained(
7 MODEL_NAME_OR_PATH,
8 trust_remote_code=True)
9
10model = AutoModelForCausalLM.from_pretrained(
11 MODEL_NAME_OR_PATH,
12 device_map="auto",
13 trust_remote_code=True)
14
15generation_config = GenerationConfig.from_pretrained(
16 MODEL_NAME_OR_PATH,
17 trust_remote_code=True)
18
19messages = []
20#round-1
21messages.append({"role": "user", "content": "介绍一下刘德华"})
22response = model.chat(tokenizer=tokenizer, messages=messages, generation_config=generation_config)
23messages.append({"role": "assistant", "content": response})
24print(messages)
25
26#round-2
27messages.append({"role": "user", "content": "他有什么代表作?"})
28response = model.chat(tokenizer=tokenizer, messages=messages, generation_config=generation_config)
29messages.append({"role": "assistant", "content": response})
30print(messages)python cli_demo.py
streamlit run web_demo.py
python openai_api.py1curl 'http://localhost:8360/v1/chat/completions' \
2-H 'Content-Type: application/json' \
3-d '{
4 "max_new_tokens": 200,
5 "do_sample": true,
6 "top_k": 0,
7 "top_p": 0.8,
8 "temperature": 1.0,
9 "repetition_penalty": 1.0,
10 "messages": [
11 {"role": "system", "content": "You are a helpful assistant."},
12 {"role": "user", "content": "你好"}
13 ]
14}'vLLM==0.3.3.pip install vllm==0.3.3vllm/zhinao.py into vllm/model_executor/models in your vllm installation directory (in python/conda env).vllm/serving_chat.py into vllm/entrypoints/openai in your vllm installation directory.vllm/model_executor/models/__init__.py"ZhinaoForCausalLM": ("zhinao", "ZhinaoForCausalLM"),1python -m vllm.entrypoints.openai.api_server \
2 --served-model-name 360Zhinao-7B-Chat-4K \
3 --model qihoo360/360Zhinao-7B-Chat-4K \
4 --trust-remote-code \
5 --tensor-parallel-size 1 \
6 --max-model-len 4096 \
7 --host 0.0.0.0 \
8 --port 83601curl http://localhost:8360/v1/chat/completions \
2-H "Content-Type: application/json" \
3-d '{
4 "model": "360Zhinao-7B-Chat-4K",
5 "max_tokens": 200,
6 "top_k": -1,
7 "top_p": 0.8,
8 "temperature": 1.0,
9 "presence_penalty": 0.0,
10 "frequency_penalty": 0.0,
11 "messages": [
12 {"role": "system", "content": "You are a helpful assistant."},
13 {"role": "user", "content": "你好"}
14 ],
15 "stop": [
16 "<eod>",
17 "<|im_end|>",
18 "<|im_start|>"
19 ]
20}'1from openai import OpenAI
2openai_api_key = "EMPTY"
3openai_api_base = "http://localhost:8360/v1"
4
5client = OpenAI(
6 api_key=openai_api_key,
7 base_url=openai_api_base,
8)
9
10chat_response = client.chat.completions.create(
11 model="360Zhinao-7B-Chat-4K",
12 messages=[
13 {"role": "system", "content": "You are a helpful assistant."},
14 {"role": "user", "content": "你好"},
15 ],
16 stop=[
17 "<eod>",
18 "<|im_end|>",
19 "<|im_start|>"
20 ],
21 presence_penalty=0.0,
22 frequency_penalty=0.0
23)
24print("Chat response:", chat_response)If you need to enable repetition penalty, we recommend settingpresence_penaltyandfrequency_penaltyinstead ofrepetition_penalty.
data/training_data_sample.json. This example data has 10,000 rows sampled from multiturn_chat_0.8M with converted format.1[
2 {
3 "id": 1,
4 "conversations": [
5 {
6 "from": "system",
7 "value": "You are a helpful assistant."
8 },
9 {
10 "from": "user",
11 "value": "您好啊"
12 },
13 {
14 "from": "assistant",
15 "value": "你好!我今天能为您做些什么?有什么问题或需要帮助吗? 我在这里为您提供服务。"
16 }
17 ]
18 }
19]1set -x
2
3HOSTFILE=hostfile
4DS_CONFIG=./finetune/ds_config_zero2.json
5
6# PARAMS
7LR=5e-6
8EPOCHS=3
9MAX_LEN=4096
10BATCH_SIZE=4
11NUM_NODES=1
12NUM_GPUS=8
13MASTER_PORT=29500
14
15IS_CONCAT=False # Whether to concatenate to maximum length (MAX_LEN)
16
17DATA_PATH="./data/training_data_sample.json"
18MODEL_PATH="qihoo360/360Zhinao-7B-Base"
19OUTPUT_DIR="./outputs/"
20
21deepspeed --hostfile ${HOSTFILE} \
22 --master_port ${MASTER_PORT} \
23 --num_nodes ${NUM_NODES} \
24 --num_gpus ${NUM_GPUS} \
25 finetune.py \
26 --report_to "tensorboard" \
27 --data_path ${DATA_PATH} \
28 --model_name_or_path ${MODEL_PATH} \
29 --output_dir ${OUTPUT_DIR} \
30 --model_max_length ${MAX_LEN} \
31 --num_train_epochs ${EPOCHS} \
32 --per_device_train_batch_size ${BATCH_SIZE} \
33 --gradient_accumulation_steps 1 \
34 --save_strategy steps \
35 --save_steps 200 \
36 --learning_rate ${LR} \
37 --lr_scheduler_type cosine \
38 --adam_beta1 0.9 \
39 --adam_beta2 0.95 \
40 --adam_epsilon 1e-8 \
41 --max_grad_norm 1.0 \
42 --weight_decay 0.1 \
43 --warmup_ratio 0.01 \
44 --gradient_checkpointing True \
45 --bf16 True \
46 --tf32 True \
47 --deepspeed ${DS_CONFIG} \
48 --is_concat ${IS_CONCAT} \
49 --logging_steps 1 \
50 --log_on_each_node Falsebash finetune/ds_finetune.shHOSTFILE switches between single-machine and multi-machine training.ds_config switches between zero1, zero2 and zero3.fp16, bf16 could configure mixed precision training. bf16 is recommended to be consistent with the pretrained model.is_concat configures whether the training data is concatenated or not.