This repository contains the code, data, and results for a research project on math query recommendation using large language models (LLMs). The project introduces and evaluates a benchmark dataset and a set of fine-tuned and pretrained LLM baselines.
The experiments focus on three model families:
- LLaMA
- Mistral
- Qwen
All models are trained and evaluated using consistent data splits and evaluation protocols.
The repository is organized as follows:
data/: Train, validation, and test splitsscripts/: Fine-tuning and pretrained generation scriptsevaluation/: Evaluation scriptsresults/: Evaluation outputs and score comparisons
This repository provides baseline results for the benchmark using three LLM families (LLaMA, Mistral, Qwen). For each model, we report:
- Pretrained performance (no task-specific training)
- Fine-tuned performance on the benchmark training data
Evaluation is performed on the held-out test set, and results are reported separately for pretrained and fine-tuned models, along with consolidated comparison files.
git clone https://github.com/usm-aiir/math-query-recommendation.git
cd math-query-recommendation
pip install -r requirements.txt
Generate math query recommendations using pretrained models:
python scripts/pretrained/LLaMA_MQS.py
python scripts/pretrained/Mistral_MQS.py
python scripts/pretrained/Qwen_MQS.py
Outputs are written to the corresponding results/<model>/pt/ directory.
Run fine-tuning for each model:
python scripts/finetuning/finetune_LLaMA_MQS.py
python scripts/finetuning/finetune_Mistral_MQS.py
python scripts/finetuning/finetune_Qwen_MQS.py
Fine-tuning outputs (checkpoints and final models) are saved under models/<model>/.
Inference outputs are written to the corresponding results/<model>/ft/ directory.
After generating outputs, change the configuration in the evaluation script (evaluation/compare_ft_pt_outputs.py) for the current model. Then, run the script to compute metrics and comparisons.
python evaluation/compare_ft_pt_outputs.py
Evaluation results are stored in results/<model>/.
From ARQMath resources (https://www.cs.rit.edu/~dprl/ARQMath/arqmath-resources.html):
- Download the official task 1 qrel files for ARQMath 1 to 3
- Download the Posts file, version 1.3 (Posts.V1.3.xml)
- Put these files in the /data/ directory
Then, run the first biencoder reranker script (evaluation/biencoder_reranker_for_ground_truth.py) to get the ground truth rankings. Results will be written to results/.
python evaluation/biencoder_reranker_for_ground_truth.py
Finally, change the configuration in the second biencoder reranker script (evaluation/biencoder_reranker_for_generated_results.py) for the current model. Then, run the script. Results will be written to results/<model>/<training>.
python evaluation/biencoder_reranker_for_generated_results.py