Text Generation
PEFT
Safetensors
medical
biology
chemistry
conversational
File size: 6,924 Bytes
0240893
 
815e563
 
25044b7
35a97c5
35d6ad3
35a97c5
 
 
 
0240893
35d6ad3
 
 
 
35a97c5
 
0240893
35d6ad3
 
 
 
 
 
 
 
 
 
 
0240893
 
35a97c5
 
 
 
 
 
0240893
 
35a97c5
 
 
 
 
12ae02c
35a97c5
 
 
 
 
 
12ae02c
35a97c5
 
 
 
 
 
 
12ae02c
35a97c5
 
 
 
 
 
12ae02c
35a97c5
 
 
 
 
 
 
 
12ae02c
 
35a97c5
12ae02c
 
 
35d6ad3
35a97c5
 
35d6ad3
35a97c5
 
12ae02c
35a97c5
 
 
 
 
 
9c4836d
35a97c5
 
 
12ae02c
35a97c5
 
 
 
 
 
 
 
 
 
 
9c4836d
35a97c5
 
 
 
35d6ad3
 
 
 
 
 
 
 
 
12ae02c
35a97c5
12ae02c
35a97c5
 
dfdecdb
 
12ae02c
dfdecdb
 
 
 
 
 
35d6ad3
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
base_model: meta-llama/Llama-3.1-8B-Instruct
datasets:
- Moreza009/drug_approval_prediction
library_name: peft
license: apache-2.0
pipeline_tag: text-generation
tags:
- medical
- biology
- chemistry
---

[![arXiv](https://img.shields.io/badge/arXiv-2508.18579-b31b1b.svg)](https://arxiv.org/abs/2508.18579)
[![GitHub](https://img.shields.io/badge/GitHub-Code-blue.svg?logo=github)](https://github.com/mohammad-gh009/DrugReasoner)

# DrugReasoner: Interpretable Drug Approval Prediction with a Reasoning-augmented Language Model
DrugReasoner is an AI-powered system for predicting drug approval outcomes using reasoning-augmented Large Language Models (LLMs) and molecular feature analysis. By combining advanced machine learning with interpretable reasoning, DrugReasoner provides transparent predictions that can accelerate pharmaceutical research and development.

## Abstract
Drug discovery is a complex and resource-intensive process, making early prediction of approval outcomes critical for optimizing research investments. While classical machine learning and deep learning methods have shown promise in drug approval prediction, their limited interpretability constraints their impact. Here, we present DrugReasoner, a reasoning-based large language model (LLM) built on the LLaMA architecture and fine-tuned with group relative policy optimization (GRPO) to predict the likelihood of small-molecule approval. DrugReasoner integrates molecular descriptors with comparative reasoning against structurally similar approved and unapproved compounds, generating predictions alongside step-by-step rationales and confidence scores. DrugReasoner achieved robust performance with an AUC of 0.732 and an F1 score of 0.729 on the validation set and 0.725 and 0.718 on the test set, respectively. These results outperformed conventional baselines, including logistic regression, support vector machine, and k-nearest neighbors and had competitive performance relative to XGBoost. On an external independent dataset, DrugReasoner outperformed both baseline and the recently developed ChemAP model, achieving an AUC of 0.728 and an F1-score of 0.774, while maintaining high precision and balanced sensitivity, demonstrating robustness in real-world scenarios. These findings demonstrate that DrugReasoner not only delivers competitive predictive accuracy but also enhances transparency through its reasoning outputs, thereby addressing a key bottleneck in AI-assisted drug discovery. This study highlights the potential of reasoning-augmented LLMs as interpretable and effective tools for pharmaceutical decision-making.

## ✨ Key Features

- **πŸ€– LLM-Powered Predictions**: Utilizes fine-tuned Llama model for drug approval prediction
- **🧬 Molecular Analysis**: Advanced SMILES-based molecular structure analysis
- **πŸ” Interpretable Results**: Clear reasoning behind predictions for better decision-making
- **πŸ“Š Similarity Analysis**: Identifies similar approved/non-approved compounds for context
- **⚑ Flexible Inference**: Support for both single molecule and batch predictions

## Model Details

-  Model Name: DrugReasoner
-  Training Paradigm: Group Relative Policy Optimization (GRPO)
-  Input: SMILES Structure
-  Output: Drug approval prediction + Rational of approval or unapproval + Confidence score
-  Training Libraries: Hugging Face’s transformers, Transformer Reinforcement Learning (TRL), and Parameter-efficient fine-tuning (PEFT)
-  Model Sources: meta-llama/Llama-3.1-8B-Instruct

## How to Get Started with the Model
-  To use **DrugReasoner**, you must first request access to the base model [Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct) on Hugging Face by providing your contact information. Once access is granted, you can run DrugReasoner either through the command-line interface (CLI) or integrate it directly into your Python workflows.

### Prerequisites

- Python 3.8 or higher
- CUDA-compatible GPU (recommended for training and inference)
- Git

### Setup Instructions

1. **Clone the repository**
   ```bash
   git clone https://github.com/mohammad-gh009/DrugReasoner.git
   cd DrugReasoner
   ```

2. **Create and activate virtual environment**

   **Windows:**
   ```bash
   cd src
   python -m venv myenv
   myenv\Scripts\activate
   ```

   **Mac/Linux:**
   ```bash
   cd src
   python -m venv myenv
   source myenv/bin/activate
   ```

3. **Install dependencies**
   ```bash
   pip install -r requirements.txt
   ```
4. **Login to your Huggingface account**
You can use [this](https://huggingface.co/join) instruction on how to make an account and [this](https://huggingface.co/docs/hub/en/security-tokens) on how to get the token

   ```bash
   huggingface-cli login --token YOUR_TOKEN_HERE
   ```
## πŸš€ How to use


**Note:** GPU is required for inference. If unavailable, use our [Kaggle Notebook](https://www.kaggle.com/code/mohammadgh009/drugreasoner).


#### CLI Inference
```bash
python inference.py \
    --smiles "CC(C)CC1=CC=C(C=C1)C(C)C(=O)O" "CC1=CC=C(C=C1)C(=O)O" \
    --output results.csv \
    --top-k 9 \
    --top-p 0.9 \
    --max-length 4096 \
    --temperature 1.0
```

#### Python API Usage
```python
from inference import DrugReasoner

predictor = DrugReasoner()

results = predictor.predict_molecules(
    smiles_list=["CC(C)CC1=CC=C(C=C1)C(C)C(=O)O"],
    save_path="results.csv",
    print_results=True,
    top_k=9,
    top_p=0.9,
    max_length=4096,
    temperature=1.0
)
```

## πŸ“Š Dataset & Model

- **Dataset**: [![Hugging Face Dataset](https://img.shields.io/badge/πŸ€—%20Dataset-drug_approval_prediction-yellow)](https://huggingface.co/datasets/Moreza009/drug_approval_prediction)
- **Model**: [![Hugging Face Model](https://img.shields.io/badge/πŸ€—%20Model-Llama--DrugReasoner-orange)](https://huggingface.co/Moreza009/Llama-DrugReasoner)

## πŸ“ˆ Performance

DrugReasoner demonstrates superior performance compared to traditional baseline models across multiple evaluation metrics. Detailed performance comparisons are available in our [paper](https://arxiv.org/abs/2508.18579).

## Citation

If you use DrugReasoner in your research, please cite our work:

```
@misc{ghaffarzadehesfahani2025drugreasonerinterpretabledrugapproval,
      title={DrugReasoner: Interpretable Drug Approval Prediction with a Reasoning-augmented Language Model}, 
      author={Mohammadreza Ghaffarzadeh-Esfahani and Ali Motahharynia* and Nahid Yousefian and Navid Mazrouei and Jafar Ghaisari and Yousof Gheisari},
      year={2025},
      eprint={2508.18579},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2508.18579}, 
}
```

## πŸ“œ License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.

---

<div align="center">
  <strong>Accelerating drug discovery through AI-powered predictions</strong>
  <br><br>
</div>