Add comprehensive model card for Re:Form

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +99 -3
README.md CHANGED
@@ -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
+ ![Overall Pipeline](https://github.com/Veri-Code/Veri-Code/raw/main/assets/pipeline.png)
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
+ ```