gpt4 book ai didi

python - 复制命令 fasttext 查询并保存 FastText 向量

转载 作者:太空宇宙 更新时间:2023-11-03 20:34:28 26 4
gpt4 key购买 nike

我正在使用预训练的 FastText 模型设置 nlp 预处理来查询和保存词向量。我遇到了 FileNotFoundError: [Errno 2] No such file or directory: 'fasttext': 'fasttext' 并且目前无法解决它。

这是我正在从事的一个 NLP 临床文本相似性项目。我仔细检查以确保目录中存在所有文件和文件夹。我还想指出,我同时使用了 floydhub 和 google colab 以确保这不是环境问题。我经历了这个过程两次,最终出现了同样的错误。第二眼肯定会有所帮助。

复制命令 fasttext print-vectors model.bin >vector.vec 的代码如下:

with open(VOCAB_FILE) as f_vocab:
with open(OUTPUT_FILE, 'a') as f_output:
subprocess.run(
[FASTTEXT_EXECUTABLE, 'print-word-vectors', PRETRAINED_MODEL_FILE],
stdin=f_vocab,
stdout=f_output)
The traceback error I am getting is below: 

FileNotFoundError Traceback (most recent call last)
<ipython-input-150-7b469ee34f75> in <module>()
4 [FASTTEXT_EXECUTABLE, 'print-word-vectors', PRETRAINED_MODEL_FILE],
5 stdin=f_vocab,
----> 6 stdout=f_output)

/usr/local/lib/python3.6/subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
401 kwargs['stdin'] = PIPE
402
--> 403 with Popen(*popenargs, **kwargs) as process:
404 try:
405 stdout, stderr = process.communicate(input, timeout=timeout)

/usr/local/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
707 c2pread, c2pwrite,
708 errread, errwrite,
--> 709 restore_signals, start_new_session)
710 except:
711 # Cleanup if the child failed starting.

/usr/local/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1342 if errno_num == errno.ENOENT:
1343 err_msg += ': ' + repr(err_filename)
-> 1344 raise child_exception_type(errno_num, err_msg, err_filename)
1345 raise child_exception_type(err_msg)
1346

FileNotFoundError: [Errno 2] No such file or directory: 'fasttext': 'fasttext'

预期的结果是能够查询和保存快速文本向量。我们上面的代码片段从 github 存储库获取并用于 Kaggles Quora 问题对。

最佳答案

必须安装Fasttext才能查询和保存Fasttext向量。

关于python - 复制命令 fasttext 查询并保存 FastText 向量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57260616/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com