Mabey we cannot assert 'model_type' as a local path?
maybe yes
easy to handle, \bert_score\score.py this file,change the line 95 ,
if num_layers is None: num_layers = model2layers[model_type]
to
if num_layers is None: # 如果 model_type 是路径,则截取最后一个/后的字符串 if "/" in model_type: num_layers = model2layers[model_type.split("/")[-1]]
Then you could use your local model, hope It could help you
THANKS A LOT!
easy to handle, \bert_score\score.py this file,change the line 95 ,
if num_layers is None: num_layers = model2layers[model_type]toif num_layers is None: # 如果 model_type 是路径,则截取最后一个/后的字符串 if "/" in model_type: num_layers = model2layers[model_type.split("/")[-1]]Then you could use your local model, hope It could help you
Good!
I make this method work better. After modification, you only need to change model_type to your local model path, e.g.
self.bert_scorer = BERTScorer(
model_type="/Users/wangyangfan/remote/models/FacebookAI/roberta-large",
device='mps',
rescale_with_baseline=True,
lang='en'
)
👏 Inspired by @shuaijiumei, thanks a lot!
Also, I created a PR that you can collaborate with if you are interested!
easy to handle, \bert_score\score.py this file,change the line 95 ,
if num_layers is None: num_layers = model2layers[model_type]toif num_layers is None: # 如果 model_type 是路径,则截取最后一个/后的字符串 if "/" in model_type: num_layers = model2layers[model_type.split("/")[-1]]Then you could use your local model, hope It could help you Thank u. It works a lot, Awesome
easy to handle, \bert_score\score.py this file,change the line 95 ,
if num_layers is None: num_layers = model2layers[model_type]toif num_layers is None: # 如果 model_type 是路径,则截取最后一个/后的字符串 if "/" in model_type: num_layers = model2layers[model_type.split("/")[-1]]Then you could use your local model, hope It could help you
照着修改了这里怎么也不管用啊,中国国内也连不上huggingface,我把预训练模型文件下载下来了,修改了utils里面的lang2model、model2layers中模型的路径,还是提示 We couldn't connect to 'https://huggingface.co/' to load this file,