Downloads · 30 days
0
fabriceyhc/Llama-DrugDetector-8B-MFI
Llama-DrugDetector-8B-MFI is a text generation model from fabriceyhc. Use it when you need the model to write or continue text. The card lists the license as llama3.1.
Llama-DrugDetector-8B-MFI is a fine-tuned medical NLP model for detecting illicit drug use in clinical notes. It specializes in identifying: - Methamphetamine (illicit use) - Fentanyl (illicit use) - Injection Drug Us…
Downloads · 30 days
0
Access
Public
Updated Dec 12, 2025
Repo size
509 MB
Likes
0
Public
Click a slice to open those files.
.pt328 MB · 53%
From the Hugging Face model README
Llama-DrugDetector-8B-MFI is a fine-tuned medical NLP model for detecting illicit drug use in clinical notes. It specializes in identifying:
The model performs multi-task learning, simultaneously predicting:
Evaluated on 159 clinical note sentences:
| Drug | F1 Score | Precision | Recall |
|---|---|---|---|
| Methamphetamine | 0.931 | 0.915 | 0.947 |
| Fentanyl | 0.950 | 0.927 | 0.974 |
| Injection Drug Use | 0.923 | 0.913 | 0.933 |
| Drug | Base F1 | Fine-tuned F1 | Improvement |
|---|---|---|---|
| Methamphetamine | 0.787 | 0.931 | +14.4pp |
| Fentanyl | 0.753 | 0.950 | +19.7pp |
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
# Load base model
base_model = "fabriceyhc/Llama-DrugDetector-8B"
model = AutoModelForCausalLM.from_pretrained(
base_model,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Load LoRA adapter
model = PeftModel.from_pretrained(model, "fabriceyhc/Llama-DrugDetector-8B-MFI")
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("fabriceyhc/Llama-DrugDetector-8B-MFI")
# Create prompt
note_text = "Patient reports using meth daily for the past 2 weeks."
prompt = f"""### Task Description:
Please carefully review the following medical note and identify illicit drug use.
**CRITICAL RULES:**
1. **Positive drug test → ALWAYS ILLICIT** (unless in medication list)
2. **PMH/History of use → ILLICIT** (even if historical)
3. **Substance use disorder → ILLICIT**
4. **Patient self-reports (endorses, reports, admits) → ILLICIT**
5. **Prescribed/medical use → NOT ILLICIT**:
- Medication lists with dosages
- "Given", "administered" in medical context
- Pain control, procedural use (fentanyl)
- Prescription quantities
**Drugs to identify:**
- **Methamphetamine**: Illicit amphetamine use (not prescribed Adderall for ADHD)
- **Fentanyl**: Illicit fentanyl use (not prescribed patches/procedural use)
- **Injection Drug Use**: IV drug use (IVDU, IVDA), including IV heroin, cocaine, meth
**Temporal Classification** (for illicit cases only):
- **Current**: Present tense, recent use, positive test results, "POA" (present on arrival)
- **Historical**: Past tense, "history of", "former user", "in remission"
- **Unknown**: Timeframe unclear or ambiguous
### Desired Format:
Methamphetamine Illicit Use: <True/False/Unknown>
Fentanyl Illicit Use: <True/False/Unknown>
Injection Drug Use: <True/False/Unknown>
Methamphetamine Temporal Status: <Current/Historical/Unknown/N/A>
Fentanyl Temporal Status: <Current/Historical/Unknown/N/A>
Injection Drug Use Temporal Status: <Current/Historical/Unknown/N/A>
### The medical note to evaluate:
{note_text}
### Answer:
"""
# Generate
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=200,
do_sample=False,
pad_token_id=tokenizer.eos_token_id
)
# Decode
result = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
print(result)
Methamphetamine Illicit Use: True
Fentanyl Illicit Use: False
Injection Drug Use: False
Methamphetamine Temporal Status: Current
Fentanyl Temporal Status: N/A
Injection Drug Use Temporal Status: N/A
Data includes:
Annotations cover diverse clinical scenarios:
Primary Use Cases:
NOT Recommended For:
@misc{llama-drugdetector-mfi-2025,
author = {Harel-Canada, Fabrice},
title = {Llama-DrugDetector-8B-MFI: Multi-task Clinical Drug Detection},
year = {2025},
publisher = {HuggingFace},
url = {https://huggingface.co/fabriceyhc/Llama-DrugDetector-8B-MFI}
}
Llama 3.1 Community License Agreement
For questions or issues, please open an issue on the model repository.