【问题标题】:OSError: [E053] Could not read meta.json from model-best.zipOSError:[E053] 无法从 model-best.zip 读取 meta.json
【发布时间】:2023-01-28 03:45:28
【问题描述】:

我试图加载经过训练的 spacy 模型,但出现此错误: OSError:[E053] 无法从 model-best.zip 读取 meta.json

这是我的代码: nlp_ner = spacy.load("model-best.zip") 有没有人可以帮助我

【问题讨论】:

    标签: machine-learning model spacy named-entity-recognition


    【解决方案1】:

    对于 spaCy 3,您可以从 3 个来源加载模型:

    通常,这些模型中的任何一个都存储为文件夹或目录,具有与此类似的结构(对于 NER 模型,它似乎是您要加载的模型):

    /path/to/your/model/
    ├── model-best  <== THIS DIRECTORY IS WHAT YOU MIGHT HAVE
    │   ├── config.cfg
    │   ├── meta.json
    │   ├── ner
    │   │   ├── cfg
    │   │   ├── model
    │   │   └── moves
    │   ├── tok2vec
    │   │   ├── cfg
    │   │   └── model
    │   ├── tokenizer
    │   └── vocab
    │       ├── key2row
    │       ├── lookups.bin
    │       ├── strings.json
    │       ├── vectors
    │       └── vectors.cfg
    └── model-last
        ├── config.cfg
        ├── meta.json
        ├── ner
        │   ├── cfg
        │   ├── model
        │   └── moves
        ├── tok2vec
        │   ├── cfg
        │   └── model
        ├── tokenizer
        └── vocab
            ├── key2row
            ├── lookups.bin
            ├── strings.json
            ├── vectors
            └── vectors.cfg
    
    8 directories, 26 files
    

    这会将“直接从 .zip 文件加载”作为有效选项丢弃。

    我想您可能想尝试以下操作:

    1. 尝试解压缩 model-best.zip 并查看是否找到与上面显示的类似的目录结构。如果您在基于 Linux 的系统中,here 就是这样。
    2. 如果确认前面的结构,那么继续第3步,否则你的文件可能已经损坏,或者不是spaCy模型,你将无法加载模型。
    3. 试试nlp_ner = spacy.load("/path/to/your/model-best")(在你的情况下是nlp_ner = spacy.load("./model-best")),看看它是否有效。

      希望能帮助到你。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-25
      • 1970-01-01
      • 2016-08-26
      • 1970-01-01
      相关资源
      最近更新 更多