Skip to content
usm-aiirPublic

About

A repository for research done on mathematical query recommendation at the University of Southern Maine's Artificial Intelligence and Information Retrieval (AIIR) Laboratory.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MathRec

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.


Repository Overview

The repository is organized as follows:

  • data/: Train, validation, and test splits
  • scripts/: Fine-tuning and pretrained generation scripts
  • evaluation/: Evaluation scripts
  • results/: Evaluation outputs and score comparisons

Experiments

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.


Setup

git clone https://github.com/usm-aiir/math-query-recommendation.git
cd math-query-recommendation
pip install -r requirements.txt

Usage

Pretrained Inference

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.


Fine-Tuning (with inference)

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.


Evaluation

To compute metrics

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>/.

To compute retrieval results

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

About

A repository for research done on mathematical query recommendation at the University of Southern Maine's Artificial Intelligence and Information Retrieval (AIIR) Laboratory.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages