我通过spacy网站中指定的(https://spacy.io/usage/training/#example-new-entity-type)方法训练了自定义模型。加载训练模型时,出现错误:
File "tokenizer.pyx", line 450, in spacy.tokenizer.Tokenizer.from_disk
File "tokenizer.pyx", line 498, in spacy.tokenizer.Tokenizer.from_bytes
File "/home/ubuntu/764934/nlp_1/lib/python3.5/re.py", line 224, in compile
return _compile(pattern, flags)
File "/home/ubuntu/764934/nlp_1/lib/python3.5/re.py", line 293, in _compile
p = sre_compile.compile(pattern, flags)
File "/home/ubuntu/764934/nlp_1/lib/python3.5/sre_compile.py", line 540, in compile
code = _code(p, flags)
File "/home/ubuntu/764934/nlp_1/lib/python3.5/sre_compile.py", line 525, in _code
_compile(code, p.data, flags)
File "/home/ubuntu/764934/nlp_1/lib/python3.5/sre_compile.py", line 185, in _compile
_compile(code, av, flags)
File "/home/ubuntu/764934/nlp_1/lib/python3.5/sre_compile.py", line 158, in _compile
raise error("look-behind requires fixed-width pattern")
知道/解决了这个错误的任何人都可以帮助我。
答案 0 :(得分:0)
检查是否以与训练相同的spacy版本加载模型。比较版本中的前两个数字以查看它们是否兼容(在保存的模型中,在meta.json
中查看):spacy v2.0模型无法由spacy v2.1加载,但可以使用spacy v2.1.0仍可与spacy v2.1.9一起使用。