odin-llama3.1-medical-ner-v14

A LoRA adapter fine-tuned for medical Named Entity Recognition (NER) and Relation Extraction (RE).

Task

Extracts medical entities and their relationships from clinical text.

  • Entity types: Disease, Drug, Symptom
  • Relation types: associated_with, causes, interacts_with, treats

Model Details

  • Base model: unsloth/meta-llama-3.1-8b-bnb-4bit
  • LoRA rank (r): 32
  • LoRA alpha: 32
  • Target modules: q_proj, gate_proj, v_proj, up_proj, down_proj, o_proj, k_proj
  • PEFT type: LORA

Evaluation Results

Metric Precision Recall F1
Entity (micro) 0.900 0.923 0.911
Relation (micro) 0.814 0.851 0.832

Usage

from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base_model = "unsloth/meta-llama-3.1-8b-bnb-4bit"
adapter_id = "pabloformoso/odin-llama3.1-medical-ner-v14"

tokenizer = AutoTokenizer.from_pretrained(adapter_id)
model = AutoModelForCausalLM.from_pretrained(base_model, device_map="auto")
model = PeftModel.from_pretrained(model, adapter_id)

prompt = """### Instruction:
Extract all medical entities and their relations from the following clinical text.

### Input:
The patient developed acute renal failure after treatment with enalapril.

### Output:"""

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Training Data

Combined dataset from:

  • ADE Corpus V2: Drug–adverse effect relations
  • BC5CDR: Chemical–disease relations
  • BioRED: Biomedical relation extraction
Downloads last month
3
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support