Downloads · 30 days
28
17% of all-time downloads
DNivalis/med-jargon-crf
med-jargon-crf is a token classification model from DNivalis. Use it when you need labels on individual words, such as names. The card lists the license as apache-2.0.
A PyTorch model that performs fine-grained medical jargon identification using a RoBERTa-large backbone enhanced by a Conditional Random Field (CRF) layer. Fine-tuned on the MedReadMe dataset introduced by Jiang & Xu…
Downloads · 30 days
28
17% of all-time downloads
All-time downloads
168
Public
Repo size
2.8 GB
Likes
0
Public
Click a slice to open those files.
.bin1.4 GB · 100%
From the Hugging Face model README
A PyTorch model that performs fine-grained medical jargon identification using a RoBERTa-large backbone enhanced by a Conditional Random Field (CRF) layer.
Fine-tuned on the MedReadMe dataset introduced by Jiang & Xu (2024).
| Label (BIO) | Meaning |
|---|---|
medical-jargon-google-easy | Easily Google-able medical terms |
medical-jargon-google-hard | Complex, hard-to-Google medical terms |
medical-name-entity | Named diseases, drugs, procedures |
general-complex | Complex general vocabulary |
abbr-medical | Medical abbreviations (e.g., ECG, CBC) |
abbr-general | General abbreviations |
general-medical-multisense | Words with both lay and medical meanings |
pytorch_model.bin – model weightsconfig.json – hyper-parameters & label maptokenizer.json, vocab.json, merges.txt – RoBERTa tokenizer assetsmodeling_jargon.py – custom CRFTokenClassificationModel classrequirements.txt – runtime dependenciesfrom transformers import AutoTokenizer
from modeling_jargon import CRFTokenClassificationModel
import torch
# 1. Load model and tokenizer
model_name = "DNivalis/med-jargon-crf"
tokenizer = AutoTokenizer.from_pretrained(model_name, add_prefix_space=True)
model = CRFTokenClassificationModel.from_pretrained(model_name)
model.eval()
# 2. Prepare input text
text = "The patient presented with elevated CRP and intermittent AF."
inputs = tokenizer(text, return_tensors="pt")
# 3. Run inference
with torch.no_grad():
outputs = model(**inputs)
logits = outputs["logits"]
# Decode best sequence using CRF
predicted_tags = model.decode(logits, inputs["attention_mask"])[0]
# 4. Extract spans from predictions
spans = [(i, model.id2label[tag_id]) for i, tag_id in enumerate(predicted_tags) if tag_id != 0]
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
# 5. Display results
print("Detected medical jargon:")
for token_idx, label in spans:
# Find continuous spans of the same entity
end_idx = token_idx + 1
while (end_idx < len(predicted_tags) and
predicted_tags[end_idx] == predicted_tags[token_idx]):
end_idx += 1
# Convert tokens back to text
detected_tokens = tokens[token_idx:end_idx]
detected_text = tokenizer.convert_tokens_to_string(detected_tokens)
print(f"{label}: '{detected_text.strip()}'")
English only.
Fine-tuned on MedReadMe: 4,520 sentences with fine-grained jargon span annotations, including the novel Google-Easy and Google-Hard categories .
If you use this model or the underlying dataset, please cite:
@article{jiang2024medreadmesystematicstudyfinegrained,
title={MedReadMe: A Systematic Study for Fine-grained Sentence Readability in Medical Domain},
author={Chao Jiang and Wei Xu},
year={2024},
eprint={2405.02144},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2405.02144}
}
Licensed under Apache 2.0.
For questions, issues, or licensing inquiries, open an issue on the model repository.