-
Notifications
You must be signed in to change notification settings - Fork 255
Open
Description
1.Describe the current behavior / 问题描述
我需要将DeepSeek-R1-Distill-Qwen-1.5B的akpt模型转成mindir模型。模型仓库地址是https://modelers.cn/models/MindSpore-Lab/DeepSeek-R1-Distill-Qwen-1.5B。
2.Environment / 环境信息
- Hardware Environment / 硬件环境:
后端类型 | 硬件具体类别 |
---|---|
CPU | Linux CPU |
- Software Environment / 软件环境:
Software | Version |
---|---|
MindSpore | MindSpore 2.5.0 |
Mindnlp | 0.4.0 |
Python | Python 3.10.16 |
OS platform | Ubuntu 24.04 |
GCC/Compiler version | 11.4.0 |
3.Steps to reproduce the issue / 重现步骤
下面是在CPU上的执行代码。我需要将akpt模型转成mindir模型。模型仓库地址是https://modelers.cn/models/MindSpore-Lab/DeepSeek-R1-Distill-Qwen-1.5B。
from mindnlp.transformers import AutoModelForCausalLM, AutoTokenizer
import mindspore as ms
model_name = 'DeepSeek-R1-Distill-Qwen-1.5B'
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "请介绍一下你自己"
inputs = tokenizer(prompt, return_tensors="ms")
outputs = model.generate(
input_ids=inputs["input_ids"],
attention_mask=inputs["attention_mask"],
max_length=512,
num_return_sequences=1)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print("Generated Response:", response)
在mindnlp文档中,我看到了一个接口mindnlp.engine.export。地址https://mindnlp.cqu.ai/zh/api/engine/export/
但是在使用的时候报错。发现该接口在源码中没有实现。
from mindnlp.transformers import AutoModelForCausalLM, AutoTokenizer
import mindspore as ms
model_name = 'DeepSeek-R1-Distill-Qwen-1.5B'
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "请介绍一下你自己"
inputs = tokenizer(prompt, return_tensors="ms")
mindnlp.engine.export(model,
inputs,
file_name="DeepSeek-R1-Distill-Qwen-1.5B",
file_format="MINDIR",
dynamic_axes={"input_ids": [0], "attention_mask": [0]})
报错:
<class 'mindnlp.transformers.models.qwen2.modeling_qwen2.Qwen2Model'>
Traceback (most recent call last):
File "/home/pikachu/Project/llm/to_mindir.py", line 15, in <module>
mindnlp.engine.export(model,
AttributeError: module 'mindnlp' has no attribute 'engine'
Metadata
Metadata
Assignees
Labels
No labels