bert_score icon indicating copy to clipboard operation
bert_score copied to clipboard

Mabey we cannot assert 'model_type' as a local path?

Open 141forever opened this issue 1 year ago • 6 comments

141forever avatar May 08 '24 08:05 141forever

maybe yes

shuaijiumei avatar May 09 '24 21:05 shuaijiumei

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

shuaijiumei avatar May 09 '24 21:05 shuaijiumei

THANKS A LOT!

141forever avatar May 10 '24 04:05 141forever

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

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!

WangYangfan avatar Jun 14 '24 16:06 WangYangfan

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 Thank u. It works a lot, Awesome

Brown-yang avatar Jul 22 '24 04:07 Brown-yang

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

照着修改了这里怎么也不管用啊,中国国内也连不上huggingface,我把预训练模型文件下载下来了,修改了utils里面的lang2model、model2layers中模型的路径,还是提示 We couldn't connect to 'https://huggingface.co/' to load this file,

zxjhellow2 avatar Aug 13 '24 06:08 zxjhellow2