File size: 14,348 Bytes
6b3ffe8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
---
pretty_name: XArch — Cross-Architecture Binary Function Retrieval
license: other
license_name: source-project-licenses
license_link: https://huggingface.co/datasets/moddemod/xarch#licensing-and-attribution
task_categories:
  - sentence-similarity
  - text-retrieval
tags:
  - binary-code
  - assembly
  - cross-architecture
  - function-retrieval
  - contrastive-learning
  - reconstruction
size_categories:
  - 100K<n<1M
viewer: false
---

# XArch: Cross-Architecture Binary Functions

**252,672 functions · 35,472 source-function groups · 835,966 positive pairs · 8 architecture configurations**

XArch provides source-linked assembly functions and positive correspondences for cross-architecture binary code similarity research. It supports embedding adaptation, contrastive learning, cross-architecture reconstruction, and function retrieval against complete target-architecture corpora.

The release derives from **BinAtlas/noinline**, covering **20 software projects compiled with GCC 6 at O0**. Architecture configurations are `arm32`, `arm64`, `mips32`, `mips64`, `ppc32`, `ppc64`, `x86`, and `x64`.

**Start with the function view for retrieval evaluation. Use the pair view for paired training.** The two views have different schemas and should be loaded separately.

## Quick start

The canonical data is distributed as a verified `.tar.gz` archive. The examples below download it, extract the requested view, and load the resulting JSONL files. Native dataset-viewer configurations are not provided for this archive release; the viewer is disabled to avoid interpreting metadata or statistics as training examples.

### 1. Download and extract

Python 3.10 or newer is supported by the preparation script.

```bash
pip install huggingface_hub datasets
```

Download the preparation helper from this repository:

```python
from huggingface_hub import hf_hub_download
import subprocess
import sys

script = hf_hub_download(
    repo_id="moddemod/xarch",
    filename="examples/prepare_dataset.py",
    repo_type="dataset",
)
subprocess.run(
    [sys.executable, script, "--output-dir", "./data", "--view", "functions"],
    check=True,
)
```

This creates `./data/xarch-bbdisasm-v2/` with the function files for all three splits. The helper verifies the archive checksum and the selected files against the release manifest. It stages extraction and refuses conflicting existing files.

To extract **both views**, replace `"functions"` with `"both"`. To extract only a split, add `"--splits", "test"` to the argument list. Selecting a view reduces extracted disk usage; it still downloads the complete archive.

The archive is approximately **489 MB**. The function files occupy **0.93 GB** uncompressed; both views together occupy **6.83 GB**, excluding caches and temporary extraction space. These are decimal GB values.

Already downloaded the archive? Run the helper locally with its neighboring checksum file:

```bash
python examples/prepare_dataset.py \
  --archive /path/to/xarch-bbdisasm-v2.tar.gz \
  --output-dir ./data --view both
```

### 2. Load the function view

```python
from datasets import load_dataset
from pathlib import Path

root = Path("./data/xarch-bbdisasm-v2")
functions = load_dataset(
    "json",
    data_files={
        split: str(root / f"{split}.functions.jsonl")
        for split in ("train", "validation", "test")
    },
    streaming=True,
)
row = next(iter(functions["train"]))
print(row["arch"], row["id"])
print(row["text"][:200])
```

`streaming=True` iterates over the extracted local files without materializing the entire view as an Arrow dataset. Remove it if random access is needed and sufficient disk space is available.

### 3. Load the pair view

First extract `--view pairs` or `--view both`, then load only the pair files:

```python
pairs = load_dataset(
    "json",
    data_files={
        split: str(root / f"{split}.jsonl")
        for split in ("train", "validation", "test")
    },
    streaming=True,
)
pair = next(iter(pairs["train"]))
anchor, positive = pair["query"], pair["positive"]
source_arch, target_arch = pair["query_arch"], pair["positive_arch"]
```

Do not use a broad `*.jsonl` pattern: it mixes the function and pair schemas. The release does not require IDA, the original binaries, or the original project's custom LLM2Vec loader.

## Release contents

The archive contains:

```text
xarch-bbdisasm-v2/
├── train.functions.jsonl
├── validation.functions.jsonl
├── test.functions.jsonl
├── train.jsonl
├── validation.jsonl
├── test.jsonl
├── summary.json
├── SHA256SUMS
├── README.txt
└── example_read.py
```

The repository additionally provides [preparation](examples/prepare_dataset.py), [JSONL inspection](examples/load_jsonl.py), and [retrieval evaluation](examples/evaluate_retrieval.py) helpers. The original archive and legacy files retain their existing names and contents.

## Dataset statistics

| Split | Functions | Source groups | Positive pairs |
|---|---:|---:|---:|
| Train | 199,408 | 27,946 | 660,178 |
| Validation | 26,277 | 3,771 | 85,857 |
| Test | 26,987 | 3,755 | 89,931 |
| **Total** | **252,672** | **35,472** | **835,966** |

| Configuration | Train | Validation | Test | Total |
|---|---:|---:|---:|---:|
| ARM32 | 24,237 | 3,202 | 3,282 | 30,721 |
| ARM64 | 24,447 | 3,220 | 3,306 | 30,973 |
| MIPS32 | 24,761 | 3,237 | 3,334 | 31,332 |
| MIPS64 | 24,767 | 3,249 | 3,321 | 31,337 |
| PPC32 | 24,710 | 3,251 | 3,338 | 31,299 |
| PPC64 | 24,777 | 3,254 | 3,325 | 31,356 |
| x86 | 25,830 | 3,439 | 3,543 | 32,812 |
| x64 | 25,879 | 3,425 | 3,538 | 32,842 |

Additional release inventories are available under [`statistics/`](https://huggingface.co/datasets/moddemod/xarch/tree/main/statistics): architecture counts, project counts, source-group coverage, and all **168 split–direction combinations** (56 directions for each split). These are data inventories, not model-performance measurements.

Published pairs follow the release's original orientation; their count is not the number of all ordered source–target retrieval combinations. Groups represented in more architectures contribute more positive pairs.

## Record schemas

### Function view: `*.functions.jsonl`

Each line is one function. The fields are:

| Field | Meaning |
|---|---|
| `id` | Function identifier within the release |
| `group_id` | Source-linked identity used to define known correspondences |
| `split` | `train`, `validation`, or `test` |
| `arch` | One of the eight configuration identifiers listed above |
| `project`, `artifact` | Source-project and binary-artifact provenance |
| `num_blocks`, `num_instructions` | Function-size metadata |
| `opcode_hash` | SHA256 of the ordered instruction-mnemonic sequence |
| `text` | Full exported assembly text, with newline-separated instructions |

### Pair view: `train.jsonl`, `validation.jsonl`, `test.jsonl`

Each line is one cross-architecture positive pair:

| Fields | Meaning |
|---|---|
| `group_id`, `split` | Shared source identity and partition |
| `query_id`, `positive_id` | IDs referencing the corresponding function records |
| `query_arch`, `positive_arch` | Source and target architecture configurations |
| `query`, `positive` | Assembly text of the two functions |

All records are UTF-8 JSON Lines. Escaped newlines in a raw JSON line become actual newlines after parsing with `json.loads`.

## Training recipes

- **Embedding adaptation / InfoNCE:** use `query` and `positive` as paired inputs. If constructing in-batch negatives, treat all known same-group counterparts as positives rather than accidental negatives. The release contains no explicit negative labels.
- **Cross-architecture reconstruction:** condition on `query` and `positive_arch`, with `positive` as the target implementation. Source/target architecture metadata can be used in the instruction; group IDs should remain supervision metadata.
- **Reranker training:** construct and audit negatives from the training split only. Exclude known same-group counterparts and check model-visible input collisions after tokenization/truncation. Different group IDs alone do not prove semantic non-equivalence.

Use assembly text, optionally with an architecture instruction, as the model input. Keep function IDs, group IDs, and project/artifact identity out of benchmark encoder inputs. Model tokenizers may truncate long functions even though the stored text is not truncated.

## Retrieval evaluation

Use the **function view**, not sampled pair rows, to construct the evaluation corpus.

For each ordered source→target direction:

1. Select source-configuration functions from a fixed split.
2. Include **every target-configuration function from the same split** in the candidate corpus.
3. Define relevance by equal `group_id`.
4. Exclude queries with no known counterpart in the target corpus and report how many were excluded.
5. Rank candidates by embedding similarity and evaluate against all known relevant candidates.

Eight configurations give **56 ordered cross-architecture directions**. A full-ranking MRR uses the first relevant rank in the entire candidate corpus. Recall@K measures the fraction of relevant functions retrieved; Hit@K measures whether any relevant function is retrieved. NDCG@K uses binary relevance. Macro-average direction-level results for equal weighting across directions, and label query-weighted or ISA-family-specific averages separately.

The example evaluator first writes deterministic, ID-sorted query and candidate files:

```bash
python examples/evaluate_retrieval.py \
  --dataset-dir ./data/xarch-bbdisasm-v2 --split test \
  --source arm64 --target x64 --output-dir ./eval_arm64_x64
```

For this release, the test `arm64→x64` plan contains **3,300 eligible queries**, **3,538 candidates**, and **6 excluded queries**.

Encode `queries.jsonl` and `candidates.jsonl` in **exactly their exported row order**, using only their `text` and any chosen architecture instruction. Save the two matrices as `.npy` files, then run:

```bash
pip install numpy
python examples/evaluate_retrieval.py \
  --dataset-dir ./data/xarch-bbdisasm-v2 --split test \
  --source arm64 --target x64 --output-dir ./eval_arm64_x64 \
  --query-embeddings queries.npy --candidate-embeddings candidates.npy
```

The evaluator normalizes vectors, performs exact cosine ranking, and resolves ties by ascending candidate ID. Report checkpoint identity, candidate/query counts, input token limit, pooling, tie handling, split, and aggregation alongside model metrics.

## Construction and split integrity

Source correspondence uses DWARF information and binary-artifact metadata rather than bare function names. Curation retains functions with at least five basic blocks, performs cross-split opcode-hash deduplication with priority **test > validation > train**, and removes groups represented in fewer than two configurations.

The opcode hash uses an ordered JSON array of lowercased, stripped instruction mnemonics, without operands or architecture tags. Functions are exported in ascending basic-block-address order and original instruction order within blocks. No block markers, function-name headers, instruction normalization, or export-time truncation are added.

The final-release [structural audit](statistics/final_release_audit.json) reports zero cross-split source-group overlap, cross-split stored opcode-hash overlap, duplicate IDs within splits, empty disassembly, functions below the block threshold, or groups below the architecture threshold. These structural checks are not a manual semantic-equivalence audit. The [audit script](statistics/audit_xarch.py) can regenerate the inventories from the extracted release.

## Scope and limitations

- **Source-group-disjoint, not project-disjoint.** All 20 projects occur in every split. Do not randomly re-split pair rows: functions in the same source group must remain together.
- **Fixed compilation scope.** This release does not establish generalization across optimization levels, compiler families, or unseen projects.
- **Source-linked correspondence, not a formal proof.** Same-group implementations are known correspondences; unrelated group IDs do not establish different semantics.
- **Assembly-text export.** Original machine bytes and complete control-flow edges are not included. Reconstruction can learn from assembly targets, but generated assembly is not automatically verified as executable or semantically equivalent.
- **No model results implied.** Dataset inventories, structural checks, and example scripts do not establish any model's retrieval performance.

## Versioning and integrity

The data release identifier is **`ppc64_entry_repaired_v2`** (2026-10-09). This documentation update does not change the archive or its records. The retained technical identifier is also recorded in `summary.json`.

For reproducible experiments, record the dataset repository commit and source-file checksums. With a complete extraction, verify all packaged files using:

```bash
cd data/xarch-bbdisasm-v2
sha256sum -c SHA256SUMS
```

For a selectively extracted view, the preparation helper verifies only the selected files and accompanying metadata; the full checksum command will also mention the intentionally unextracted files.

## Licensing and attribution

This export does not assign a new blanket license to the underlying code. Source-project licenses and notices have not been consolidated into the package. Project and artifact fields preserve attribution; users should consult the relevant upstream projects before redistribution or other use.

Please acknowledge the **BinAtlas/noinline** source collection and the underlying software projects, in addition to this derived text release.

## Citation

To cite this dataset release:

```bibtex
@misc{xarch_dataset_2026,
  author       = {{moddemod}},
  title        = {{XArch: Cross-Architecture Binary Functions}},
  year         = {2026},
  howpublished = {Hugging Face dataset repository},
  url          = {https://huggingface.co/datasets/moddemod/xarch},
  note         = {Data release: ppc64_entry_repaired_v2}
}
```

For questions, reproducibility issues, or corrections, use the repository's **Community** tab and include the release/commit, file name, and minimal reproduction steps.