plasticityai/magnitude 的不完整词嵌入模型转换

Incomplete word embedding model conversion with plasticityai/magnitude

我想转换词嵌入模型Numberbatch 19.08 to the .magnitude format used in plasticityai/magnitude。因为我希望能够使用近似最近邻算法,所以我 运行 命令

python -m pymagnitude.converter -i numberbatch.txt -o numberbatch.magnitude -a

解压后的大小numberbatch.txt约为20GB。我正在使用 Windows10.

起初,转换似乎 运行 正常(几个小时),显示的进度类似于

Writing vectors... (this may take some time)

1% completed ... 99% completed

然后

Committing written vectors... (this may take some time)

最后

Creating search index... (this may take some time)

Creating spatial search index for dimension 2 (it has high entropy)... (this may take some time)

Creating approximate nearest neighbors index... (this may take some time)

但是,我从未收到转换完成的最终消息。相反,程序会在没有任何进一步消息的情况下停止。

那个阶段我在目标文件夹中留下了以下三个文件:

    15.891.668.992 numberbatch.magnitude.tmp
           557.056 numberbatch.magnitude.tmp-shm
       281.227.112 numberbatch.magnitude.tmp-wal

预期的最终结果 numberbatch.magnitude 缺失。

任何关于可能出错的提示都将不胜感激。有什么方法可以使用三个 tmp 文件完成转换吗?

我想我在 plasticity/ai 项目的 closed issue 中找到了我自己问题的部分答案:

当与生成近似最近邻索引的 -a 标志一起使用时,pymagnitude.converter 似乎无法处理多 GB 范围内的矢量文件大小。在问题中推测这是底层 Annoy 库的问题,尽管确切原因从未完全解决。

在这个阶段,临时补救措施是放弃使用 -a 标志。