RefModel is a tool that leverages foundation models to automatically detect code refactoring operations in program transformations. By default, it analyzes both the original and transformed versions of a program to identify refactorings. However, when dealing with large programs that exceed the model’s context window, RefModel can alternatively operate by analyzing only the code differences (diffs) introduced by the transformation.
This repository contains the source code, datasets, and results related to the model evaluations:
-
Demonstrations –
docs/
Visual assets including GIFs and videos that demonstrate how the model works in both Full and Small Programs and Diffs of Large Programs. -
Usage Instructions –
RefModel/Step-by-step guides on how to use the model. -
Dataset –
dataset/Contains the full datasets used in the evaluation: Full and Small Programs and Diffs of Large Programs. -
Performance Results –
evaluation/Contains precision and recall metrics using different models. We compare the results of our RefModel against tools like RefactoringMiner, RefDiff, and ReExtractor+ across both datasets.
RefModel currently supports 19 distinct refactoring types, with an architecture designed for easy extension by simply adding a natural language definition for each new refactoring in a text file.
- Add Method Parameter
- Remove Method Parameter
- Rename Method
- Rename Class
- Rename Package
- Rename Field
- Extract Class
- Extract Superclass
- Inline Method
- Pull Up Method
- Push Down Method
- Pull Up Field
- Push Down Field
- Inline Class
- Extract Interface
- Move Method
- Move Field
- Replace Magic Number with Constant
- Encapsulate Field
You can run RefModel in two ways:
- Terminal: Use the command-line script located in
./RefModel. - Notebook: Use the Colab notebook available in
./RefModel/notebook.
If you are using RefModel in your research, please cite the following paper:
@inproceedings{refModel2025,
author = {Pedro Simões and Rohit Gheyi and Rian Melo and Jonhnanthan Oliveira and Márcio Ribeiro and Wesley K. G. Assunção},
title = {RefModel: Detecting Refactorings using Foundation Models},
booktitle = {Brazilian Symposium on Software Engineering},
year = {2025},
url = {https://arxiv.org/abs/2507.11346}
}The structure is shown below:
├── dataset/ # CSV datasets used as input
│ ├── full-and-small-programs.csv # dataset Full and Small Programs
│ └── diff-of-large-programs.csv # dataset Diff of Large Programs
│
├── docs/ # Visual documentation and demo media
│ ├── full-and-small-programs.gif # GIF – Full & Small Programs
│ ├── diff-of-large-programs.gif # GIF – Diffs of Large Programs
│ ├── full-and-small-programs.mp4 # video – Full & Small Programs
│ └── diff-of-large-programs.mp4 # video – Diffs of Large Programs
│
├── evaluation/ # Evaluation outputs from models
│ ├── full-and-small-programs/ # Metrics for full and small programs
│ │ └── results.csv # Precision/recall for each model
│ │
│ └── diff-of-large-programs/ # Metrics for large diff-only programs
│ ├── golang/ # Go language
│ │ ├── gemini-2.5-pro.pdf # Gemini 2.5 Pro results
│ │ └── o4-mini-high.pdf # O4-mini-high results
│ │
│ ├── java/ # Java language
│ │ ├── gemini-2.5-pro.pdf # Gemini 2.5 Pro results
│ │ └── o4-mini-high.pdf # O4-mini-high results
│ │
│ ├── python/ # Python language
│ │ ├── gemini-2.5-pro.pdf # Gemini 2.5 Pro results
│ │ └── o4-mini-high.pdf # O4-mini-high results
│ │
│ └── results.csv # Aggregated metrics across all models
│
├── RefModel/ # Main source code and configuration
│ ├── RefModel.py # Core script to run the tool
│ ├── notebook/
│ │ └── RefModel.ipynb # notebook
│ │
│ ├── requirements.txt # Required Python dependencies
│ ├── README.md # Documentation for the RefModel module
│ │
│ ├── resources/ # definitions
│ │ └── refactoring_definitions.txt # List of predefined refactoring types
│ │
│ └── data/ # Folder for generated I/O files
│ ├── input/ # CSV files to be processed
│ │ └── your.csv # Example input file
│ │
│ └── output/ # Output results from execution
│
├── README.md # Project overview and instructions
└── .gitignore # Files ignored by Git
The screencast below shows the process running:
The following screencast demonstrates how to use RefModel to analyze both the original and transformed versions of a small program to detect refactorings.
The following screencast demonstrates how to use RefModel to analyze the code differences (diffs) introduced by transformations applied to larger programs.


