SiniShell1 nielsr HF Staff commited on
Commit
852eb84
·
verified ·
1 Parent(s): bccc0bb

Add comprehensive model card for Re:Form (#1)

Browse files

- Add comprehensive model card for Re:Form (7d7640dab563ff3d193e9430a8eb2d3ad17c64bb)


Co-authored-by: Niels Rogge <[email protected]>

Files changed (1) hide show
  1. README.md +82 -3
README.md CHANGED
@@ -1,3 +1,82 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pipeline_tag: text-generation
4
+ library_name: transformers
5
+ ---
6
+
7
+ # Re:Form -- Reducing Human Priors in Scalable Formal Software Verification with RL in LLMs: A Preliminary Study on Dafny
8
+
9
+ This repository contains models from the **Re:Form** framework, as 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).
10
+
11
+ Re:Form introduces a novel approach to formal software verification by integrating Reinforcement Learning (RL) with Large Language Models (LLMs), focusing on formal languages like Dafny. This work aims to reduce the dependency on extensive human-annotated priors, a significant challenge in informal language-based LLMs. By grounding LLMs in rigorous formal systems, Re:Form enables automatic and mathematically provable verification of reasoning processes and outcomes, addressing scalability and reliability issues in generating verifiable programs.
12
+
13
+ The pipeline for Re:Form involves an automatic and scalable data curation process and carefully designed RL strategies that incorporate feedback from a formal language verifier. The paper also introduces **DafnyComp**, a benchmark of compositional formal programs. Even small models (e.g., 0.5B) fine-tuned with Supervised Fine-Tuning (SFT) can generate syntactically valid and verifiable Dafny code, surpassing proprietary models. Further improvements in performance and generalization to out-of-domain tasks are achieved through RL with regularization.
14
+
15
+ * **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)
16
+ * **Project Page**: [https://veri-code.github.io/ReForm-page](https://veri-code.github.io/ReForm-page)
17
+ * **Code**: [https://github.com/Veri-Code/Veri-Code](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
+ ## Usage
22
+
23
+ This model is compatible with the Hugging Face `transformers` library. You can load and use it for text generation tasks, particularly for generating Dafny code.
24
+
25
+ ```python
26
+ from transformers import AutoModelForCausalLM, AutoTokenizer
27
+ import torch
28
+
29
+ # Replace with the specific model checkpoint you want to use, e.g., "Veri-Code/sft_0.5B" or "Veri-Code/reform-qwen2-7b-sft"
30
+ model_name = "Veri-Code/sft_0.5B"
31
+
32
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
33
+ model = AutoModelForCausalLM.from_pretrained(
34
+ model_name,
35
+ torch_dtype=torch.bfloat16, # Use bfloat16 for better performance if supported, otherwise torch.float16
36
+ device_map="auto" # Automatically loads the model across available devices (e.g., multiple GPUs)
37
+ )
38
+
39
+ model.eval() # Set model to evaluation mode
40
+
41
+ # Example: Generate Dafny code for a simple function
42
+ prompt = """
43
+ method Add(x: int, y: int) returns (sum: int)
44
+ ensures sum == x + y
45
+ {
46
+ """
47
+
48
+ print(f"Input Prompt:
49
+ {prompt}")
50
+
51
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
52
+
53
+ # Generate continuation of the code
54
+ with torch.no_grad():
55
+ outputs = model.generate(
56
+ **inputs,
57
+ max_new_tokens=100, # Generate up to 100 new tokens
58
+ do_sample=True,
59
+ temperature=0.7, # Adjust for more/less creative outputs
60
+ top_p=0.9 # Adjust for nucleus sampling
61
+ )
62
+
63
+ generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
64
+ print(f"Generated Dafny Code:
65
+ {generated_text}")
66
+ ```
67
+
68
+ ## Citation
69
+
70
+ If you use this work in your research, please cite:
71
+
72
+ ```bibtex
73
+ @misc{yan2025reformreducinghuman,
74
+ title={Re:Form -- Reducing Human Priors in Scalable Formal Software Verification with RL in LLMs: A Preliminary Study on Dafny},
75
+ 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},
76
+ year={2025},
77
+ eprint={2507.16331},
78
+ archivePrefix={arXiv},
79
+ primaryClass={cs.CL},
80
+ url={https://arxiv.org/abs/2507.16331},
81
+ }
82
+ ```