Views
No views yet
1import transformers
2
3model = transformers.AutoModelWithLMHead.from_pretrained('lordtt13/COVID-SciBERT')
4
5tokenizer = transformers.AutoTokenizer.from_pretrained('lordtt13/COVID-SciBERT')
6
7nlp_fill = transformers.pipeline('fill-mask', model = model, tokenizer = tokenizer)
8nlp_fill('Coronavirus or COVID-19 can be prevented by a' + nlp_fill.tokenizer.mask_token)
9
10# Output:
11# [{'sequence': '[CLS] coronavirus or covid - 19 can be prevented by a combination [SEP]',
12# 'score': 0.1719885915517807,
13# 'token': 2702},
14# {'sequence': '[CLS] coronavirus or covid - 19 can be prevented by a simple [SEP]',
15# 'score': 0.054218728095293045,
16# 'token': 2177},
17# {'sequence': '[CLS] coronavirus or covid - 19 can be prevented by a novel [SEP]',
18# 'score': 0.043364267796278,
19# 'token': 3045},
20# {'sequence': '[CLS] coronavirus or covid - 19 can be prevented by a high [SEP]',
21# 'score': 0.03732519596815109,
22# 'token': 597},
23# {'sequence': '[CLS] coronavirus or covid - 19 can be prevented by a vaccine [SEP]',
24# 'score': 0.021863549947738647,
25# 'token': 7039}]Created by Tanmay Thakur | LinkedIn
PS: Still looking for more resources to expand my expansion!