Model Card for Tomohiro/MedTXTNER
本モデルは、日本語医療テキストの NER(固有表現抽出)タスク向けに cl-tohoku/bert-base-japanese-v3
をファインチューニングしたモデルです。
モデル詳細
説明
- ベースに
cl-tohoku/bert-base-japanese-v3
を使用 - 奈良先端大で作成された日本語医療テキストのアノテーション付きデータ(症例報告、読影レポート、看護記録)でファインチューニングを実施
項目 | 詳細 |
---|---|
Developed by | NAIST ソーシャルコンピューティング研究室 |
Model type | Token classification |
Language(s) | Japanese |
Finetuned from | cl-tohoku/bert-base-japanese-v3 |
モデルソース
- Hub リポジトリ: https://huggingface.co/Tomohiro/MedTXTNER
利用方法
import torch
from transformers import AutoTokenizer, AutoModelForTokenClassification
model_dir = "Tomohiro/MedTXTNER"
model = AutoModelForTokenClassification.from_pretrained(model_dir)
tokenizer = AutoTokenizer.from_pretrained(checkpoint_dir, use_fast=True)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
model.eval()
def predict_text(text: str):
enc = tokenizer(
text,
return_tensors="pt",
truncation=True,
padding="max_length",
max_length=512,
is_split_into_words=False
).to(device)
with torch.no_grad():
outputs = model(**enc)
logits = outputs.logits
pred_ids = torch.argmax(logits, dim=-1)[0].cpu().tolist()
tokens = tokenizer.convert_ids_to_tokens(enc["input_ids"][0])
id2label = model.config.id2label
result = []
for tok, pid in zip(tokens, pred_ids):
if tok in tokenizer.all_special_tokens:
continue
result.append((tok, id2label[pid]))
return result
sample = "症例】53歳女性。発熱と嘔気を認め、プレドニゾロンを中断しました。"
for tok, lab in predict_text(sample):
print(f"{tok}\t{lab}")
- Downloads last month
- 8
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
🙋
Ask for provider support