Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
141forever opened this issue May 8, 2024 · 6 comments
Open

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

141forever opened this issue May 8, 2024 · 6 comments

Comments

@141forever
Copy link

No description provided.

@shuaijiumei
Copy link

maybe yes

@shuaijiumei
Copy link

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

@141forever
Copy link
Author

THANKS A LOT!

@WangYangfan
Copy link

WangYangfan commented Jun 14, 2024

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!

@Brown-yang
Copy link

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

@zxjhellow2
Copy link

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants