This code is our implementation of paper An Abductive Learning Framework For Automatically Solving Math Problems, which is based on the famous NLP framework AllenNLP.
Citation: "Yangyang Hu and Yang Yu. Enhancing neural mathematical reasoning by abductive combination with symbolic library. In: ICML 2020 Workshop on Bridge Between Perception and Reasoning: Graph Neural Networks & Beyond, Vienna, Austria, 2020". https://arxiv.org/abs/2203.14487
Video presentation: https://agit.ai/Polixir/ABL-sym
Online demonstration: http://math.polixir.ai/
pip install -r requirements.txtWe experiment on the Mathematics Dataset. The data set is preprocessed into the following form, where one line is the description of the problem, the next line is separated by ###, the first half is the answer, the second half is the program(may not have).
What is the first derivative of 5018w**4 + 15w3 + 15w + 12680810 wrt w?
20072w3 + 45*w**2 + 15###pos#3 pos#8 pos#6 argc#3 api#diff extra#@end@
Calculate the remainder when 7687189 is divided by 3441.
3436###pos#8 pos#4 argc#2 api#Mod extra#@end@
We release 3 models(extraction code: eg39)
To execute program-searching procedure, use warm_up_search.py, program_search.py, curriculum_search.py.
During the execution process, the searched programs need to be used to train the program-searching model,
and the programs generated by the search model will further help the search process.
For the training process, see the training section below.
python dmmath/search/warm_up_search.py \
--data ...
python dmmath/search/program_search.py \
--data ...
python dmmath/search/curriculum_search.py \
--model .. \
--data ...To train ABL-sym model, use train_dist_transformer.py, the workdir directory should include experiment.config, which is used for training configuration.
python dmmath/nlp/train_dist_transformer.py \
---workdir ... \
--local_rank ...To predict results, use predict_mix_transformer.py, the data should be preprocessed as above.
python dmmath/nlp/predict_mix_transformer.py \
--model ... \
--data ... \
--result_dir ... \
--target_limit_decode_steps ... \
--batch_size ... \
--cuda ...To evaluate ABL-Sym on Mathematics Dataset, use evaluate_mix_transformer.py, the result_path is the prediction result path using predict_mix_transformer.py:
python dmmath/nlp/evaluate_mix_transformer.py \
--result ...