首次运行OmniEvent运行报错
运行代码如下:
from OmniEvent.infer import infer
>>> # Even Extraction (EE) Task
>>> text = "2022年北京市举办了冬奥会"
>>> results = infer(text=text, task="EE")
>>> print(results[0]["events"])
系统报错情况如图
首次运行OmniEvent运行报错
运行代码如下:
from OmniEvent.infer import infer
>>> # Even Extraction (EE) Task
>>> text = "2022年北京市举办了冬奥会"
>>> results = infer(text=text, task="EE")
>>> print(results[0]["events"])
系统报错情况如图
引自免费微信小程序:皆我百晓生:
根据您提供的错误信息,首次运行OmniEvent时出现了几个问题。这些问题主要集中在模型文件下载和解压过程中以及从Hugging Face模型库加载预训练模型配置文件失败上。
首先,OmniEvent试图从缓存或网络下载预训练模型“s2s-mt5-eae”。在下载过程中,似乎出现了完整性问题,因为系统未能找到zip文件的中央目录签名,这意味着可能由于网络不稳定或其他原因导致下载不完整。
错误提示:
End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive.
接下来,在尝试解压下载的模型文件时,系统找不到有效的zip文件结构,导致解压失败。
unzip: cannot find zipfile directory in c:/Users/lenovo/.cache/OmniEvent_Model/s2s-mt5-eae.zip
最后,在处理上述异常时,OmniEvent尝试从本地缓存目录加载模型配置文件,但由于之前模型文件没有正确下载和解压,因此无法找到所需的config.json文件,从而抛出OSError。
OSError: We couldn't connect to 'https://huggingface.co' to load this model, couldn't find it in the cached and it looks like C:\Users\lenovo\.cache\OmniEvent_Model\s2s-mt5-eae is not the path to a directory containing a config.json file.
针对这个问题,您可以采取以下解决步骤:
清理并重新下载:确保网络连接稳定后,尝试清除OmniEvent相关模型缓存(C:\Users\Lenovo.cache\OmniEvent_Model\),然后重新运行代码以触发模型的重新下载。
检查代理设置:如果您的网络环境使用了代理服务器,请确认transformers
库能正确识别和使用代理设置。
手动下载模型:访问Hugging Face Model Hub上的相应模型页面,下载模型权重文件和配置文件,并将其放置在适当的缓存路径下,确保文件结构正确。
调整代码逻辑:在OmniEvent库中,可以考虑添加更健壮的模型下载和验证机制,例如通过检查下载文件的完整性后再进行解压,或者在网络请求失败时提供重试机制。