xarch / example_read.py
moddemod's picture
Upload verified cross-architecture bb_disasm V2 dataset
4e2109c verified
Raw History Blame Contribute Delete
800 Bytes
import json
import sys
from pathlib import Path
root = Path(sys.argv[1] if len(sys.argv) > 1 else ".")
def records(name):
with (root / name).open(encoding="utf-8") as stream:
for line in stream:
yield json.loads(line)
pair = next(records("train.jsonl"))
print("Positive pair:", pair["query_arch"], "->", pair["positive_arch"])
print("Query excerpt:", pair["query"][:200])
functions = list(records("test.functions.jsonl"))
targets = [f for f in functions if f["arch"] == "x64"]
gold_groups = {f["group_id"] for f in targets}
queries = [f for f in functions if f["arch"] == "arm64" and f["group_id"] in gold_groups]
print("arm64 -> x64:", len(queries), "eligible queries;", len(targets), "candidates")
print("Encode text; same group_id indicates a labeled relevant candidate.")