Instructions to use Veri-Code/ReForm-SFT-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Veri-Code/ReForm-SFT-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Veri-Code/ReForm-SFT-3B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Veri-Code/ReForm-SFT-3B") model = AutoModelForCausalLM.from_pretrained("Veri-Code/ReForm-SFT-3B") 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 Veri-Code/ReForm-SFT-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Veri-Code/ReForm-SFT-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Veri-Code/ReForm-SFT-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Veri-Code/ReForm-SFT-3B
- SGLang
How to use Veri-Code/ReForm-SFT-3B 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 "Veri-Code/ReForm-SFT-3B" \ --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": "Veri-Code/ReForm-SFT-3B", "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 "Veri-Code/ReForm-SFT-3B" \ --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": "Veri-Code/ReForm-SFT-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Veri-Code/ReForm-SFT-3B with Docker Model Runner:
docker model run hf.co/Veri-Code/ReForm-SFT-3B
Add comprehensive model card for Re:Form
Browse filesThis PR adds a comprehensive model card for the Re:Form model, presented in [Re:Form -- Reducing Human Priors in Scalable Formal Software Verification with RL in LLMs: A Preliminary Study on Dafny](https://huggingface.co/papers/2507.16331).
The model card now includes relevant metadata such as `pipeline_tag: text-generation` and `library_name: transformers`, along with other relevant tags, improving its discoverability on the Hub. It also features a detailed overview, links to the project page and GitHub repository, a visual representation of the pipeline, and a clear Python code snippet for sample usage with the `transformers` library.
|
@@ -1,3 +1,99 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- code-generation
|
| 7 |
+
- reinforcement-learning
|
| 8 |
+
- formal-verification
|
| 9 |
+
- dafny
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Re:Form -- Reducing Human Priors in Scalable Formal Software Verification with RL in LLMs: A Preliminary Study on Dafny
|
| 13 |
+
|
| 14 |
+
This repository contains checkpoints and resources for the **Re:Form** project, which explores novel approaches to formal software verification using Large Language Models (LLMs). The work was presented in the paper [Re:Form -- Reducing Human Priors in Scalable Formal Software Verification with RL in LLMs: A Preliminary Study on Dafny](https://huggingface.co/papers/2507.16331).
|
| 15 |
+
|
| 16 |
+
- 🌐 [Project Page](https://veri-code.github.io/ReForm-page)
|
| 17 |
+
- 💾 [GitHub Repository](https://github.com/Veri-Code/Veri-Code)
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
|
| 21 |
+
## Overview
|
| 22 |
+
|
| 23 |
+
Existing informal language-based LLMs often face challenges with reliable and scalable verification processes. Re:Form addresses this by grounding LLMs in rigorous formal systems, such as Dafny, to enable automatic and mathematically provable verification of their reasoning. This capability is vital for achieving large-scale, reliable formal software verification while systematically reducing reliance on extensive human priors.
|
| 24 |
+
|
| 25 |
+
The core of Re:Form's pipeline involves:
|
| 26 |
+
* An automatic and scalable data curation process.
|
| 27 |
+
* Careful Reinforcement Learning (RL) designs integrated with feedback from a formal language verifier.
|
| 28 |
+
|
| 29 |
+
Even small models (e.g., 0.5B) fine-tuned with Re:Form can generate syntactically valid and verifiable Dafny code, surpassing proprietary models and demonstrating stronger generalization to out-of-domain tasks, as evidenced by performance on the challenging DafnyComp benchmark.
|
| 30 |
+
|
| 31 |
+
## Usage
|
| 32 |
+
|
| 33 |
+
You can use the Re:Form models with the Hugging Face `transformers` library. Below is an example using the `sft_0.5B` checkpoint. Other checkpoints (e.g., `sft_1.5B`, `sft_3B`, `sft_7B`, `sft_14B`, `14B-RL-entropy`) are also available from the [Veri-Code Hugging Face organization](https://huggingface.co/Veri-Code).
|
| 34 |
+
|
| 35 |
+
First, ensure you have the `transformers` library and `torch` installed. For optimal performance, especially with larger models, consider installing `FlashAttention` as detailed in the [GitHub repository's installation instructions](https://github.com/Veri-Code/Veri-Code#installation).
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 39 |
+
import torch
|
| 40 |
+
|
| 41 |
+
model_id = "Veri-Code/sft_0.5B" # Example checkpoint, replace with other available models if needed
|
| 42 |
+
|
| 43 |
+
# Load the model and tokenizer
|
| 44 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 45 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 46 |
+
model_id,
|
| 47 |
+
torch_dtype=torch.bfloat16, # Use torch.float16 or torch.float32 depending on your hardware
|
| 48 |
+
device_map="auto",
|
| 49 |
+
trust_remote_code=True
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
# Example for generating Dafny code
|
| 53 |
+
prompt = """
|
| 54 |
+
method print_sum(a: int, b: int) returns (sum: int)
|
| 55 |
+
ensures sum == a + b
|
| 56 |
+
{
|
| 57 |
+
return a + b;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
method Max(a: int, b: int) returns (result: int)
|
| 61 |
+
ensures result == a || result == b;
|
| 62 |
+
ensures result >= a && result >= b;
|
| 63 |
+
{
|
| 64 |
+
"""
|
| 65 |
+
|
| 66 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt").to(model.device)
|
| 67 |
+
|
| 68 |
+
# Generate text (Dafny code)
|
| 69 |
+
output_ids = model.generate(
|
| 70 |
+
inputs,
|
| 71 |
+
max_new_tokens=2048, # Max new tokens as specified in generation_config.json
|
| 72 |
+
do_sample=True,
|
| 73 |
+
temperature=0.6,
|
| 74 |
+
top_p=0.9,
|
| 75 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 76 |
+
pad_token_id=tokenizer.eos_token_id, # Usually set pad_token_id to eos_token_id for causal LMs
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
generated_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
| 80 |
+
print(generated_text)
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
For more details on training, evaluation, and other advanced usage, please refer to the [official GitHub repository](https://github.com/Veri-Code/Veri-Code).
|
| 84 |
+
|
| 85 |
+
## Citation
|
| 86 |
+
|
| 87 |
+
If you use this work in your research, please cite the paper:
|
| 88 |
+
|
| 89 |
+
```bibtex
|
| 90 |
+
@misc{yan2025reformreducinghuman,
|
| 91 |
+
title={Re:Form -- Reducing Human Priors in Scalable Formal Software Verification with RL in LLMs: A Preliminary Study on Dafny},
|
| 92 |
+
author={Chuanhao Yan and Fengdi Che and Xuhan Huang and Xu Xu and Xin Li and Yizhi Li and Xingwei Qu and Jingzhe Shi and Zhuangzhuang He and Chenghua Lin and Yaodong Yang and Binhang Yuan and Hang Zhao and Yu Qiao and Bowen Zhou and Jie Fu},
|
| 93 |
+
year={2025},
|
| 94 |
+
eprint={2507.16331},
|
| 95 |
+
archivePrefix={arXiv},
|
| 96 |
+
primaryClass={cs.CL},
|
| 97 |
+
url={https://arxiv.org/abs/2507.16331},
|
| 98 |
+
}
|
| 99 |
+
```
|