Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

LLM4Decompile

> 编程语言
Open source

Reverse Engineering: Decompiling Binary Code with Large Language Models

6.8K stars0 likes1 views
WebsiteGitHub

About

Reverse Engineering: Decompiling Binary Code with Large Language Models

 Results |  Models |  Quick Start |  HumanEval-Decompile |  Citation |  Paper | ️ Colab | ▶️ YouTube

Reverse Engineering: Decompiling Binary Code with Large Language Models

Updates

  • [2025-10-04]: Release SK²Decompile: LLM-based Two-Phase Binary Decompilation from Skeleton to Skin. Phase 1 Structure Recovery (Skeleton): Transform binary/pseudo-code into obfuscated intermediate representations HF Link. Phase 2 Identifier Naming (Skin): Generate human-readable source code with meaningful identifiers HF Link.
  • [2025-05-20]: Release decompile-bench, contains two million binary-source function pairs for training, and 70K function pairs for evaluation. Please refer to the decompile-bench folder for details.
  • [2024-10-17]: Release decompile-ghidra-100k, a subset of 100k training samples (25k per optimization level). We provide a training script that runs in ~3.5 hours on a single A100 40G GPU. It achieves a 0.26 re-executability rate, with a total cost of under $20 for quick replication of LLM4Decompile.
  • [2024-09-26]: Update a Colab notebook to demonstrate the usage of the LLM4Decompile model, including examples for the LLM4Decompile-End and LLM4Decompile-Ref models.
  • [2024-09-23]: Release LLM4Decompile-9B-v2, fine-tuned based on Yi-Coder-9B, achieved a re-executability rate of 0.6494 on the Decompile benchmark.
  • [2024-06-19]: Release V2 series (LLM4Decompile-Ref). V2 (1.3B-22B), building upon Ghidra, are trained on 2 billion tokens to refine the decompiled pseudo-code from Ghidra. The 22B-V2 version outperforms the 6.7B-V1.5 by an additional 40.1%. Please check the ghidra folder for details.
  • [2024-05-13]: Release V1.5 series (LLM4Decompile-End, directly decompile binary using LLM). V1.5 are trained with a larger dataset (15B tokens) and a maximum token length of 4,096, with remarkable performance (over 100% improvement) compared to the previous model.
  • [2024-03-16]: Add llm4decompile-6.7b-uo model which is trained without prior knowledge of the optimization levels (O0~O3), the average re-executability is around 0.219, performs the best in our models.

About

  • LLM4Decompile is the pioneering open-source large language model dedicated to decompilation. Its current version supports decompiling Linux x86_64 binaries, ranging from GCC's O0 to O3 optimization levels, into human-readable C source code. Our team is committed to expanding this tool's capabilities, with ongoing efforts to incorporate a broader range of architectures and configurations.
  • LLM4Decompile-End focuses on decompiling the binary directly. LLM4Decompile-Ref refines the pseudo-code decompiled by Ghidra.

Evaluation

Framework

During compilation, the Preprocessor processes the source code (SRC) to eliminate comments and expand macros or includes. The cleaned code is then forwarded to the Compiler, which converts it into assembly code (ASM). This ASM is transformed into binary code (0s and 1s) by the Assembler. The Linker finalizes the process by linking function calls to create an executable file. Decompilation, on the other hand, involves converting binary code back into a source file. LLMs, being trained on text, lack the ability to process binary data directly. Therefore, binaries must be disassembled by Objdump into assembly language (ASM) first. It should be noted that binary and disassembled ASM are equivalent, they can be interconverted, and thus we refer to them interchangeably. Finally, the loss is computed between the decompiled code and source code to guide the training. To assess the quality of the decompiled code (SRC'), it is tested for its functionality through test assertions (re-executability).

Metrics

  • Re-executability evaluates whether the decompiled code can execute properly and pass all the predefined test cases.

Benchmarks

  • HumanEval-Decompile A collection of 164 C functions that exclusively rely on standard C libraries.
  • ExeBench A collection of 2,621 functions drawn from real projects, each utilizing user-defined functions, structures, and macros.

Results

Models

Our LLM4Decompile includes models with sizes between 1.3 billion and 33 billion parameters, and we have made these models available on Hugging Face.

Model Checkpoint Size Re-executability Note
llm4decompile-1.3b-v1.5 HF Link 1.3B 27.3% Note 3
llm4decompile-6.7b-v1.5 HF Link 6.7B 45.4% Note 3
llm4decompile-1.3b-v2 HF Link 1.3B 46.0% Note 4
llm4decompile-6.7b-v2 HF Link 6.7B 52.7% Note 4
llm4decompile-9b-v2 HF Link 9B 64.9% Note 4
llm4decompile-22b-v2 HF Link 22B 63.6% Note 4

Note 3: V1.5 series are trained with a larger dataset (15B tokens) and a maximum token size of 4,096, with remarkable performance (over 100% improvement) compared to the previous model.

Note 4: V2 series are built upon Ghidra and trained on 2 billion tokens to refine the decompiled pseudo-code from Ghidra. Check ghidra folder for details.

Quick Start

Setup: Please use the script below to install the necessary environment.

bash
git clone https://github.com/albertan017/LLM4Decompile.git
cd LLM4Decompile
conda create -n 'llm4decompile' python=3.9 -y
conda activate llm4decompile
pip install -r requirements.txt

Here is an example of how to use our model (Revised for V1.5. For previous models, please check the corresponding model page at HF). Note: Replace the "func0" with the function name you want to decompile.

Preprocessing: Compile the C code into binary, and disassemble the binary into assembly instructions.

…

Assembly instructions should be in the format:

<FUNCTION_NAME>:\nOPERATIONS\nOPERATIONS\n

Typical assembly instructions may look like this:

<func0>:
endbr64
lea    (%rdi,%rsi,1),%eax
retq

Decompilation: Use LLM4Decompile to translate the assembly instructions into C:

…

Docker setup

bash
# build docker
docker build -t llm4decompile .

# run docker with GPU
docker run --gpus all -it --name llm4decompile llm4decompile /bin/bash

# run demo.py (choose a model suitable for your resources before running)
cd ghidra
python demo.py

HumanEval-Decompile

Data are stored in llm4decompile/decompile-eval/decompile-eval-executable-gcc-obj.json, using JSON list format. There are 164*4 (O0, O1, O2, O3) samples, each with five keys:

  • task_id: indicates the ID of the problem.
  • type: the optimization stage, is one of [O0, O1, O2, O3].
  • c_func: C solution for HumanEval problem.
  • c_test: C test assertions.
  • input_asm_prompt: assembly instructions with prompts, can be derived as in our preprocessing example.

Please check the evaluation scripts.

On Going

  • Larger training dataset with the cleaning process. (done:2024.05.13)
  • Support for popular languages/platforms and settings.
  • Support for executable binaries. (done:2024.05.13)
  • Integration with decompilation tools (e.g., Ghidra, Rizin)

License

This code repository is licensed under the MIT and DeepSeek License.

Citation

@misc{tan2024llm4decompile,
      title={LLM4Decompile: Decompiling Binary Code with Large Language Models}, 
      author={Hanzhuo Tan and Qi Luo and Jing Li and Yuqun Zhang},
      year={2024},
      eprint={2403.05286},
      archivePrefix={arXiv},
      primaryClass={cs.PL}
}

Star History

Issues· 46 open

View all issuesOpen on GitHub
  • #77

    Not working on CPU only

    Updated Jun 26, 2026
  • #75

    How are C source functions extracted for dataset construction?

    Updated Apr 28, 2026
  • #69

    Support for Objective-C and Swift

    Updated Feb 22, 2026
  • #71

    作者您好,请问sk2decompile的全部训练脚本预计什么时候公开

    Updated Feb 12, 2026
  • #72

    Use SK2 models for Ghidra/IDA Pro

    Updated Jan 25, 2026
  • #70

    部分函数优化结果残缺不全

    Updated Dec 5, 2025
  • #68

    About the prompt of LLM4Decompile -Ref in colab script

    Updated Nov 28, 2025
  • #66

    Release HumanEval-Decompile and ExeBench datasets on Hugging Face & Link artifacts to paper page

    Updated Oct 22, 2025
  • #65

    Release source code versions of decompile-bench Github projects

    Updated Oct 13, 2025
  • #63

    Compilation platform of decompile-bench

    Updated Oct 10, 2025

> Tags

Pythonbinarydecompilelarge-language-modelsreverse-engineering

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 23, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言