RLDBF: Enhancing LLMs Via Reinforcement Learning With DataBase FeedBack

Weichen Dai, Zijie Dai, Zhijie Huang, Yixuan Pan, Xinhe Li, Yi Zhou, Ji Qi, Jiang WuarXiv 2025 · DOI

Abstract

Large Language Models (LLMs) often struggle with the precise, structured data required for specialized scientific domains like chemistry. We present RLDBF (Reinforcement Learning with DataBase Feedback), a novel framework that leverages structured scientific databases to automate the training and alignment of LLMs. By utilizing database values as ground-truth preference labels, RLDBF significantly enhances a model's ability to predict molecular properties and reason through complex chemical tasks. Our approach eliminates the need for expensive human expert annotation while achieving superior performance on specialized benchmarks.

Introduction

While LLMs excel at processing unstructured text, they remain "numerically insensitive" when faced with structured scientific data. In chemistry, molecular structures are often represented as SMILES strings, where minor character changes can correspond to drastic shifts in physical properties. Current models frequently fail to capture these fine-grained relationships, treating scientific data as mere text to be predicted rather than structured information with underlying logic. Furthermore, aligning models via Reinforcement Learning from Human Feedback (RLHF) is prohibitively expensive in chemistry, requiring PhD-level expertise for data labeling.

The RLDBF Framework

To bridge this gap, we propose a three-stage pipeline consisting of Continual Pre-training (CPT), Supervised Fine-Tuning (SFT), and a novel Reinforcement Learning (RL) stage driven by database feedback.

The RLDBF framework architecture, illustrating the flow from template generation and property extraction to model training.

The process begins with Template Generation, where GPT-4o creates diverse Q&A templates to convert structured database entries into natural language. In the Property Extraction phase, the PubChem database serves as an "oracle," providing ground-truth values for molecular properties. These components feed into the Data Construction phase, generating Q&A and preference data for model training.

Database-Driven Reinforcement Learning

The core innovation of RLDBF lies in its use of Direct Preference Optimization (DPO) with strategic preference pairs. To address numerical blindness, we identify the K-most similar molecules to a target compound. We then construct preference pairs where the model must distinguish the correct property value of a target molecule from the value of its structural "look-alike." This contrastive approach forces the model to learn the specific structural features that drive chemical properties. Additionally, we integrated a reasoning component that allows the model to self-correct by comparing its internal logic against database references.

Experimental Setup and Datasets

Our primary data source is PubChem, from which we extracted a training subset of 10,000 molecules focusing on properties such as Hydrogen Bond counts, XLogP, and Molecular Weight. To evaluate the model, we developed a Custom 4-Level Test Set with increasing difficulty:

  • Level 1: Basic numerical perturbations.
  • Level 4: Distractors chosen from the most structurally similar molecules, representing the highest difficulty. We also benchmarked RLDBF on ChemBench, a comprehensive suite for diverse chemistry tasks including name conversion and property prediction.

Key Results and Performance

RLDBF demonstrates remarkable consistency and superior generalization across all difficulty levels. On the most challenging Level 4 tasks, RLDBF outperformed GPT-4o-mini by +20.5% and surpassed specialized domain models like ChemLLM.

Performance comparison of RLDBF against various baseline models across four levels of difficulty on the PubChem test set.

Beyond property prediction, RLDBF showed emergent reasoning capabilities. On the ChemBench Mol2Caption task, it achieved a score of 93.3, indicating a superior ability to map structural features to semantic descriptions. Furthermore, when used for regression tasks via a simple MLP head, RLDBF-enhanced embeddings achieved a 0.160 RMSE on Coulombic efficiency prediction, significantly outperforming the base Llama-3 model.

Conclusion

RLDBF proves that structured databases can serve as high-density information sources for training scientifically-aware LLMs. By using a contrastive "nearest neighbor" approach in the RL stage, we can teach models the nuances of chemical structures without human intervention. Future work will focus on scaling this approach to the full PubChem database and extending the property scope to include biological activity and complex reaction pathways.

Summary updated

BibTeX
@misc{dai2025rldbf,
  author = {Weichen Dai and Zijie Dai and Zhijie Huang and Yixuan Pan and Xinhe Li and Xi Li and Yi Zhou and Ji Qi and Jiang Wu},
  title = {{RLDBF: Enhancing LLMs Via Reinforcement Learning With DataBase FeedBack}},
  year = {2025},
  eprint = {2504.03713},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.03713},
}
Figure