CLAP: Learning Transferable Binary Code Representations with Natural Language Supervision

Hao Wang, Zeyu Gao, Chao Zhang, Zihan Sha, Mingyang Sun +5 more
2/26/2024
cs.SEcs.AI

Official code: Hustcw/CLAP (75 stars, last commit 2024-09-28).

Abstract

Binary code representation learning has shown significant performance in binary analysis tasks. But existing solutions often have poor transferability, particularly in few-shot and zero-shot scenarios where few or no training samples are available for the tasks. To address this problem, we present CLAP (Contrastive Language-Assembly Pre-training), which employs natural language supervision to learn better representations of binary code (i.e., assembly code) and get better transferability. At the core, our approach boosts superior transfer learning capabilities by effectively aligning binary code with their semantics explanations (in natural language), resulting a model able to generate better embeddings for binary code. To enable this alignment training, we then propose an efficient dataset engine that could automatically generate a large and diverse dataset comprising of binary code and corresponding natural language explanations. We have generated 195 million pairs of binary code and explanations and trained a prototype of CLAP. The evaluations of CLAP across various downstream tasks in binary analysis all demonstrate exceptional performance. Notably, without any task-specific training, CLAP is often competitive with a fully supervised baseline, showing excellent transferability. We release our pre-trained model and code at https://github.com/Hustcw/CLAP.

View on arXivView PDF

Code Implementations(1)

Hustcw/CLAPOfficial100%

CLAP(Contrastive Language-Assembly Pre-training) learns transferable binary code representations with natural language supervision

755Python, Jupyter NotebookJun 7, 20232 years ago
assemblybinary-analysisrepresentation-learningreverse-engineering

Similar Papers

Cite this paper

@article{wang2024clap,
  title  = {CLAP: Learning Transferable Binary Code Representations with Natural Language Supervision},
  author = {Hao Wang and Zeyu Gao and Chao Zhang and Zihan Sha and Mingyang Sun and Yuchen Zhou and Wenyu Zhu and Wenju Sun and Han Qiu and Xi Xiao},
  year   = {2024},
  eprint = {2402.16928},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2402.16928v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.16928.svg)](https://codeofpaper.com/paper/2402.16928)

Discussion