Skip to main content
QUICK REVIEW

[Paper Review] Binary Code Summarization: Benchmarking ChatGPT/GPT-4 and Other Large Language Models

Xin Jin, Jonathan Larson|arXiv (Cornell University)|Dec 15, 2023
Topic ModelingComputer Science12 citations
TL;DR

The paper introduces BinSum, a large-scale binary code summarization benchmark with 557,664 ground-truth function summaries, evaluates multiple LLMs (GPT-4, ChatGPT, Llama 2, Code Llama) and BinT5 across four binary representations, and proposes a semantic-similarity evaluation metric and prompt-synthesis pipeline.

ABSTRACT

Binary code summarization, while invaluable for understanding code semantics, is challenging due to its labor-intensive nature. This study delves into the potential of large language models (LLMs) for binary code comprehension. To this end, we present BinSum, a comprehensive benchmark and dataset of over 557K binary functions and introduce a novel method for prompt synthesis and optimization. To more accurately gauge LLM performance, we also propose a new semantic similarity metric that surpasses traditional exact-match approaches. Our extensive evaluation of prominent LLMs, including ChatGPT, GPT-4, Llama 2, and Code Llama, reveals 10 pivotal insights. This evaluation generates 4 billion inference tokens, incurred a total expense of 11,418 US dollars and 873 NVIDIA A100 GPU hours. Our findings highlight both the transformative potential of LLMs in this field and the challenges yet to be overcome.

Motivation & Objective

  • Create a large-scale open-source binary code summarization dataset with ground-truth summaries derived from code comments.
  • Systematically evaluate the capability of leading LLMs to summarize binary code semantics across diverse representations and architectures.
  • Develop prompt synthesis and optimization methods to maximize LLM performance on binary code summarization.
  • Introduce a semantic-embedding based evaluation metric to better capture semantic alignment beyond exact-match metrics.
  • Provide practical insights into representation choice, model choice, and prompting strategies for binary code understanding.

Proposed method

  • Construct a dataset of 44 GNU projects compiled into x86, x64, ARM, and MIPS with four optimization levels, yielding 557,664 function-level summaries.
  • Generate four binary representations (raw bytes, assembly, IR, and decompiled code with/without debugging symbols) plus source code.
  • Propose a four-step prompt workflow: in-context prompt synthesis, prompt variant generation, prompt optimization, and task-specific prompt selection.
  • Introduce a semantic embedding-based evaluator using a pretrained model to compute cosine similarity between generated and ground-truth summaries.
  • Test four LLMs (GPT-4, ChatGPT, Llama 2, Code Llama) and BinT5, plus compare against BinT5, with a cost and efficiency analysis.
  • Evaluate prompts by semantic similarity on a random data subset to identify top prompts for full evaluation.

Experimental results

Research questions

  • RQ1How well do leading LLMs understand and summarize binary code semantics across different binary representations?
  • RQ2What representations (raw bytes, assembly, IR, decompiled code) best support LLM-based binary code summarization?
  • RQ3Which LLMs perform best on this task under symbol-rich and symbol-stripped conditions?
  • RQ4Does a semantic-embedding based evaluation better reflect summary quality than traditional BLEU/METEOR/ROUGE metrics?
  • RQ5How effective are automatic prompt synthesis and optimization strategies for improving LLM performance on binary code summarization?

Key findings

  • De-symbolized binaries lose semantic information substantially (up to 55.0% loss).
  • Decompiled code yields the strongest semantic understanding for LLMs among representations.
  • ChatGPT and Code Llama achieve the best performance with and without debugging symbols, respectively.
  • Code Llama generally outperforms Llama 2; fine-tuning CodeT5 on decompiled code does not match BinT5 performance.
  • ChatGPT and Llama 2 are faster (up to 2.9x and 1.5x) than GPT-4 and Code Llama in this task.
  • LLMs perform best on x64 and MIPS binaries (up to 16.0% improvement) with decompiled code and symbols; decompilers Hex-Rays yield the highest scores (60.7% relative).
  • Function names contribute most to binary semantics among symbols analyzed.
  • Zero-shot prompting often outperforms few-shot and chain-of-thought prompting when considering performance and cost.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.