Text Generation
Transformers
Safetensors
qwen2
code-generation
formal-verification
reinforcement-learning
dafny
conversational
text-generation-inference
Instructions to use Veri-Code/ReForm-SFT-0.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Veri-Code/ReForm-SFT-0.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Veri-Code/ReForm-SFT-0.5B") 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-0.5B") model = AutoModelForCausalLM.from_pretrained("Veri-Code/ReForm-SFT-0.5B") 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-0.5B 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-0.5B" # 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-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Veri-Code/ReForm-SFT-0.5B
- SGLang
How to use Veri-Code/ReForm-SFT-0.5B 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-0.5B" \ --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-0.5B", "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-0.5B" \ --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-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Veri-Code/ReForm-SFT-0.5B with Docker Model Runner:
docker model run hf.co/Veri-Code/ReForm-SFT-0.5B
Improve model card for Re:Form: add metadata, links, and usage example
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,3 +1,83 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
pipeline_tag: text-generation
|
| 4 |
+
library_name: transformers
|
| 5 |
+
tags:
|
| 6 |
+
- code-generation
|
| 7 |
+
- formal-verification
|
| 8 |
+
- reinforcement-learning
|
| 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 hosts the `sft_0.5B` model, part of the **Re:Form** framework, which focuses on enhancing formal software verification using Large Language Models (LLMs) and Reinforcement Learning (RL).
|
| 15 |
+
|
| 16 |
+
**Re:Form** addresses the limitations of informal language-based LLMs by grounding them in rigorous formal systems, such as Dafny. This approach enables automatic and mathematically provable verification of the LLMs' reasoning processes and outcomes, crucial for large-scale, reliable formal software verification. The framework introduces an automatic and scalable data curation pipeline and integrates RL designs with feedback from a formal language verifier to reduce reliance on human priors.
|
| 17 |
+
|
| 18 |
+
- **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)
|
| 19 |
+
- **Project Page**: [https://veri-code.github.io/ReForm-page](https://veri-code.github.io/ReForm-page)
|
| 20 |
+
- **Code**: [https://github.com/Veri-Code/Veri-Code](https://github.com/Veri-Code/Veri-Code)
|
| 21 |
+
|
| 22 |
+
<p align="center">
|
| 23 |
+
<img src="https://github.com/Veri-Code/Veri-Code/raw/main/assets/pipeline.png" alt="Overall Pipeline" width="700"/>
|
| 24 |
+
<br>
|
| 25 |
+
<em>Overall Pipeline of Re:Form</em>
|
| 26 |
+
</p>
|
| 27 |
+
|
| 28 |
+
## Usage
|
| 29 |
+
|
| 30 |
+
You can load and use the `Re:Form` model with the `transformers` library for Dafny code generation.
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 34 |
+
import torch
|
| 35 |
+
|
| 36 |
+
model_id = "Veri-Code/sft_0.5B" # Example checkpoint; other available include sft_1.5B, sft_3B, sft_7B, sft_14B, 14B-RL-entropy
|
| 37 |
+
|
| 38 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 39 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 40 |
+
model_id,
|
| 41 |
+
torch_dtype=torch.bfloat16, # Use bfloat16 for optimal performance if supported
|
| 42 |
+
device_map="auto",
|
| 43 |
+
trust_remote_code=True,
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# Example prompt for Dafny code generation
|
| 47 |
+
# This prompt asks the model to implement a simple Max method in Dafny.
|
| 48 |
+
prompt = "method Max(a: int, b: int) returns (m: int)\
|
| 49 |
+
ensures m == a || m == b\
|
| 50 |
+
ensures m >= a && m >= b\
|
| 51 |
+
{\
|
| 52 |
+
"
|
| 53 |
+
|
| 54 |
+
input_ids = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 55 |
+
|
| 56 |
+
# Generate Dafny code
|
| 57 |
+
generated_ids = model.generate(
|
| 58 |
+
**input_ids,
|
| 59 |
+
max_new_tokens=100,
|
| 60 |
+
temperature=0.7,
|
| 61 |
+
do_sample=True,
|
| 62 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
|
| 66 |
+
print(generated_text)
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## Citation
|
| 70 |
+
|
| 71 |
+
If you use this work in your research, please cite:
|
| 72 |
+
|
| 73 |
+
```bibtex
|
| 74 |
+
@misc{yan2025reformreducinghuman,
|
| 75 |
+
title={Re:Form -- Reducing Human Priors in Scalable Formal Software Verification with RL in LLMs: A Preliminary Study on Dafny},
|
| 76 |
+
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},
|
| 77 |
+
year={2025},
|
| 78 |
+
eprint={2507.16331},
|
| 79 |
+
archivePrefix={arXiv},
|
| 80 |
+
primaryClass={cs.CL},
|
| 81 |
+
url={https://arxiv.org/abs/2507.16331},
|
| 82 |
+
}
|
| 83 |
+
```
|