Instructions to use stepfun-ai/StepFun-Formalizer-32B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use stepfun-ai/StepFun-Formalizer-32B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="stepfun-ai/StepFun-Formalizer-32B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("stepfun-ai/StepFun-Formalizer-32B") model = AutoModelForCausalLM.from_pretrained("stepfun-ai/StepFun-Formalizer-32B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use stepfun-ai/StepFun-Formalizer-32B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "stepfun-ai/StepFun-Formalizer-32B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "stepfun-ai/StepFun-Formalizer-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/stepfun-ai/StepFun-Formalizer-32B
- SGLang
How to use stepfun-ai/StepFun-Formalizer-32B 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 "stepfun-ai/StepFun-Formalizer-32B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "stepfun-ai/StepFun-Formalizer-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "stepfun-ai/StepFun-Formalizer-32B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "stepfun-ai/StepFun-Formalizer-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use stepfun-ai/StepFun-Formalizer-32B with Docker Model Runner:
docker model run hf.co/stepfun-ai/StepFun-Formalizer-32B

StepFun-Formalizer: Unlocking the Autoformalization Potential of LLMs through Knowledge-Reasoning Fusion
Introduction
We introduce StepFun-Formalizer, a family of large language models designed to translate natural-language mathematical problems into formal statements in Lean 4. Through the fusion of formal knowledge and informal-to-formal reasoning capability, StepFun-Formalizer achieves strong performance on autoformalization tasks. Evaluated with BEq verification on mainstream benchmarks including FormalMATH-Lite, ProverBench, and CombiBench, StepFun-Formalizer matches or exceeds all prior general-purpose and specialized autoformalization models of comparable scale. Please refer to our paper and code for more details.
Models
| Model | Download |
|---|---|
| StepFun-Formalizer-7B | 🤗HuggingFace |
| StepFun-Formalizer-32B | 🤗HuggingFace |
Usage
from vllm import LLM, SamplingParams
from transformers import AutoTokenizer
def get_formal_statement_prompt(informal_problem: str, header: str = "import Mathlib\n") -> str:
prompt = "Please autoformalize the following problem in Lean 4 with a header. Use the following theorem names: my_favorite_theorem.\n\n"
prompt += informal_problem
prompt += f"\n\nYour code should start with:\n```Lean4\n{header}\n```\n"
return prompt
MODEL_DIR = "stepfun-ai/StepFun-Formalizer-32B"
if __name__ == "__main__":
system_prompt = "You are an expert in mathematics and Lean 4."
informal_problem = "The real numbers $x, y, z$ satisfy $0 \\leq x \\leq y \\leq z \\leq 4$. If their squares form an arithmetic progression with common difference 2, determine the minimum possible value of $|x-y|+|y-z|$.\n Prove that the answer is: 4-2\\sqrt{3}"
header = "import Mathlib\n\nopen Real\n"
user_prompt = get_formal_statement_prompt(informal_problem, header)
dialog = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
]
tokenizer = AutoTokenizer.from_pretrained(MODEL_DIR)
prompt = tokenizer.apply_chat_template(dialog, tokenize=False, add_generation_prompt=True) + "<think>"
print(f"prompt: {prompt}")
model = LLM(
MODEL_DIR,
tensor_parallel_size=4 # 8 for 32B, 4 for 7B
)
sampling_params = SamplingParams(
temperature=0.6,
top_p=0.95,
max_tokens=16384,
n=1
)
responses = model.generate(prompt, sampling_params)
print(f"response: {responses[0].outputs[0].text}")
License
Both the code repository and the model weights are released under the Apache License (Version 2.0).
Citation
@misc{stepfunformalizer2025,
title={StepFun-Formalizer: Unlocking the Autoformalization Potential of LLMs through Knowledge-Reasoning Fusion},
author={Yutong Wu and Di Huang and Ruosi Wan and Yue Peng and Shijie Shang and Chenrui Cao and Lei Qi and Rui Zhang and Zidong Du and Jie Yan and Xing Hu},
year={2025},
eprint={2508.04440},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2508.04440},
}
- Downloads last month
- 395
Model tree for stepfun-ai/StepFun-Formalizer-32B
Base model
deepseek-ai/DeepSeek-R1-Distill-Qwen-32B