Instructions to use odin-deus/odin-llama3.1-medical-ner-v14 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use odin-deus/odin-llama3.1-medical-ner-v14 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/meta-llama-3.1-8b-bnb-4bit") model = PeftModel.from_pretrained(base_model, "odin-deus/odin-llama3.1-medical-ner-v14") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use odin-deus/odin-llama3.1-medical-ner-v14 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for odin-deus/odin-llama3.1-medical-ner-v14 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for odin-deus/odin-llama3.1-medical-ner-v14 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for odin-deus/odin-llama3.1-medical-ner-v14 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="odin-deus/odin-llama3.1-medical-ner-v14", max_seq_length=2048, )
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