Text Generation
Transformers
PyTorch
English
llama
lean4
statement-autoformalization
formal-mathematics
text-generation-inference
Instructions to use purewhite42/rautoformalizer_ra_deepseek with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use purewhite42/rautoformalizer_ra_deepseek with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="purewhite42/rautoformalizer_ra_deepseek")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("purewhite42/rautoformalizer_ra_deepseek") model = AutoModelForCausalLM.from_pretrained("purewhite42/rautoformalizer_ra_deepseek", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use purewhite42/rautoformalizer_ra_deepseek with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "purewhite42/rautoformalizer_ra_deepseek" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "purewhite42/rautoformalizer_ra_deepseek", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/purewhite42/rautoformalizer_ra_deepseek
- SGLang
How to use purewhite42/rautoformalizer_ra_deepseek with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "purewhite42/rautoformalizer_ra_deepseek" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "purewhite42/rautoformalizer_ra_deepseek", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "purewhite42/rautoformalizer_ra_deepseek" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "purewhite42/rautoformalizer_ra_deepseek", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use purewhite42/rautoformalizer_ra_deepseek with Docker Model Runner:
docker model run hf.co/purewhite42/rautoformalizer_ra_deepseek
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- hoskinson-center/proofnet
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
base_model:
|
| 8 |
+
- internlm/internlm2-math-7b
|
| 9 |
+
- deepseek-ai/deepseek-math-7b-base
|
| 10 |
+
pipeline_tag: text-generation
|
| 11 |
+
library_name: transformers
|
| 12 |
+
tags:
|
| 13 |
+
- lean4
|
| 14 |
+
- statement-autoformalization
|
| 15 |
+
- formal-mathematics
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
<div align="center">
|
| 19 |
+
<h1 style="font-size: 1.5em;">[ICLR'25 Spotlight] Rethinking and Improving Autoformalization: Towards a Faithful Metric and a Dependency Retrieval-based Approach</h1>
|
| 20 |
+
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;">
|
| 21 |
+
<a href="https://choosealicense.com/licenses/apache-2.0/"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License: Apache 2.0"></a>
|
| 22 |
+
<a href="https://github.com/leanprover-community/mathlib4"><img src="https://img.shields.io/badge/Lean-4-orange" alt="Lean 4"></a>
|
| 23 |
+
<a href="https://github.com/Purewhite2019/rethinking_autoformalization"><img src="https://img.shields.io/badge/GitHub-%23121011.svg?logo=github&logoColor=white" alt="GitHub"></a>
|
| 24 |
+
</div>
|
| 25 |
+
<h2>Qi Liu, Xinhao Zheng, Xudong Lu, Qinxiang Cao, Junchi Yan* (* indicates Correspondence author)</h2>
|
| 26 |
+
<h2>Sch. of Computer Science & Sch. of Artificial Intelligence, Shanghai Jiao Tong University</h2>
|
| 27 |
+
</div>
|
| 28 |
+
|
| 29 |
+
Please refer to the [📺GitHub repo](https://github.com/Purewhite2019/rethinking_autoformalization) and
|
| 30 |
+
[📃Paper](https://openreview.net/pdf?id=hUb2At2DsQ) for more details.
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
## 📈 Performance
|
| 34 |
+
| | **Benchmark** | **ProofNet** | **Con-NF** |
|
| 35 |
+
|:---------------------:|:--------------------:|--------------|------------|
|
| 36 |
+
| **InternLM2-Math 7B** | Rautoformalizer (-R) | 16.58% | 4.58% |
|
| 37 |
+
| | RAutoformalizer | 18.18% | 16.86% |
|
| 38 |
+
| | Rautoformalizer (+R) | 31.28% | 55.36% |
|
| 39 |
+
| **DeepseekMath 7B** | Rautoformalizer (-R) | 15.24% | 4.27% |
|
| 40 |
+
| | RAutoformalizer | 17.91% | 15.30% |
|
| 41 |
+
| | Rautoformalizer (+R) | 32.62% | 59.00% |
|
| 42 |
+
|
| 43 |
+
## ⚙️ Usage
|
| 44 |
+
### w/o Dependency Retrieval
|
| 45 |
+
- [🤗`purewhite42/rautoformalizer_nora_deepseek`](https://huggingface.co/purewhite42/rautoformalizer_nora_deepseek): w/o dependency retrieval, SFTed from [🤗`deepseek-ai/deepseek-math-7b-base`](https://huggingface.co/deepseek-ai/deepseek-math-7b-base)
|
| 46 |
+
- [🤗`purewhite42/rautoformalizer_nora_internlm`](https://huggingface.co/purewhite42/rautoformalizer_nora_internlm): w/o dependency retrieval, SFTed from [🤗`internlm/internlm2-math-7b`](https://huggingface.co/internlm/internlm2-math-7b)
|
| 47 |
+
|
| 48 |
+
```shell
|
| 49 |
+
python -m autoformalizer.autoformalize_vllm_passk \
|
| 50 |
+
--port ... \ # Can be arbitrarily set (should avoid conflict)
|
| 51 |
+
--trust-remote-code \
|
| 52 |
+
--enable-prefix-caching \
|
| 53 |
+
--model /path/to/model \
|
| 54 |
+
--mathlib_root ... \ # Path to Mathlib 4 or path to Con(NF)
|
| 55 |
+
--eval_set ... \ # {proofnet, connf}
|
| 56 |
+
--working_root /path/to/output/results \
|
| 57 |
+
--dataset_root ./data/ \
|
| 58 |
+
--repl_root /path/to/repl \
|
| 59 |
+
--try_num 8 \
|
| 60 |
+
--num_concurrency 8 \
|
| 61 |
+
--temperature 0.0;
|
| 62 |
+
```
|
| 63 |
+
### RAutofromalizer (w/ Dependency Retrieval)
|
| 64 |
+
- [🤗`purewhite42/rautoformalizer_ra_deepseek`](https://huggingface.co/purewhite42/rautoformalizer_ra_deepseek): w/ dependency retrieval (`dependency_retriever_f`), SFTed from [🤗`deepseek-ai/deepseek-math-7b-base`](https://huggingface.co/deepseek-ai/deepseek-math-7b-base)
|
| 65 |
+
- [🤗`purewhite42/rautoformalizer_ra_internlm`](https://huggingface.co/purewhite42/rautoformalizer_ra_internlm): w/ dependency retrieval (`dependency_retriever_f`), SFTed from [🤗`internlm/internlm2-math-7b`](https://huggingface.co/internlm/internlm2-math-7b)
|
| 66 |
+
```shell
|
| 67 |
+
python -m autoformalizer.autoformalize_vllm_w_ra_passk \
|
| 68 |
+
--port ... \ # Can be arbitrarily set (should avoid conflict)
|
| 69 |
+
--trust-remote-code \
|
| 70 |
+
--enable-prefix-caching \
|
| 71 |
+
--model /path/to/model \
|
| 72 |
+
--retrieval_result_path /path/to/retrieval/result \
|
| 73 |
+
--mathlib_root ... \ # Path to Mathlib 4 or path to Con(NF)
|
| 74 |
+
--eval_set ... \ # {proofnet, connf}
|
| 75 |
+
--working_root /path/to/output/results \
|
| 76 |
+
--dataset_root ./data/ \
|
| 77 |
+
--repl_root /path/to/repl \
|
| 78 |
+
--try_num 8 \
|
| 79 |
+
--num_concurrency 8 \
|
| 80 |
+
--temperature 0.0;
|
| 81 |
+
```
|
| 82 |
+
### Oracle RAutoformalizer (w/ Ground-truth Dependencies)
|
| 83 |
+
- [🤗`purewhite42/rautoformalizer_gtra_deepseek`](https://huggingface.co/purewhite42/rautoformalizer_gtra_deepseek): w/ oracle dependency retrieval, SFTed from [🤗`deepseek-ai/deepseek-math-7b-base`](https://huggingface.co/deepseek-ai/deepseek-math-7b-base)
|
| 84 |
+
- [🤗`purewhite42/rautoformalizer_gtra_internlm`](https://huggingface.co/purewhite42/rautoformalizer_gtra_internlm): w/ oracle dependency retrieval, SFTed from [🤗`internlm/internlm2-math-7b`](https://huggingface.co/internlm/internlm2-math-7b)
|
| 85 |
+
```shell
|
| 86 |
+
python -m autoformalizer.autoformalize_vllm_w_gt_passk \
|
| 87 |
+
--port ... \ # Can be arbitrarily set (should avoid conflict)
|
| 88 |
+
--trust-remote-code \
|
| 89 |
+
--enable-prefix-caching \
|
| 90 |
+
--model /path/to/model \
|
| 91 |
+
--mathlib_root ... \ # Path to Mathlib 4 or path to Con(NF)
|
| 92 |
+
--eval_set ... \ # {proofnet, connf}
|
| 93 |
+
--working_root /path/to/output/results \
|
| 94 |
+
--dataset_root ./data/ \
|
| 95 |
+
--repl_root /path/to/repl \
|
| 96 |
+
--try_num 8 \
|
| 97 |
+
--num_concurrency 8 \
|
| 98 |
+
--temperature 0.0;
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
## 📚 Citation
|
| 102 |
+
If you find our work useful in your research, please cite
|
| 103 |
+
```bibtex
|
| 104 |
+
@inproceedings{
|
| 105 |
+
liu2025rethinking,
|
| 106 |
+
title={Rethinking and improving autoformalization: towards a faithful metric and a Dependency Retrieval-based approach},
|
| 107 |
+
author={Qi Liu and Xinhao Zheng and Xudong Lu and Qinxiang Cao and Junchi Yan},
|
| 108 |
+
booktitle={The Thirteenth International Conference on Learning Representations},
|
| 109 |
+
year={2025},
|
| 110 |
+
url={https://openreview.net/forum?id=hUb2At2DsQ}
|
| 111 |
+
}
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
# License
|
| 115 |
+
This project is released under the Apache 2.0 license. Please see the [LICENSE](https://github.com/Purewhite2019/rethinking_autoformalization/blob/main/LICENSE) file for more information.
|
| 116 |
+
|
| 117 |
+
# Contact
|
| 118 |
+
Feel free to discuss the paper/data/code with us through issues/emails!
|
| 119 |
+
- Qi Liu: purewhite@sjtu.edu.cn
|