Text Generation
PEFT
Safetensors
rag-gym
retrieval-augmented-generation
agent
lora
process-supervision
search-agent
conversational
Instructions to use RAG-Gym/Direct-MedQA-DPO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use RAG-Gym/Direct-MedQA-DPO with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct") model = PeftModel.from_pretrained(base_model, "RAG-Gym/Direct-MedQA-DPO") - Notebooks
- Google Colab
- Kaggle
Add model card
Browse files
README.md
CHANGED
|
@@ -1,202 +1,74 @@
|
|
| 1 |
---
|
| 2 |
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
|
| 3 |
library_name: peft
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
|
|
|
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
-
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
-
##
|
| 37 |
|
| 38 |
-
|
| 39 |
|
| 40 |
-
##
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
-
|
| 56 |
-
[More Information Needed]
|
| 57 |
-
|
| 58 |
-
## Bias, Risks, and Limitations
|
| 59 |
-
|
| 60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
-
|
| 62 |
-
[More Information Needed]
|
| 63 |
-
|
| 64 |
-
### Recommendations
|
| 65 |
-
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
| 200 |
-
### Framework versions
|
| 201 |
-
|
| 202 |
-
- PEFT 0.14.0
|
|
|
|
| 1 |
---
|
| 2 |
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
|
| 3 |
library_name: peft
|
| 4 |
+
license: other
|
| 5 |
+
license_name: ncbi-public-domain
|
| 6 |
+
license_link: https://github.com/RAG-Gym/RAG-Gym/blob/main/LICENSE
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
tags:
|
| 9 |
+
- rag-gym
|
| 10 |
+
- retrieval-augmented-generation
|
| 11 |
+
- agent
|
| 12 |
+
- peft
|
| 13 |
+
- lora
|
| 14 |
+
- process-supervision
|
| 15 |
+
- search-agent
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# Direct-MedQA-DPO
|
| 19 |
|
| 20 |
+
This is the **DPO** actor for the **Direct** agent on **MedQA**, released as part of [RAG-Gym](https://github.com/RAG-Gym/RAG-Gym). Direct is a baseline agent used for comparison in RAG-Gym. It is a single-step agent that answers directly without intermediate reasoning or retrieval. This checkpoint was trained with direct preference optimization on process-level preference pairs.
|
| 21 |
|
| 22 |
+
- **Base model:** [`meta-llama/Meta-Llama-3.1-8B-Instruct`](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct)
|
| 23 |
+
- **Agent architecture:** Direct (a baseline agent used for comparison in RAG-Gym)
|
| 24 |
+
- **Task / dataset:** MedQA (medical multiple-choice question answering in the USMLE style)
|
| 25 |
+
- **Training method:** direct preference optimization (DPO)
|
| 26 |
+
- **Adapter:** PEFT LoRA (r=256, alpha=512), task type `CAUSAL_LM`
|
| 27 |
+
- **Precision:** bf16
|
| 28 |
|
| 29 |
+
## Intended use
|
| 30 |
|
| 31 |
+
- Act as the reasoning/search policy for the Direct agent on MedQA-style (medical multiple-choice question answering in the USMLE style) tasks within RAG-Gym.
|
| 32 |
+
- Can be run with zero-shot inference or, together with the matching PRM critic, with critic-guided (Best-of-N) inference.
|
| 33 |
|
| 34 |
+
This model is intended for research on process-supervised retrieval-augmented generation. It is not intended for clinical decision-making or other high-stakes use.
|
| 35 |
|
| 36 |
+
## How to use
|
| 37 |
|
| 38 |
+
Load the LoRA adapter on top of the base model:
|
| 39 |
|
| 40 |
+
```python
|
| 41 |
+
import torch
|
| 42 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 43 |
+
from peft import PeftModel
|
| 44 |
|
| 45 |
+
base = "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
| 46 |
+
tokenizer = AutoTokenizer.from_pretrained(base)
|
| 47 |
+
model = AutoModelForCausalLM.from_pretrained(base, torch_dtype=torch.bfloat16)
|
| 48 |
+
model = PeftModel.from_pretrained(model, "RAG-Gym/Direct-MedQA-DPO")
|
| 49 |
+
```
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
For full usage within the agent framework (environment setup, inference, and critic-guided Best-of-N selection), see the [RAG-Gym repository](https://github.com/RAG-Gym/RAG-Gym).
|
| 52 |
|
| 53 |
+
## Training
|
| 54 |
|
| 55 |
+
Fine-tuned from `meta-llama/Meta-Llama-3.1-8B-Instruct` on MedQA process-reward data using direct preference optimization (DPO) with the TRL library. Adaptation uses LoRA (rank 256, alpha 512, task type `CAUSAL_LM`) in bf16. The training code and full configuration are available in the [RAG-Gym repository](https://github.com/RAG-Gym/RAG-Gym).
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
## Limitations
|
| 58 |
|
| 59 |
+
The model is trained on MedQA-style data and is intended for research use within RAG-Gym. Outputs may be inaccurate or unsupported by retrieved evidence and should not be relied upon for high-stakes decisions. As an 8B-parameter model, it requires a CUDA-enabled GPU to run efficiently.
|
| 60 |
|
| 61 |
+
## License
|
| 62 |
|
| 63 |
+
Public Domain Notice (U.S. Government Work, NCBI). See the [LICENSE](https://github.com/RAG-Gym/RAG-Gym/blob/main/LICENSE) in the repository. Please cite the authors when using this material.
|
| 64 |
|
| 65 |
+
## Citation
|
| 66 |
|
| 67 |
+
```bibtex
|
| 68 |
+
@article{xiong2025raggym,
|
| 69 |
+
title={RAG-Gym: Optimizing Reasoning and Search Agents with Process Supervision},
|
| 70 |
+
author={Guangzhi Xiong and Qiao Jin and Xiao Wang and Yin Fang and Haolin Liu and Yifan Yang and Fangyuan Chen and Zhixing Song and Dengyu Wang and Minjia Zhang and Zhiyong Lu and Aidong Zhang},
|
| 71 |
+
journal={arXiv preprint arXiv:2502.13957},
|
| 72 |
+
year={2025}
|
| 73 |
+
}
|
| 74 |
+
```
|
|
|
|
|
|
|
|
|
|
|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