hzeng8 commited on
Commit
e969dee
·
verified ·
1 Parent(s): d4125a5

Add C2Rust model card

Browse files

Document the model, companion benchmark, setup, intended use, limitations, and licensing.

Files changed (1) hide show
  1. README.md +116 -0
README.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - Qwen/Qwen3.5-27B
5
+ library_name: transformers
6
+ pipeline_tag: image-text-to-text
7
+ tags:
8
+ - code
9
+ - c
10
+ - rust
11
+ - code-translation
12
+ - c-to-rust
13
+ - qwen3.5
14
+ ---
15
+
16
+ # C2Rust
17
+
18
+ C2Rust is a 27B-parameter BF16 Qwen3.5 checkpoint for translating C programs into behaviorally
19
+ equivalent Rust. It is released alongside an execution-based benchmark that compiles each generated
20
+ translation and checks its output against the reference C program.
21
+
22
+ ## Resources
23
+
24
+ - [Benchmark, evaluation harness, and setup instructions](https://github.com/moxin-org/C2Rust)
25
+ - [Base model: Qwen/Qwen3.5-27B](https://huggingface.co/Qwen/Qwen3.5-27B)
26
+ - [SACTOR translation engine](https://github.com/qsdrqs/sactor)
27
+
28
+ ## Model details
29
+
30
+ | Field | Value |
31
+ |---|---|
32
+ | Base model | `Qwen/Qwen3.5-27B` |
33
+ | Architecture | Qwen3.5 causal language model with vision encoder |
34
+ | Parameters | 27B |
35
+ | Weight format | Safetensors |
36
+ | Precision | BF16 |
37
+ | Primary task | C→Rust program translation |
38
+
39
+ ## Intended use
40
+
41
+ The model is intended for research and experimentation on C→Rust translation. Its output should be
42
+ treated as a candidate translation: compile it, test it against the original program, and review it
43
+ for correctness, safety, and maintainability before use.
44
+
45
+ The companion benchmark evaluates a single translation stage that preserves the C interface and may
46
+ produce `unsafe` Rust. It does not establish that generated code is memory-safe, idiomatic, secure,
47
+ or suitable for production.
48
+
49
+ ## Running the model with the benchmark
50
+
51
+ Download the checkpoint:
52
+
53
+ ```bash
54
+ hf download moxin-org/C2Rust --local-dir /path/to/C2Rust-model
55
+ ```
56
+
57
+ Clone and prepare the benchmark:
58
+
59
+ ```bash
60
+ git clone https://github.com/moxin-org/C2Rust.git
61
+ cd C2Rust
62
+ bash fix_paths.sh
63
+
64
+ cd engine
65
+ uv sync
66
+ ./update_rust_ast_parser.sh
67
+ cargo build --release
68
+ cd ..
69
+ ```
70
+
71
+ Create an SGLang environment, point `SERVE_VENV` at it, and launch the checkpoint. The helper script
72
+ sets the serving options expected by the benchmark:
73
+
74
+ ```bash
75
+ export SERVE_VENV=/path/to/sglang-venv
76
+ ./scripts/launch_model.sh /path/to/C2Rust-model 0,1 30878 2
77
+ ```
78
+
79
+ In another shell, run a two-problem smoke test before a full evaluation:
80
+
81
+ ```bash
82
+ python3 scripts/run_eval.py configs/native_prompt.toml results/_smoke \
83
+ --modes argv --limit 2 --workers 1
84
+ ```
85
+
86
+ See the [benchmark README](https://github.com/moxin-org/C2Rust#setup-once-per-machine) and
87
+ [`SETUP.md`](https://github.com/moxin-org/C2Rust/blob/main/SETUP.md) for system dependencies,
88
+ multi-seed evaluation, aggregation, and troubleshooting.
89
+
90
+ ## Evaluation protocol
91
+
92
+ The companion CodeNet benchmark contains 200 C programs: 92 use command-line arguments and 108 use
93
+ standard input. A problem passes only when the generated Rust program compiles and matches the
94
+ reference C program on every test case. Decoding is fixed at temperature 0.6, top-p 0.95, and top-k
95
+ 20. Because individual runs are noisy, the repository reports five-seed means with standard
96
+ deviation and a bootstrap confidence interval.
97
+
98
+ No reference model score is claimed in the benchmark repository. Use its shipped configuration and
99
+ five-seed aggregation script for comparable measurements.
100
+
101
+ ## Limitations
102
+
103
+ - Generated translations may fail to compile or may differ from the source program on untested
104
+ inputs.
105
+ - Passing the supplied tests is not a proof of semantic equivalence, memory safety, or security.
106
+ - The benchmark's primary flow permits `unsafe` Rust and prioritizes behavioral preservation over
107
+ idiomatic Rust.
108
+ - Training-data and training-procedure details are not included in the current release.
109
+
110
+ ## Licenses and attribution
111
+
112
+ The checkpoint is released under Apache-2.0 and is based on
113
+ [Qwen/Qwen3.5-27B](https://huggingface.co/Qwen/Qwen3.5-27B). The benchmark repository is
114
+ Apache-2.0. Its dataset includes material derived from IBM Project CodeNet under
115
+ CDLA-Permissive-2.0; see the benchmark's
116
+ [dataset provenance and terms](https://github.com/moxin-org/C2Rust/blob/main/CodeNet/README.md).