license: apache-2.0
base_model:
- Qwen/Qwen2.5-7B-Instruct
base_model_relation: quantized
pipeline_tag: text2text-generation
language:
- 中文
- 英文
- 法语
- 西班牙语
- 葡萄牙语
- 德语
- 意大利语
- 俄语
- 日语
- 韩语
- 越南语
- 泰语
- 阿拉伯语
弹性模型:Qwen2.5-7B-Instruct。自托管场景下最快最灵活的模型
弹性模型是由TheStage AI ANNA(自动化神经网络加速器)生成的模型系列。通过简单滑动控制条,您可自由调节模型规模、延迟与质量。针对每个基础模型,ANNA会生成以下优化版本:
- XL版:数学等效的神经网络,经DNN编译器优化
- L版:近无损模型,基准测试性能衰减<1%
- M版:加速模型,精度损失<1.5%
- S版:极速模型,精度损失<2%
弹性模型核心目标:
- 为推理任务提供成本与质量的灵活选择
- 提供透明的质量与延迟基准数据
- 单行代码即可调用HF生态库(transformers/diffusers)
- 支持多硬件平台,预编译无需即时编译
- 为自托管场景提供最佳模型与服务
注意:具体质量衰减程度因模型而异,例如S版也可能仅产生0.5%的性能衰减

推理部署
只需将标准transformers
导入替换为elastic_models.transformers
:
import torch
from transformers import AutoTokenizer
from elastic_models.transformers import AutoModelForCausalLM
model_name = "Qwen/Qwen2.5-7B-Instruct"
hf_token = ''
device = torch.device("cuda")
tokenizer = AutoTokenizer.from_pretrained(model_name, token=hf_token)
model = AutoModelForCausalLM.from_pretrained(
model_name,
token=hf_token,
torch_dtype=torch.bfloat16,
attn_implementation="sdpa",
mode='S'
).to(device)
model.generation_config.pad_token_id = tokenizer.eos_token_id
prompt = "解释DNN量化的基本原理。"
messages = [
{"role": "system", "content": "你是一个搜索引擎,请回答用户提问。"},
{"role": "user", "content": prompt}
]
chat_prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
inputs = tokenizer(chat_prompt, return_tensors="pt").to(device)
with torch.inference_mode():
generate_ids = model.generate(**inputs, max_length=500)
output = tokenizer.batch_decode(
generate_ids[:, inputs['input_ids'].shape[1]:],
skip_special_tokens=True,
clean_up_tokenization_spaces=False
)[0]
print(f"# 问题:\n{prompt}\n# 回答:\n{output}")
系统要求:
- GPU:H100/L40s
- CPU:AMD/Intel
- Python:3.10-3.12
通过终端执行以下命令完成环境配置:
pip install thestage
pip install elastic_models[nvidia]\
--index-url https://thestage.jfrog.io/artifactory/api/pypi/pypi-thestage-ai-production/simple\
--extra-index-url https://pypi.nvidia.com\
--extra-index-url https://pypi.org/simple
pip install flash_attn==2.7.3 --no-build-isolation
pip uninstall apex
登录app.thestage.ai获取API令牌后配置:
thestage config set --api-token <您的API令牌>
恭喜!现在您可以使用加速模型了。
基准测试
我们致力于提供清晰的模型加速性能指标。W8A8, int8
列表示我们对所有线性层应用W8A8量化(int8数据类型),使用与ANNA相同的校准数据。S版模型在保持相近速度的同时,通过敏感层量化优化实现了更高质量!
质量基准
指标/模型 |
S |
M |
L |
XL |
原始模型 |
W8A8量化 |
arc_challenge |
49.10 |
50.10 |
53.20 |
52.60 |
52.60 |
41.70 |
mmlu |
71.70 |
73.00 |
74.10 |
73.50 |
73.50 |
64.60 |
piqa |
77.00 |
78.20 |
78.80 |
79.50 |
79.50 |
67.10 |
winogrande |
66.20 |
69.10 |
71.50 |
70.60 |
70.60 |
53.10 |
- MMLU:评估57个学科(含理工/人文等)的综合知识能力
- PIQA:通过日常物理交互问题评估常识推理能力
- Arc挑战赛:测试需要推理的小学级选择题解决能力
- Winogrande:通过语句补全任务评估上下文理解与歧义消除能力
延迟基准
100输入/300输出(token/秒):
GPU/模型 |
S |
M |
L |
XL |
原始模型 |
W8A8量化 |
H100 |
201 |
173 |
162 |
135 |
62 |
201 |
L40S |
76 |
67 |
61 |
47 |
43 |
78 |
相关链接