【大模型】 大模型 Qwen/Qwen2.5-7B-Instruct

Qwen2.5-7B-Instruct 模型介绍

就 Qwen2.5 语言模型而言,所有模型都在我们最新的大规模数据集上进行了预训练,该数据集包含多达 18T tokens。相较于 Qwen2,Qwen2.5 获得了显著更多的知识(MMLU:85+),并在编程能力(HumanEval 85+)和数学能力(MATH 80+)方面有了大幅提升。此外,新模型在指令执行、生成长文本(超过 8K 标记)、理解结构化数据(例如表格)以及生成结构化输出特别是 JSON 方面取得了显著改进。 Qwen2.5 模型总体上对各种system prompt更具适应性,增强了角色扮演实现和聊天机器人的条件设置功能。与 Qwen2 类似,Qwen2.5 语言模型支持高达 128K tokens,并能生成最多 8K tokens的内容。它们同样保持了对包括中文、英文、法文、西班牙文、葡萄牙文、德文、意大利文、俄文、日文、韩文、越南文、泰文、阿拉伯文等 29 种以上语言的支持。 我们在下表中提供了有关模型的基本信息。

Qwen2.5-7B-Instruct 模型特征:

  • Type: Causal Language Models
  • Training Stage: Pretraining & Post-training
  • Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
  • Number of Parameters: 7.61B
  • Number of Paramaters (Non-Embedding): 6.53B
  • Number of Layers: 28
  • Number of Attention Heads (GQA): 28 for Q and 4 for KV
  • Context Length: Full 131,072 tokens and generation 8192 tokens

发布时间

2024年9月份

模型测评

  • Qwen2.5-7B 表现:

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

  • Qwen2.5-7B-Instruct 表现:
    在这里插入图片描述

在这里插入图片描述

Qwen2.5-7B-Instruct 在除了 IFeval 的所有任务中表现均优于竞争对手 Gemma2-9b-IT 和 Llama3.1-8B-Instruct,尤其是在数学(MATH: 75.5)和代码(HumanEval: 84.8)任务上优势明显。

推理性能

在这里插入图片描述

在这里插入图片描述

运行环境安装

pip install transformers==4.45.2

运行模型

  • with transformers:
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "Qwen/Qwen2.5-7B-Instruct"

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 model."
messages = [
    {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
    {"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]

下载

model_id: Qwen/Qwen2.5-7B-Instruct
下载地址:https://hf-mirror.com/Qwen/Qwen2-VL-2B-Instruct 不需要翻墙

开源协议

License: apache-2.0

参考

### Qwen-2.5-7B Instruct Novel LoRA Model Information and Usage The Qwen-2.5-7B Instruct novel LoRA (Low-Rank Adaptation) model represents an advanced approach to fine-tuning large language models efficiently while maintaining performance on specific tasks or domains[^1]. This particular instantiation, the Qwen-2.5-7B variant, leverages a base architecture with approximately 7 billion parameters designed for instruction-2.5-7B Instruct Novel LoRA LoRA focuses on adapting only a small number of low-rank matrices within pre-trained layers rather than updating all weights during training. For this version: - **Parameter Efficiency**: By modifying fewer parameters compared to full fine-tuning methods. - **Performance Preservation**: Ensures that task-specific adaptations do not degrade overall model quality significantly. - **Customization Flexibility**: Allows users to tailor the model towards specialized applications like generating creative narratives when using `Instruct` configurations. #### Implementation Example Using Hugging Face Transformers Library To utilize the Qwen-2.5-7B Instruct novel LoRA model effectively, one can employ Python libraries such as Hugging Face's transformers package. Below is a simplified code snippet demonstrating how to load and apply this model configuration: ```python from transformers import AutoModelForCausalLM, AutoTokenizer model_name = "Qwen/Qwen-2.5-7B-Instruct-novel-lora" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained(model_name) input_text = "Once upon a time," inputs = tokenizer(input_text, return_tensors="pt") outputs = model.generate(**inputs, max_length=50, num_return_sequences=1) generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True) print(generated_text) ``` This script initializes both the tokenizer and causal language modeling components from the specified pretrained checkpoint before processing input text through generation functions provided by the library. --related questions-- 1. What are some best practices for optimizing inference speed with LoRA adapted models? 2. How does parameter efficiency impact the generalizability of LoRA-based modifications across different datasets? 3. Can you provide examples where customizing a LoRA setup has led to significant improvements over standard fine-tuned approaches? 4. Are there any limitations associated specifically with applying LoRA techniques to very large-scale transformer architectures?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

szZack

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值