我尝试下载DrQA,这是一种由Facebook研究小组开发的用于开放域问答的阅读理解系统。它包括要求提供经过培训的Wikipedia问题解答的模型和数据。但是,当我尝试启动交互式会话时,此AttributeError
出现了:
(drqa_env) mike@mike-thinks:~/Programing/DrQA$ python scripts/pipeline/interactive.py
07/16/2018 11:38:35 PM: [ Running on CPU only. ]
07/16/2018 11:38:35 PM: [ Initializing pipeline... ]
07/16/2018 11:38:35 PM: [ Initializing document ranker... ]
07/16/2018 11:38:35 PM: [ Loading /home/mike/Programing/DrQA/data/wikipedia/docs-tfidf-ngram=2-hash=16777216-tokenizer=simple.npz ]
Traceback (most recent call last):
File "scripts/pipeline/interactive.py", line 83, in <module>
tokenizer=args.tokenizer
File "/home/mike/Programing/DrQA/drqa/pipeline/drqa.py", line 109, in __init__
self.ranker = ranker_class(**ranker_opts)
File "/home/mike/Programing/DrQA/drqa/retriever/tfidf_doc_ranker.py", line 37, in __init__
matrix, metadata = utils.load_sparse_csr(tfidf_path)
File "/home/mike/Programing/DrQA/drqa/retriever/utils.py", line 33, in load_sparse_csr
loader = np.load(filename)
File "/home/mike/Programing/drqa_env/lib/python3.6/site-packages/numpy/lib/npyio.py", line 414, in load
pickle_kwargs=pickle_kwargs)
File "/home/mike/Programing/drqa_env/lib/python3.6/site-packages/numpy/lib/npyio.py", line 173, in __init__
_zip = zipfile_factory(fid)
File "/home/mike/Programing/drqa_env/lib/python3.6/site-packages/numpy/lib/npyio.py", line 103, in zipfile_factory
return zipfile.ZipFile(file, *args, **kwargs)
File "/usr/lib/python3.6/zipfile.py", line 1108, in __init__
self._RealGetContents()
File "/usr/lib/python3.6/zipfile.py", line 1175, in _RealGetContents
raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
Exception ignored in: <bound method NpzFile.__del__ of <numpy.lib.npyio.NpzFile object at 0x7fa18140e9e8>>
Traceback (most recent call last):
File "/home/mike/Programing/drqa_env/lib/python3.6/site-packages/numpy/lib/npyio.py", line 210, in __del__
self.close()
File "/home/mike/Programing/drqa_env/lib/python3.6/site-packages/numpy/lib/npyio.py", line 201, in close
if self.zip is not None:
AttributeError: 'NpzFile' object has no attribute 'zip'
这似乎意味着Numpy对象没有zip属性。我认为它试图解压缩模型文件,但没有合适的工具。
你知道如何应付吗?我在a GitHub issue中讨论过的大型存储模型库下载时,已经遇到了这个存储库问题。
根据abarnet,看来问题在于zipfile模块无法解压缩(然后NumPy的错误处理并不尽如人意)。它可能是损坏的文件,所以我试图解压缩造成错误的文件:
mike@mike-thinks:~/Programing/DrQA/data/wikipedia$ unzip -t docs-tfidf-ngram=2-hash=16777216-tokenizer=simple.npz
Archive: docs-tfidf-ngram=2-hash=16777216-tokenizer=simple.npz
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of docs-tfidf-ngram=2-hash=16777216-tokenizer=simple.npz or
docs-tfidf-ngram=2-hash=16777216-tokenizer=simple.npz.zip, and cannot find docs-tfidf-ngram=2-hash=16777216-tokenizer=simple.npz.ZIP, period.