Views
No views yet
| 位点序号 | 早退出位置 | 等效模型大小 | 对应分支代号 | 场景定位 |
|---|---|---|---|---|
| 1 | 2层 | 1.7B | AI-Flow-Ruyi2-1.7B | 端侧极速/简单任务 |
| 2 | 21层 | 8B | AI-Flow-Ruyi2-8B | 边缘计算/通用平衡 |
| 3 | 39层 | 14B | AI-Flow-Ruyi2-14B | 云端全能/复杂问题 |
| Model | MMLU | MMLU-P | CMMLU | BBH | ARC-c | Hella | IFEval | Human | Math | GSM8K | Avg. |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Qwen3-1.7B | 39.31 | 39.82 | 61.61 | 35.81 | 67.12 | 54.25 | 67.65 | 62.20 | 70.32 | 75.89 | 57.40 |
| Qwen3-8B | 48.64 | 55.63 | 78.84 | 55.11 | 82.03 | 77.32 | 81.89 | 87.20 | 82.30 | 85.37 | 73.43 |
| Qwen3-14B | 60.43 | 64.11 | 82.06 | 64.70 | 81.69 | 80.80 | 85.77 | 87.80 | 84.42 | 85.90 | 77.77 |
| Ruyi2-1.7B | 62.77 | 9.60 | 22.68 | 19.95 | 27.46 | 58.77 | 47.13 | 47.56 | 39.14 | 75.97 | 41.10 |
| Ruyi2-8B | 79.68 | 56.12 | 74.72 | 59.38 | 82.71 | 78.19 | 73.94 | 71.95 | 72.96 | 92.19 | 74.18 |
| Ruyi2-14B | 81.84 | 71.55 | 82.15 | 77.86 | 84.41 | 83.94 | 81.52 | 84.76 | 86.52 | 94.24 | 82.88 |
1conda create -n ruyi python=3.12
2conda activate ruyi1git clone https://github.com/TeleAI-AI-Flow/AI-Flow-Ruyi2.git
2cd AI-Flow-Ruyipip install -e .git clone https://huggingface.co/TeleAI-AI-Flow/AI-Flow-Ruyi2 models/AI-Flow-Ruyi2python demo.py1import torch
2from ruyi.global_var import set_global_val
3from transformers import GenerationConfig
4from transformers import AutoModelForCausalLM, AutoTokenizer
5
6
7model_path = f"models/AI-Flow-Ruyi2"
8tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
9model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, attn_implementation='flash_attention_2', torch_dtype=torch.bfloat16).to('cuda')
10
11
12generation_config = GenerationConfig(
13 do_sample=True,
14 top_k=30,
15 top_p=0.95,
16 temperature=0.6,
17 repetition_penalty=1.2,
18 no_repeat_ngram_size=3,
19 max_new_tokens=8192
20)
21
22# 输入文本
23messages = [
24 {"role": "user", "content": "你好,请用一句话介绍一下自己。"},
25]
26
27# 应用 chat_template 模板
28prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
29inputs = tokenizer(prompt, return_tensors="pt")
30
31# 模型生成
32with torch.no_grad():
33 # 设置早退出点
34 # - 2: 第一个早退出点,对应约1.7B
35 # - 21: 第二个早退出点,对应约8B
36 # - 39: 第三个早退出点,对应约14B
37 set_global_val("early_exit_point", 39)
38
39 output = model.generate(
40 inputs["input_ids"].to('cuda'),
41 generation_config=generation_config
42 )
43
44# 解码并打印结果
45generated_text = tokenizer.decode(output[0], skip_special_tokens=False)
46print(generated_text)