DrugNER with PubMedBERT on the DDI 2013 Corpus
This project builds a Named Entity Recognition (NER) model to identify drug-related entities in biomedical text using the [DDI 2013 Challenge Corpus] and fine-tunes the domain-specific PubMedBERT model.
Project Structure
DDICorpus/
βββ Train/
β βββ DrugBank/
β βββ MedLine/
βββ Test/
β βββ Test for DrugNER task/
βββ NER_DDI/
β βββ parsed_data.json
β βββ tokenized_dataset/
β βββ val_dataset/
β βββ models/
β β βββ final_model/
β βββ eval_results/
## Model
- **Base model:** `microsoft/BiomedNLP-PubMedBERT-base-uncased-abstract`
- **Fine-tuned on:** DDI 2013 training set
- **Entity types:** `drug`, `brand`, `group`, `drug_n`
- **Labels format:** BIO tagging scheme
- **Final evaluation:** on the DDI Test Set (unseen XML files)
## Training Pipeline
1. **Parse & label the XML corpus** (BIO format aligned to tokenizer offsets)
2. **Create HuggingFace Dataset** (`datasets.Dataset`)
3. **Tokenize with alignment**
4. **Fine-tune model using `Trainer`**
5. **Save model and tokenizer**
6. **Evaluate on test set**
7. **Compute metrics with `seqeval` + confusion matrix**
## Final Results (Test Set)
| Entity Type | Precision | Recall | F1-score |
|-------------|-----------|--------|----------|
| Drug | 0.7820 | 0.8940 | 0.8342 |
| Brand | 0.8780 | 0.6102 | 0.7200 |
| Group | 0.8293 | 0.8774 | 0.8527 |
| Drug_n | 0.4953 | 0.4417 | 0.4670 |
| **Overall** | **0.7553**| **0.7862** | **0.7704** |
## Example Inference
```python
sentence = "Aspirin and paracetamol were found to interact against each other."
entities = [
{'type': 'drug', 'text': 'Aspirin'},
{'type': 'drug', 'text': 'paracetamol'}
]
- Downloads last month
- 7
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support