On the Role of Pre-trained Embeddings in Binary Code Analysis

Alwin Maier, Felix Weissberg, Konrad Rieck · DOI

Abstract

In binary code analysis, pre-trained embeddings are often regarded as the standard for transforming assembly instructions into vector representations. However, this study challenges that assumption by demonstrating that when sufficient labeled data is available—a common scenario in binary analysis due to compiler debug information—simple end-to-end learning often matches or exceeds the performance of complex pre-trained models like Asm2Vec or PalmTree. We introduce the Orbit dataset, a large-scale benchmark for binary analysis, and conduct a systematic evaluation of various embedding strategies across five downstream tasks. Our findings suggest that pre-training is primarily beneficial in low-data regimes, while task-specific embeddings trained from scratch provide a more efficient and accurate baseline for most practical applications.

Introduction

Deep learning has significantly advanced binary code analysis tasks such as malware detection, vulnerability discovery, and reverse engineering. Central to these techniques is the instruction embedding, which maps discrete assembly instructions to continuous vector spaces. Drawing inspiration from Natural Language Processing (NLP), researchers have widely adopted "pre-train then fine-tune" workflows using models like Word2Vec or BERT.

However, the availability of labeled data in binary analysis differs fundamentally from NLP. While human-labeled text is scarce, labeled binary data can be generated at scale by compiling source code with various configurations and preserving debug symbols. This paper investigates whether the complexity of specialized pre-trained embeddings is truly necessary when labeled data is abundant.

Embedding Strategies and Methodology

The study compares two primary paradigms for instruction representation:

  1. Pre-training and Downstream Task: An unsupervised model is trained on a large corpus of unlabeled instructions to generate embeddings, which are then used as input for a supervised learning model.
  2. End-to-End Supervised Learning: The embedding layer is initialized and trained jointly with the downstream model using labeled data.
Comparison of pre-training vs. task-specific embedding workflows.

The researchers evaluated several pre-trained models (Word2Vec, Instruction2Vec, Asm2Vec, PalmTree) against a "Random" baseline and an "End-to-end" approach across five tasks: compiler detection, optimization level identification, argument count prediction, argument type reconstruction, and function similarity detection.

The Orbit Dataset

To facilitate this large-scale evaluation, the authors created the Orbit dataset. This benchmark comprises 1.2 million functions and 129 million x86 instructions derived from 480 Debian packages. Each package was compiled with eight combinations of compilers (GCC, Clang) and optimization levels (O0-O3).

The pipeline for generating the Orbit dataset and training embedding models.

A critical feature of Orbit is its split strategy: data is partitioned by source package rather than individual functions. This prevents "data leakage," ensuring the model cannot rely on project-specific patterns seen during training to make predictions during testing.

Key Findings

The Efficacy of End-to-End Learning

The most significant finding is that training an embedding layer from scratch (end-to-end) achieved an average accuracy of ~87% across classification tasks, frequently outperforming sophisticated pre-trained models. This suggests that the supervised task itself provides enough signal to learn effective representations without the need for an expensive unsupervised pre-training phase.

The "Random" Baseline Surprise

Remarkably, even randomly assigned instruction vectors yielded strong results. This indicates that the architectural components of the downstream models (e.g., LSTMs or GRUs) are responsible for much of the "heavy lifting" in capturing code semantics, rather than the intrinsic quality of the initial embeddings.

When Pre-training Matters

Pre-training showed a clear advantage only in "data-poor" scenarios, specifically when labeled data constituted less than 1% of the total dataset. In these cases, PalmTree (a BERT-based model) proved to be the most robust. Additionally, pre-trained embeddings served as a "head start," leading to faster convergence during the training process.

Conclusion

The study concludes that for most binary analysis tasks where labeled data is accessible, end-to-end learning should be the default approach. Pre-trained embeddings remain valuable for structural code comparison (like function similarity) or when working with extremely limited labeled datasets. Practitioners are encouraged to establish an end-to-end baseline before investing in the computational overhead of complex pre-trained models.

Summary updated

BibTeX
@inproceedings{maier2024role,
  author = {Alwin Maier and Felix Weissberg and Konrad Rieck},
  title = {{On the Role of Pre-trained Embeddings in Binary Code Analysis}},
  booktitle = {AsiaCCS},
  year = {2024},
  doi = {10.1145/3634737.3657029},
}
Figure