[Bug]: 在用Taskflow推理的时候,指定本地模型路径没生效
软件环境
- paddlepaddle:3.0
- paddlepaddle-gpu: 3.0
- paddlenlp: latest
-windows环境
重复问题
- [x] I have searched the existing issues
错误描述
在用Taskflow推理的时候,指定本地模型路径没生效,设置过task_path,model_path都没生效,都要去联网下载,也试过将联网下载的模型转移到其他指定的目录,一直不生效指定的模型路径
稳定复现步骤 & 代码
from pprint import pprint from paddlenlp import Taskflow
schema = ['时间', '选手', '赛事名称'] # Define the schema for entity extraction ie = Taskflow(task='information_extraction', task_path='G:/models/paddlenlp/PP-UIE-0.5B', schema= ['时间', '选手', '赛事名称'], schema_lang="zh", batch_size=1, # model='paddlenlp/PP-UIE-0.5B', precision='float16', device_map='auto',
)
pprint(ie("2月8日上午北京冬奥会自由式滑雪女子大跳台决赛中中国选手谷爱凌以188.25分获得金牌!")) # Better print results using pprint
输出
[{'时间': [{'text': '2月8日上午'}], '赛事名称': [{'text': '北京冬奥会自由式滑雪女子大跳台决赛'}], '选手': [{'text': '谷爱凌'}]}]
还有个问题,即使已经缓存了,每次还要去下载一个json[2025-05-27 16:15:14,480] [ INFO] - Loading weights file from cache at C:\Users\Administrator\.paddlenlp\models\paddlenlp/PP-UIE-0.5B\model.safetensors.index.json Downloading shards: 100%|███████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<?, ?it/s]
使用绝对路径是无效的,你可以查看报错的代码,他会直接把绝对路径加在一个前缀字符串(假设xxx/)下,联网搜索xxx/abc模型,我的解决办法是确定好运行的路径,使用相对路径。
ie2 = Taskflow('information_extraction',
schema=uie_schema,
schema_lang="zh",
model='paddlenlp/PP-UIE-0.5B',
task_path='paddlenlp/PP-UIE-0.5B',
device_id=0,
batch_size=1,
precision='float32', # 使用全精度
dtype='float32', # 设置dtype
position_prob=0.5,)
具体来说,就是model参数使用网络上的名称,task_path使用你的相对路径,注意是代码运行路径
第二个问题没有遇到过,或许你输出模型的时候没有保存这个参数文件?如果它是可选的话
我之前修改过下载模型的地址,还是不生效,不知道为啥,建议这种路径修改为可配置的绝对或者相对路径
还有个问题,即使已经缓存了,每次还要去下载一个json
[2025-05-27 16:15:14,480] [ INFO] - Loading weights file from cache at C:\Users\Administrator\.paddlenlp\models\paddlenlp/PP-UIE-0.5B\model.safetensors.index.json Downloading shards: 100%|███████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<?, ?it/s]
@DJ-Yosef 这个是什么问题呢
还有个问题,即使已经缓存了,每次还要去下载一个json
[2025-05-27 16:15:14,480] [ INFO] - Loading weights file from cache at C:\Users\Administrator\.paddlenlp\models\paddlenlp/PP-UIE-0.5B\model.safetensors.index.json Downloading shards: 100%|███████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<?, ?it/s]
我也遇到了,百思不得其解,不过这个文件对模型没有影响,占空间也不大就没管。 我觉得 paddlepaddle 发展为 torch 这样的框架还有一定距离,一些API不成熟且不稳定
我之前修改过下载模型的地址,还是不生效,不知道为啥,建议这种路径修改为可配置的绝对或者相对路径
那最后你能加载本地模型吗?
我之前修改过下载模型的地址,还是不生效,不知道为啥,建议这种路径修改为可配置的绝对或者相对路径
那最后你能加载本地模型吗?
不能,还是自动联网下载路径的模型
我想从hfhub获取模型,看到taskflow带有个from_hf_hub参数,给了true实际是没用的,看了官方的文档也是没人维护了,都是老的文档,太难了
唉,说旧他开发版库基本每日一更,说新文档也是至少2年没更新了。这平台生态和体量还是不如pytorch
在 2025-08-08 14:34:08,"龍貓" @.***> 写道:
totoro52 left a comment (PaddlePaddle/PaddleNLP#10660)
我想从hfhub获取模型,看到taskflow带有个from_hf_hub参数,给了true实际是没用的,看了官方的文档也是没人维护了,都是老的文档,太难了
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。
This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。