LLM-based pipeline for generating and evaluating equations from scientific text.
Jupyter Notebook
0
8 commits
updated Aug 5, 2025
This repository contains the code and data supporting my master's thesis, which investigates the capabilities of large language models (LLMs) in generating mathematical equations from scientific text.
In this work, we introduce a novel framework that explores large language models (LLMs) for equation generation from scientific context. We leverage LLMs' mathematical reasoning abilities and scientific domain knowledge to infer missing equations directly from surrounding text in scientific literature. The framework casts equation generation as a contextual translation task and incorporates prompt engineering to guide model behavior. To evaluate output quality, we propose an evaluation framework that combines standard text similarity metrics, structure-aware measures, and an LLM-as-a-Judge methodology. Experiments across multiple LLMs and metrics show that current models can generate syntactically plausible equations but often fall short on deep semantic alignment. Our analysis highlights the limitations of existing automatic metrics and introduces LLM-based judgment as a promising complementary approach for evaluating math reasoning tasks.

# Clone the repository
git clone https://github.com/imxiaoxiaohh/master_thesis_project.git
cd math-equation-generation
# Install dependencies
pip install -r requirements.txt
id, titleequations: list of objects with
equation idcontext (surrounding text)description (variable/explanation, optional)EQ_latex (list of LaTeX strings)Generation/main.pypython Generation/main.py --llm <llm_name> [--fresh] [--papers <paper_id1> <paper_id2> ...] [--status] [--list]
Usage:
--llm: LLM to use (see below for options)
--fresh: Ignore previous results and start anew
--papers: Only generate for specific paper IDs
--status: Show current progress
--list: List available LLMs
Supported LLMs:
gpt-o1-mini, gpt-4o-mini, gpt-4.1-mini, gpt-4.1deepseek-R1llama3.3-70B, qwen3-235B, qwen-qwq-32B <latex> ... </latex>
<description> ... </description>
Generation/outputs/<llm_name>_results.json.Evaluation/generate_evaluation_table.pyEvaluation/data/raw_csv/Script: Evaluation/metrics_evaluation.py
Metrics: TeXBLEU, Levenshtein distance, sequence similarity, ROUGE-L, tree edit distance, etc.
Output: Metrics CSV in Evaluation/data/result_csv/
Evaluation/llm_as_judge.pyEvaluation/data/result_csv/Before running anything, set the required API keys as environment variables.
$env:OPENAI_API_KEY="your-openai-key"
$env:DeepSeek_API_Key="your-deepseek-key"
$env:TOGETHER_API_KEY="your-together-key"
python Generation/main.py --llm gpt-4.1
python Evaluation/generate_evaluation_table.py
python Evaluation/metrics_evaluation.py --input_csv <your_csv>
python Evaluation/llm_as_judge.py --input_csv <your_csv>
LLM-based pipeline for generating and evaluating equations from scientific text.
Jupyter Notebook
0
8 commits
updated Aug 5, 2025
This repository contains the code and data supporting my master's thesis, which investigates the capabilities of large language models (LLMs) in generating mathematical equations from scientific text.
In this work, we introduce a novel framework that explores large language models (LLMs) for equation generation from scientific context. We leverage LLMs' mathematical reasoning abilities and scientific domain knowledge to infer missing equations directly from surrounding text in scientific literature. The framework casts equation generation as a contextual translation task and incorporates prompt engineering to guide model behavior. To evaluate output quality, we propose an evaluation framework that combines standard text similarity metrics, structure-aware measures, and an LLM-as-a-Judge methodology. Experiments across multiple LLMs and metrics show that current models can generate syntactically plausible equations but often fall short on deep semantic alignment. Our analysis highlights the limitations of existing automatic metrics and introduces LLM-based judgment as a promising complementary approach for evaluating math reasoning tasks.

# Clone the repository
git clone https://github.com/imxiaoxiaohh/master_thesis_project.git
cd math-equation-generation
# Install dependencies
pip install -r requirements.txt
id, titleequations: list of objects with
equation idcontext (surrounding text)description (variable/explanation, optional)EQ_latex (list of LaTeX strings)Generation/main.pypython Generation/main.py --llm <llm_name> [--fresh] [--papers <paper_id1> <paper_id2> ...] [--status] [--list]
Usage:
--llm: LLM to use (see below for options)
--fresh: Ignore previous results and start anew
--papers: Only generate for specific paper IDs
--status: Show current progress
--list: List available LLMs
Supported LLMs:
gpt-o1-mini, gpt-4o-mini, gpt-4.1-mini, gpt-4.1deepseek-R1llama3.3-70B, qwen3-235B, qwen-qwq-32B <latex> ... </latex>
<description> ... </description>
Generation/outputs/<llm_name>_results.json.Evaluation/generate_evaluation_table.pyEvaluation/data/raw_csv/Script: Evaluation/metrics_evaluation.py
Metrics: TeXBLEU, Levenshtein distance, sequence similarity, ROUGE-L, tree edit distance, etc.
Output: Metrics CSV in Evaluation/data/result_csv/
Evaluation/llm_as_judge.pyEvaluation/data/result_csv/Before running anything, set the required API keys as environment variables.
$env:OPENAI_API_KEY="your-openai-key"
$env:DeepSeek_API_Key="your-deepseek-key"
$env:TOGETHER_API_KEY="your-together-key"
python Generation/main.py --llm gpt-4.1
python Evaluation/generate_evaluation_table.py
python Evaluation/metrics_evaluation.py --input_csv <your_csv>
python Evaluation/llm_as_judge.py --input_csv <your_csv>