🚀 基于SciBERT的科学实体识别模型
本模型是基于SciBERT的科学实体识别模型,可识别特定的科学实体类型,为科学文本处理提供了有效的解决方案。
🚀 快速开始
模型详情
模型描述
这是一个基于SciBERT的科学实体识别任务模型。预定义的实体类型包括:'Generic'(通用)、'Material'(材料)、'Method'(方法)、'Metric'(指标)、'OtherScientificTerm'(其他科学术语)和'Task'(任务)。
模型来源
使用示例
基础用法
from transformers import AutoConfig, AutoTokenizer, AutoModelForTokenClassification
tokenizer = AutoTokenizer.from_pretrained('Kashob/SciBERTNER')
model = AutoModelForTokenClassification.from_pretrained('Kashob/SciBERTNER')
config = AutoConfig.from_pretrained('Kashob/SciBERTNER')
id2tag = config.id2label
text = 'The paper tackles the problem of endowing Transformers with the ability to encode information about the past via recurrence. The proposed architecture can leverage the recurrent connections to improve the sample efficiency while maintaining expressivity due to the use of self-attention.'.split()
inputs = tokenizer(text, is_split_into_words=True, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predictions = outputs.logits.argmax(-1)
tokenized_text = tokenizer.convert_ids_to_tokens(inputs['input_ids'].tolist()[0])
predicted_labels = [id2tag[label_id] for label_id in predictions[0].tolist()]
print(tokenized_text)
print(predicted_labels)
Output:
['[CLS]', 'the', 'paper', 'tackle', '##s', 'the', 'problem', 'of', 'endow', '##ing', 'transformers', 'with', 'the', 'ability', 'to', 'encode', 'information', 'about', 'the', 'past', 'via', 'recurrence', '.', 'the', 'proposed', 'architecture', 'can', 'leverage', 'the', 'recurrent', 'connections', 'to', 'improve', 'the', 'sample', 'efficiency', 'while', 'maintaining', 'express', '##ivity', 'due', 'to', 'the', 'use', 'of', 'self', '-', 'attention', '.', '[SEP]']
['O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'B-OtherScientificTerm', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'B-Method', 'O', 'O', 'O', 'B-Generic', 'O', 'O', 'O', 'B-OtherScientificTerm', 'I-OtherScientificTerm', 'O', 'O', 'O', 'B-Metric', 'I-Metric', 'O', 'O', 'B-Metric', 'I-OtherScientificTerm', 'O', 'O', 'O', 'O', 'O', 'B-Method', 'I-OtherScientificTerm', 'I-OtherScientificTerm', 'O', 'O']
模型卡片作者
Kashob Kumar Roy
计算机科学专业,伊利诺伊大学厄巴纳 - 香槟分校
模型卡片联系方式
- 邮箱:kkroy2 at illinois dot edu
如果您对这个预训练模型有任何疑问,请随时联系。
📄 许可证
本模型采用MIT许可证。