这个问题是关于NLP Python模块Flair (https://github.com/flairNLP/flair)的。
模型的默认下载文件夹位于flair缓存(~/.flair)中。但是,在服务器上工作时,我更喜欢在另一个位置进行此下载,因为/home目录非常小。下面是一个最小的工作示例。
from flair.data import Sentence
from flair.models import SequenceTagger
# make a sentence
sentence = Sentence('I love Berlin .')
# load the NER tagger
tagger = SequenceTagger.load('ner')因此,您可以看到设备上没有剩余空间,并显示以下错误:(...) OSError: [Errno 28] No space left on device: '~/.flair/models/ner-english/tmp8js3y34i' (...)
发布于 2021-03-18 19:43:31
张贴一个答案,以防有人像我一样被困在这里。
from pathlib import Path
import flair
#flair.cache_root = "/your/path/.flair" # DOES NOT WORK
flair.cache_root = Path("/your/path/.flair")# WORKS发布于 2021-06-26 01:37:14
您可以设置环境变量FLAIR_CACHE_ROOT。通过查看根.py文件找到。
在某些旧版本的FlairNLP中,这将不起作用。应将os.getenv函数传递给Path
cache_root = Path(os.getenv('FLAIR_CACHE_ROOT', Path(Path.home(), ".flair")))https://stackoverflow.com/questions/66689472
复制相似问题