[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-albertan017--LLM4Decompile":3,"tool-albertan017--LLM4Decompile":65},[4,17,27,35,48,57],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",154349,2,"2026-04-13T23:32:16",[13,14,15],"开发框架","Agent","语言模型","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,3,"2026-04-06T11:19:32",[15,26,14,13],"图像",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":10,"last_commit_at":33,"category_tags":34,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":10,"last_commit_at":41,"category_tags":42,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",85092,"2026-04-10T11:13:16",[26,43,44,45,14,46,15,13,47],"数据工具","视频","插件","其他","音频",{"id":49,"name":50,"github_repo":51,"description_zh":52,"stars":53,"difficulty_score":54,"last_commit_at":55,"category_tags":56,"status":16},5784,"funNLP","fighting41love\u002FfunNLP","funNLP 是一个专为中文自然语言处理（NLP）打造的超级资源库，被誉为\"NLP 民工的乐园”。它并非单一的软件工具，而是一个汇集了海量开源项目、数据集、预训练模型和实用代码的综合性平台。\n\n面对中文 NLP 领域资源分散、入门门槛高以及特定场景数据匮乏的痛点，funNLP 提供了“一站式”解决方案。这里不仅涵盖了分词、命名实体识别、情感分析、文本摘要等基础任务的标准工具，还独特地收录了丰富的垂直领域资源，如法律、医疗、金融行业的专用词库与数据集，甚至包含古诗词生成、歌词创作等趣味应用。其核心亮点在于极高的全面性与实用性，从基础的字典词典到前沿的 BERT、GPT-2 模型代码，再到高质量的标注数据和竞赛方案，应有尽有。\n\n无论是刚刚踏入 NLP 领域的学生、需要快速验证想法的算法工程师，还是从事人工智能研究的学者，都能在这里找到急需的“武器弹药”。对于开发者而言，它能大幅减少寻找数据和复现模型的时间；对于研究者，它提供了丰富的基准测试资源和前沿技术参考。funNLP 以开放共享的精神，极大地降低了中文自然语言处理的开发与研究成本，是中文 AI 社区不可或缺的宝藏仓库。",79857,1,"2026-04-08T20:11:31",[15,43,46],{"id":58,"name":59,"github_repo":60,"description_zh":61,"stars":62,"difficulty_score":54,"last_commit_at":63,"category_tags":64,"status":16},6590,"gpt4all","nomic-ai\u002Fgpt4all","GPT4All 是一款让普通电脑也能轻松运行大型语言模型（LLM）的开源工具。它的核心目标是打破算力壁垒，让用户无需依赖昂贵的显卡（GPU）或云端 API，即可在普通的笔记本电脑和台式机上私密、离线地部署和使用大模型。\n\n对于担心数据隐私、希望完全掌控本地数据的企业用户、研究人员以及技术爱好者来说，GPT4All 提供了理想的解决方案。它解决了传统大模型必须联网调用或需要高端硬件才能运行的痛点，让日常设备也能成为强大的 AI 助手。无论是希望构建本地知识库的开发者，还是单纯想体验私有化 AI 聊天的普通用户，都能从中受益。\n\n技术上，GPT4All 基于高效的 `llama.cpp` 后端，支持多种主流模型架构（包括最新的 DeepSeek R1 蒸馏模型），并采用 GGUF 格式优化推理速度。它不仅提供界面友好的桌面客户端，支持 Windows、macOS 和 Linux 等多平台一键安装，还为开发者提供了便捷的 Python 库，可轻松集成到 LangChain 等生态中。通过简单的下载和配置，用户即可立即开始探索本地大模型的无限可能。",77307,"2026-04-11T06:52:37",[15,13],{"id":66,"github_repo":67,"name":68,"description_en":69,"description_zh":70,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":77,"owner_location":77,"owner_email":77,"owner_twitter":77,"owner_website":77,"owner_url":80,"languages":81,"stars":94,"forks":95,"last_commit_at":96,"license":97,"difficulty_score":23,"env_os":98,"env_gpu":99,"env_ram":100,"env_deps":101,"category_tags":109,"github_topics":110,"view_count":10,"oss_zip_url":77,"oss_zip_packed_at":77,"status":16,"created_at":115,"updated_at":116,"faqs":117,"releases":146},7305,"albertan017\u002FLLM4Decompile","LLM4Decompile","Reverse Engineering: Decompiling Binary Code with Large Language Models","LLM4Decompile 是一款开创性的开源人工智能工具，致力于利用大语言模型将计算机二进制代码“反编译”还原为人类可读的源代码。在软件逆向工程领域，传统工具生成的代码往往晦涩难懂且变量名混乱，给安全分析和遗留系统维护带来巨大挑战。LLM4Decompile 通过深度学习技术，不仅能直接从二进制文件生成代码，还能对现有反编译结果进行智能优化，显著恢复程序的结构逻辑并赋予变量有意义的名称，从而大幅提升代码的可执行性和可理解性。\n\n该项目提供了多种规模的模型版本，支持从端到端直接反编译到基于 Ghidra 的二次精炼等多种工作流。其独特亮点在于引入了“从骨架到皮肤”的两阶段反编译策略，先恢复代码结构再重命名标识符，并在大规模二进制 - 源码配对数据集上进行了训练，实现了业界领先的代码还原准确率。\n\nLLM4Decompile 非常适合网络安全研究人员、逆向工程师以及需要分析闭源软件或维护老旧系统的开发者使用。无论是进行漏洞挖掘、恶意软件分析，还是尝试理解无文档支持的二进制程序，它都能成为得力的智能助手，帮助用户更高效地揭开二进制代码背后的逻辑真相。","\n\u003Cp align=\"center\">\n  \u003Cpicture>\n    \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Fblob\u002Fmain\u002Fsamples\u002Flogo-dark.png\">\n    \u003Cimg alt=\"LLM4Decompile\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_90af590ac83d.png\" width=55%>\n  \u003C\u002Fpicture>\n\u003C\u002Fp>\n\n\u003Cp align=\"left\">\n    📊&nbsp;\u003Ca href=\"#evaluation\">Results\u003C\u002Fa>\n    | 🤗&nbsp;\u003Ca href=\"#models\">Models\u003C\u002Fa>\n    | 🚀&nbsp;\u003Ca href=\"#quick-start\">Quick Start\u003C\u002Fa>\n    | 📚&nbsp;\u003Ca href=\"#humaneval-decompile\">HumanEval-Decompile\u003C\u002Fa>\n    | 📎&nbsp;\u003Ca href=\"#citation\">Citation\u003C\u002Fa>\n    | 📝&nbsp;\u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.05286\">Paper\u003C\u002Fa>\n    | 🖥️&nbsp;\u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1X5TuUKuNuksGJZz6Cc83KKI0ATBP9q7r?usp=sharing\">Colab\u003C\u002Fa>\n    | ▶️&nbsp;\u003Ca href=\"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=x7knF3Z1yLk\">YouTube\u003C\u002Fa>\n\u003C\u002Fp>\n\nReverse Engineering: Decompiling Binary Code with Large Language Models\n\n[![GitHub Tread](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_17f4a7d6fa98.png)](https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F8664)\n\n## Updates\n* [2025-10-04]: Release SK²Decompile: LLM-based Two-Phase Binary Decompilation from Skeleton to Skin. Phase 1 Structure Recovery (Skeleton): Transform binary\u002Fpseudo-code into obfuscated intermediate representations 🤗 [HF Link](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fsk2decompile-struct-6.7b). Phase 2 Identifier Naming (Skin): Generate human-readable source code with meaningful identifiers 🤗 [HF Link](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fsk2decompile-ident-6.7).\n* [2025-05-20]: Release [decompile-bench](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002FLLM4Binary\u002Fdecompile-bench-68259091c8d49d0ebd5efda9), contains two million binary-source function pairs for training, and 70K function pairs for evaluation. Please refer to the [decompile-bench](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Ftree\u002Fmain\u002Fdecompile-bench) folder for details.\n* [2024-10-17]: Release [decompile-ghidra-100k](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002FLLM4Binary\u002Fdecompile-ghidra-100k), a subset of 100k training samples (25k per optimization level). We provide a [training script](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Fblob\u002Fmain\u002Ftrain\u002FREADME.md) 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.\n* [2024-09-26]: Update a [Colab notebook](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1X5TuUKuNuksGJZz6Cc83KKI0ATBP9q7r?usp=sharing) to demonstrate the usage of the LLM4Decompile model, including examples for the LLM4Decompile-End and LLM4Decompile-Ref models.\n* [2024-09-23]: Release [LLM4Decompile-9B-v2](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-9b-v2), fine-tuned based on [Yi-Coder-9B](https:\u002F\u002Fhuggingface.co\u002F01-ai\u002FYi-Coder-9B), achieved a re-executability rate of **0.6494** on the Decompile benchmark.\n* [2024-06-19]: Release [V2](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-6.7b-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](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Ftree\u002Fmain\u002Fghidra) for details.\n* [2024-05-13]: Release [V1.5](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-6.7b-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.\n* [2024-03-16]: Add [llm4decompile-6.7b-uo](https:\u002F\u002Fhuggingface.co\u002Farise-sustech\u002Fllm4decompile-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.\n\n## About\n* **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.\n* **LLM4Decompile-End** focuses on decompiling the binary directly. **LLM4Decompile-Ref** refines the pseudo-code decompiled by Ghidra.\n\n## Evaluation\n\n### Framework\n\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_d3ac24354ce6.png\" alt=\"image\" width=\"400\" height=\"auto\">\n\u003C\u002Fp>\n\nDuring 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).\n\n### Metrics\n* **Re-executability** evaluates whether the decompiled code can execute properly and pass all the predefined test cases.\n\n### Benchmarks\n* **HumanEval-Decompile** A collection of 164 C functions that exclusively rely on **standard** C libraries.\n* **ExeBench** A collection of 2,621 functions drawn from **real** projects, each utilizing user-defined functions, structures, and macros.\n\n\n### Results\n\n\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_64e61ce9704a.png\" alt=\"results\" width=\"800\" height=\"auto\">\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_66432ac6f82b.png\" alt=\"image\" width=\"800\" height=\"auto\">\n\u003C\u002Fp>\n\n## Models\nOur LLM4Decompile includes models with sizes between 1.3 billion and 33 billion parameters, and we have made these models available on Hugging Face.\n\n| Model                 | Checkpoint                                                        | Size | Re-executability       | Note |\n|-----------------------|-------------------------------------------------------------------|------|---------------------|----------------------|\n| **llm4decompile-1.3b-v1.5**| 🤗 [HF Link](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-1.3b-v1.5)   | 1.3B | **27.3%**   | Note 3 |\n| **llm4decompile-6.7b-v1.5**| 🤗 [HF Link](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-6.7b-v1.5)   | 6.7B | **45.4%**   | Note 3 |\n| **llm4decompile-1.3b-v2**| 🤗 [HF Link](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-1.3b-v2)   | 1.3B | **46.0%**   | Note 4 |\n| **llm4decompile-6.7b-v2**| 🤗 [HF Link](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-6.7b-v2)   | 6.7B | **52.7%**   | Note 4 |\n| **llm4decompile-9b-v2**| 🤗 [HF Link](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-9b-v2)   | 9B | **64.9%**  | Note 4 |\n| **llm4decompile-22b-v2**| 🤗 [HF Link](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-22b-v2)   | 22B | **63.6%**   | Note 4 |\n\nNote 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.\n\nNote 4: V2 series are built upon **Ghidra** and trained on 2 billion tokens to **refine** the decompiled pseudo-code from Ghidra. Check [ghidra folder](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Ftree\u002Fmain\u002Fghidra) for details.\n\n## Quick Start\n\n[![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1X5TuUKuNuksGJZz6Cc83KKI0ATBP9q7r?usp=sharing)\n\n**Setup:** Please use the script below to install the necessary environment.\n```\ngit clone https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile.git\ncd LLM4Decompile\nconda create -n 'llm4decompile' python=3.9 -y\nconda activate llm4decompile\npip install -r requirements.txt\n```\n\nHere is an example of how to use our model (Revised for V1.5. For previous models, please check the corresponding model page at HF).\nNote: **Replace the \"func0\" with the function name you want to decompile**.\n\n**Preprocessing:** Compile the C code into binary, and disassemble the binary into assembly instructions.\n```python\nimport subprocess\nimport os\nfunc_name = 'func0'\nOPT = [\"O0\", \"O1\", \"O2\", \"O3\"]\nfileName = 'samples\u002Fsample' #'path\u002Fto\u002Ffile'\nfor opt_state in OPT:\n    output_file = fileName +'_' + opt_state\n    input_file = fileName+'.c'\n    compile_command = f'gcc -o {output_file}.o {input_file} -{opt_state} -lm'#compile the code with GCC on Linux\n    subprocess.run(compile_command, shell=True, check=True)\n    compile_command = f'objdump -d {output_file}.o > {output_file}.s'#disassemble the binary file into assembly instructions\n    subprocess.run(compile_command, shell=True, check=True)\n    \n    input_asm = ''\n    with open(output_file+'.s') as f:#asm file\n        asm= f.read()\n        if '\u003C'+func_name+'>:' not in asm: #IMPORTANT replace func0 with the function name\n            raise ValueError(\"compile fails\")\n        asm = '\u003C'+func_name+'>:' + asm.split('\u003C'+func_name+'>:')[-1].split('\\n\\n')[0] #IMPORTANT replace func0 with the function name\n        asm_clean = \"\"\n        asm_sp = asm.split(\"\\n\")\n        for tmp in asm_sp:\n            if len(tmp.split(\"\\t\"))\u003C3 and '00' in tmp:\n                continue\n            idx = min(\n                len(tmp.split(\"\\t\")) - 1, 2\n            )\n            tmp_asm = \"\\t\".join(tmp.split(\"\\t\")[idx:])  # remove the binary code\n            tmp_asm = tmp_asm.split(\"#\")[0].strip()  # remove the comments\n            asm_clean += tmp_asm + \"\\n\"\n    input_asm = asm_clean.strip()\n    before = f\"# This is the assembly code:\\n\"#prompt\n    after = \"\\n# What is the source code?\\n\"#prompt\n    input_asm_prompt = before+input_asm.strip()+after\n    with open(fileName +'_' + opt_state +'.asm','w',encoding='utf-8') as f:\n        f.write(input_asm_prompt)\n```\n\nAssembly instructions should be in the format:\n\n\u003CFUNCTION_NAME>:\\nOPERATIONS\\nOPERATIONS\\n\n\nTypical assembly instructions may look like this:\n```\n\u003Cfunc0>:\nendbr64\nlea    (%rdi,%rsi,1),%eax\nretq\n```\n\n\n**Decompilation:** Use LLM4Decompile to translate the assembly instructions into C:\n```python\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\nimport torch\n\nmodel_path = 'LLM4Binary\u002Fllm4decompile-6.7b-v1.5' # V1.5 Model\ntokenizer = AutoTokenizer.from_pretrained(model_path)\nmodel = AutoModelForCausalLM.from_pretrained(model_path,torch_dtype=torch.bfloat16).cuda()\n\nwith open(fileName +'_' + OPT[0] +'.asm','r') as f:#optimization level O0\n    asm_func = f.read()\ninputs = tokenizer(asm_func, return_tensors=\"pt\").to(model.device)\nwith torch.no_grad():\n    outputs = model.generate(**inputs, max_new_tokens=2048)### max length to 4096, max new tokens should be below the range\nc_func_decompile = tokenizer.decode(outputs[0][len(inputs[0]):-1])\n\nwith open(fileName +'.c','r') as f:#original file\n    func = f.read()\n\nprint(f'original function:\\n{func}')# Note we only decompile one function, where the original file may contain multiple functions\nprint(f'decompiled function:\\n{c_func_decompile}')\n```\n\n### Docker setup\n\n```\n# build docker\ndocker build -t llm4decompile .\n\n# run docker with GPU\ndocker run --gpus all -it --name llm4decompile llm4decompile \u002Fbin\u002Fbash\n\n# run demo.py (choose a model suitable for your resources before running)\ncd ghidra\npython demo.py\n```\n\n## HumanEval-Decompile\nData are stored in ``llm4decompile\u002Fdecompile-eval\u002Fdecompile-eval-executable-gcc-obj.json``, using JSON list format. There are 164*4 (O0, O1, O2, O3) samples, each with five keys:\n\n*   ``task_id``: indicates the ID of the problem.\n*   ``type``: the optimization stage, is one of [O0, O1, O2, O3].\n*   ``c_func``: C solution for HumanEval problem. \n*   ``c_test``: C test assertions.\n*   ``input_asm_prompt``: assembly instructions with prompts, can be derived as in our [preprocessing example](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile?tab=readme-ov-file#quick-start).\n\nPlease check the [evaluation scripts](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Ftree\u002Fmain\u002Fevaluation).\n\n## On Going\n* Larger training dataset with the cleaning process. (done:2024.05.13)\n* Support for popular languages\u002Fplatforms and settings.\n* Support for executable binaries. (done:2024.05.13)\n* Integration with decompilation tools (e.g., Ghidra, Rizin)\n\n## License\nThis code repository is licensed under the MIT and DeepSeek License.\n\n## Citation\n```\n@misc{tan2024llm4decompile,\n      title={LLM4Decompile: Decompiling Binary Code with Large Language Models}, \n      author={Hanzhuo Tan and Qi Luo and Jing Li and Yuqun Zhang},\n      year={2024},\n      eprint={2403.05286},\n      archivePrefix={arXiv},\n      primaryClass={cs.PL}\n}\n```\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_9f45be0bb6ca.png)](https:\u002F\u002Fstar-history.com\u002F#albertan017\u002FLLM4Decompile&Timeline)\n","\u003Cp align=\"center\">\n  \u003Cpicture>\n    \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Fblob\u002Fmain\u002Fsamples\u002Flogo-dark.png\">\n    \u003Cimg alt=\"LLM4Decompile\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_90af590ac83d.png\" width=55%>\n  \u003C\u002Fpicture>\n\u003C\u002Fp>\n\n\u003Cp align=\"left\">\n    📊&nbsp;\u003Ca href=\"#evaluation\">结果\u003C\u002Fa>\n    | 🤗&nbsp;\u003Ca href=\"#models\">模型\u003C\u002Fa>\n    | 🚀&nbsp;\u003Ca href=\"#quick-start\">快速入门\u003C\u002Fa>\n    | 📚&nbsp;\u003Ca href=\"#humaneval-decompile\">HumanEval-Decompile\u003C\u002Fa>\n    | 📎&nbsp;\u003Ca href=\"#citation\">引用\u003C\u002Fa>\n    | 📝&nbsp;\u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.05286\">论文\u003C\u002Fa>\n    | 🖥️&nbsp;\u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1X5TuUKuNuksGJZz6Cc83KKI0ATBP9q7r?usp=sharing\">Colab\u003C\u002Fa>\n    | ▶️&nbsp;\u003Ca href=\"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=x7knF3Z1yLk\">YouTube\u003C\u002Fa>\n\u003C\u002Fp>\n\n逆向工程：利用大型语言模型反编译二进制代码\n\n[![GitHub趋势](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_17f4a7d6fa98.png)](https:\u002F\u002Ftrendshift.io\u002Frepositories\u002F8664)\n\n## 更新\n* [2025-10-04]: 发布 SK²Decompile：基于 LLM 的两阶段二进制反编译，从骨架到皮肤。第一阶段结构恢复（骨架）：将二进制\u002F伪代码转换为混淆的中间表示形式 🤗 [HF 链接](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fsk2decompile-struct-6.7b)。第二阶段标识符命名（皮肤）：生成带有有意义标识符的人类可读源代码 🤗 [HF 链接](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fsk2decompile-ident-6.7)。\n* [2025-05-20]: 发布 [decompile-bench](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002FLLM4Binary\u002Fdecompile-bench-68259091c8d49d0ebd5efda9)，包含用于训练的二百万对二进制-源代码函数对，以及用于评估的七万对函数对。详情请参阅 [decompile-bench](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Ftree\u002Fmain\u002Fdecompile-bench) 文件夹。\n* [2024-10-17]: 发布 [decompile-ghidra-100k](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002FLLM4Binary\u002Fdecompile-ghidra-100k)，这是一个包含十万个训练样本的子集（每个优化级别 2.5 万个）。我们提供了一个 [训练脚本](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Fblob\u002Fmain\u002Ftrain\u002FREADME.md)，在单块 A100 40G GPU 上运行约 3.5 小时即可完成。该模型实现了 0.26 的可重执行率，总成本低于 20 美元，便于快速复现 LLM4Decompile。\n* [2024-09-26]: 更新了 [Colab 笔记本](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1X5TuUKuNuksGJZz6Cc83KKI0ATBP9q7r?usp=sharing)，以演示 LLM4Decompile 模型的使用方法，包括 LLM4Decompile-End 和 LLM4Decompile-Ref 模型的示例。\n* [2024-09-23]: 发布 [LLM4Decompile-9B-v2](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-9b-v2)，基于 [Yi-Coder-9B](https:\u002F\u002Fhuggingface.co\u002F01-ai\u002FYi-Coder-9B) 进行微调，在 Decompile 基准测试中达到了 **0.6494** 的可重执行率。\n* [2024-06-19]: 发布 [V2](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-6.7b-v2) 系列（LLM4Decompile-Ref）。V2（1.3B-22B）以 **Ghidra** 为基础，使用 20 亿个标记进行训练，以 **精炼** Ghidra 反编译出的伪代码。22B-V2 版本比 6.7B-V1.5 提高了额外的 40.1%。详情请查看 [ghidra 文件夹](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Ftree\u002Fmain\u002Fghidra)。\n* [2024-05-13]: 发布 [V1.5](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-6.7b-v1.5) 系列（LLM4Decompile-End，直接使用 LLM 反编译二进制文件）。V1.5 使用更大的数据集（150 亿个标记）和最大标记长度 **4,096** 进行训练，与先前模型相比，性能显著提升（超过 **100%**）。\n* [2024-03-16]: 新增 [llm4decompile-6.7b-uo](https:\u002F\u002Fhuggingface.co\u002Farise-sustech\u002Fllm4decompile-6.7b-uo) 模型，该模型在不预先了解优化级别（O0~O3）的情况下进行训练，平均可重执行率约为 0.219，是我们所有模型中表现最好的。\n\n## 关于\n* **LLM4Decompile** 是开创性的开源大型语言模型，专门用于反编译。当前版本支持将 Linux x86_64 二进制文件（从 GCC 的 O0 到 O3 优化级别）反编译为人类可读的 C 源代码。我们的团队致力于扩展此工具的功能，目前正在努力纳入更广泛的架构和配置。\n* **LLM4Decompile-End** 专注于直接反编译二进制文件。**LLM4Decompile-Ref** 则用于精炼由 Ghidra 反编译得到的伪代码。\n\n## 评估\n\n### 框架\n\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_d3ac24354ce6.png\" alt=\"image\" width=\"400\" height=\"auto\">\n\u003C\u002Fp>\n\n在编译过程中，预处理器会处理源代码（SRC），去除注释并展开宏或包含文件。清理后的代码随后被传递给编译器，将其转换为汇编代码（ASM）。然后，汇编器将这些汇编代码进一步转化为二进制代码（0 和 1）。最后，链接器通过链接函数调用创建可执行文件。而反编译则是将二进制代码重新转换回源文件的过程。由于 LLM 是基于文本训练的，无法直接处理二进制数据。因此，必须先使用 ```Objdump``` 将二进制文件反汇编成汇编语言（ASM）。需要注意的是，二进制文件和反汇编后的 ASM 是等价的，可以相互转换，因此我们在讨论中会交替使用这两个术语。最后，通过计算反编译代码与源代码之间的损失来指导训练。为了评估反编译代码（SRC'）的质量，我们会通过测试断言（可重执行性）来检验其功能是否正常。\n\n### 指标\n* **可重执行性** 用于评估反编译后的代码是否能够正确执行，并通过所有预定义的测试用例。\n\n### 基准测试\n* **HumanEval-Decompile** 是一个包含 164 个 C 函数的集合，这些函数仅依赖于 **标准** C 库。\n* **ExeBench** 是一个包含 2,621 个函数的集合，这些函数来自 **真实**项目，每个函数都使用了用户自定义的函数、结构体和宏。\n\n\n### 结果\n\n\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_64e61ce9704a.png\" alt=\"results\" width=\"800\" height=\"auto\">\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_66432ac6f82b.png\" alt=\"image\" width=\"800\" height=\"auto\">\n\u003C\u002Fp>\n\n## 模型\n我们的 LLM4Decompile 包含参数量从 13 亿到 330 亿不等的模型，并且我们已将这些模型发布在 Hugging Face 上。\n\n| 模型                 | 检查点                                                        | 参数量 | 可重执行性       | 备注 |\n|-----------------------|-------------------------------------------------------------------|------|---------------------|----------------------|\n| **llm4decompile-1.3b-v1.5**| 🤗 [HF 链接](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-1.3b-v1.5)   | 13亿 | **27.3%**   | 注3 |\n| **llm4decompile-6.7b-v1.5**| 🤗 [HF 链接](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-6.7b-v1.5)   | 67亿 | **45.4%**   | 注3 |\n| **llm4decompile-1.3b-v2**| 🤗 [HF 链接](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-1.3b-v2)   | 13亿 | **46.0%**   | 注4 |\n| **llm4decompile-6.7b-v2**| 🤗 [HF 链接](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-6.7b-v2)   | 67亿 | **52.7%**   | 注4 |\n| **llm4decompile-9b-v2**| 🤗 [HF 链接](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-9b-v2)   | 90亿 | **64.9%**  | 注4 |\n| **llm4decompile-22b-v2**| 🤗 [HF 链接](https:\u002F\u002Fhuggingface.co\u002FLLM4Binary\u002Fllm4decompile-22b-v2)   | 220亿 | **63.6%**   | 注4 |\n\n注3：V1.5 系列使用更大的数据集（150 亿个 token）和最大 4,096 个 token 的序列长度进行训练，与先前模型相比，性能显著提升（超过 100%）。\n\n注4：V2 系列基于 **Ghidra** 构建，并在 20 亿个 token 上进行训练，以 **优化** Ghidra 生成的反编译伪代码。详情请参阅 [ghidra 文件夹](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Ftree\u002Fmain\u002Fghidra)。\n\n## 快速入门\n\n[![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1X5TuUKuNuksGJZz6Cc83KKI0ATBP9q7r?usp=sharing)\n\n**设置：** 请使用以下脚本安装必要的环境。\n```\ngit clone https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile.git\ncd LLM4Decompile\nconda create -n 'llm4decompile' python=3.9 -y\nconda activate llm4decompile\npip install -r requirements.txt\n```\n\n以下是使用我们模型的示例（针对 V1.5 版本进行了修订。对于旧版本，请查看 Hugging Face 上对应的模型页面）。\n注意：**请将“func0”替换为您想要反编译的函数名**。\n\n**预处理：** 将 C 代码编译为二进制文件，并将二进制文件反汇编为汇编指令。\n```python\nimport subprocess\nimport os\nfunc_name = 'func0'\nOPT = [\"O0\", \"O1\", \"O2\", \"O3\"]\nfileName = 'samples\u002Fsample' #'path\u002Fto\u002Ffile'\nfor opt_state in OPT:\n    output_file = fileName +'_' + opt_state\n    input_file = fileName+'.c'\n    compile_command = f'gcc -o {output_file}.o {input_file} -{opt_state} -lm'#用 GCC 在 Linux 上编译代码\n    subprocess.run(compile_command, shell=True, check=True)\n    compile_command = f'objdump -d {output_file}.o > {output_file}.s'#将二进制文件反汇编为汇编指令\n    subprocess.run(compile_command, shell=True, check=True)\n    \n    input_asm = ''\n    with open(output_file+'.s') as f:#asm 文件\n        asm= f.read()\n        if '\u003C'+func_name+'>:' not in asm: #重要：将 func0 替换为实际函数名\n            raise ValueError(\"编译失败\")\n        asm = '\u003C'+func_name+'>:' + asm.split('\u003C'+func_name+'>:')[-1].split('\\n\\n')[0] #重要：将 func0 替换为实际函数名\n        asm_clean = \"\"\n        asm_sp = asm.split(\"\\n\")\n        for tmp in asm_sp:\n            if len(tmp.split(\"\\t\"))\u003C3 和 '00' 在其中时：\n                continue\n            idx = min(\n                len(tmp.split(\"\\t\")) - 1, 2\n            )\n            tmp_asm = \"\\t\".join(tmp.split(\"\\t\")[idx:])  # 去除二进制代码\n            tmp_asm = tmp_asm.split(\"#\")[0].strip()  # 去除注释\n            asm_clean += tmp_asm + \"\\n\"\n    input_asm = asm_clean.strip()\n    before = f\"# 这是汇编代码:\\n\"#提示\n    after = \"\\n# 源代码是什么？\\n\"#提示\n    input_asm_prompt = before+input_asm.strip()+after\n    with open(fileName +'_' + opt_state +'.asm','w',encoding='utf-8') as f:\n        f.write(input_asm_prompt)\n```\n\n汇编指令应采用以下格式：\n\n\u003CFUNCTION_NAME>:\\nOPERATIONS\\nOPERATIONS\\n\n\n典型的汇编指令可能如下所示：\n```\n\u003Cfunc0>:\nendbr64\nlea    (%rdi,%rsi,1),%eax\nretq\n```\n\n\n**反编译：** 使用 LLM4Decompile 将汇编指令转换为 C 语言代码：\n```python\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\nimport torch\n\nmodel_path = 'LLM4Binary\u002Fllm4decompile-6.7b-v1.5' # V1.5 模型\ntokenizer = AutoTokenizer.from_pretrained(model_path)\nmodel = AutoModelForCausalLM.from_pretrained(model_path,torch_dtype=torch.bfloat16).cuda()\n\nwith open(fileName +'_' + OPT[0] +'.asm','r') as f:#优化级别 O0\n    asm_func = f.read()\ninputs = tokenizer(asm_func, return_tensors=\"pt\").to(model.device)\nwith torch.no_grad():\n    outputs = model.generate(**inputs, max_new_tokens=2048)### 最大长度为 4096，新令牌数量应在范围内\nc_func_decompile = tokenizer.decode(outputs[0][len(inputs[0]):-1])\n\nwith open(fileName +'.c','r') as f:#原始文件\n    func = f.read()\n\nprint(f'原始函数:\\n{func}')# 注意我们只反编译一个函数，而原始文件可能包含多个函数\nprint(f'反编译后的函数:\\n{c_func_decompile}')\n```\n\n### Docker 设置\n\n```\n# 构建 Docker\ndocker build -t llm4decompile .\n\n# 使用 GPU 运行 Docker\ndocker run --gpus all -it --name llm4decompile llm4decompile \u002Fbin\u002Fbash\n\n# 运行 demo.py（运行前请根据您的资源选择合适的模型）\ncd ghidra\npython demo.py\n```\n\n## HumanEval-Decompile\n数据存储在 ``llm4decompile\u002Fdecompile-eval\u002Fdecompile-eval-executable-gcc-obj.json`` 中，采用 JSON 列表格式。共有 164*4（O0、O1、O2、O3）个样本，每个样本包含五个键：\n\n*   ``task_id``：表示问题的 ID。\n*   ``type``：优化阶段，取值为 [O0、O1、O2、O3]。\n*   ``c_func``：HumanEval 问题的 C 语言解决方案。\n*   ``c_test``：C 语言测试断言。\n*   ``input_asm_prompt``：带有提示的汇编指令，可参考我们的 [预处理示例](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile?tab=readme-ov-file#quick-start)。\n\n请查看 [评估脚本](https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Ftree\u002Fmain\u002Fevaluation)。\n\n## 进展中\n* 更大的训练数据集及清洗流程。（已完成：2024年5月13日）\n* 对主流语言\u002F平台及配置的支持。\n* 对可执行二进制文件的支持。（已完成：2024年5月13日）\n* 与反编译工具（如 Ghidra、Rizin）的集成。\n\n## 许可证\n此代码仓库采用 MIT 许可证和 DeepSeek 许可证授权。\n\n## 引用\n```\n@misc{tan2024llm4decompile,\n      title={LLM4Decompile: 使用大型语言模型反编译二进制代码}, \n      author={Hanzhuo Tan、Qi Luo、Jing Li、Yuqun Zhang},\n      year={2024},\n      eprint={2403.05286},\n      archivePrefix={arXiv},\n      primaryClass={cs.PL}\n}\n```\n\n## 星标历史\n\n[![星标历史图表](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_readme_9f45be0bb6ca.png)](https:\u002F\u002Fstar-history.com\u002F#albertan017\u002FLLM4Decompile&Timeline)","# LLM4Decompile 快速上手指南\n\nLLM4Decompile 是一款专为反编译设计的开源大语言模型，支持将 Linux x86_64 架构下的二进制文件（涵盖 GCC O0-O3 优化等级）还原为可读的 C 语言源代码。本项目提供两种主要模式：**LLM4Decompile-End**（直接从汇编反编译）和 **LLM4Decompile-Ref**（基于 Ghidra 生成的伪代码进行优化）。\n\n## 环境准备\n\n*   **操作系统**: Linux (推荐 Ubuntu)\n*   **硬件要求**: NVIDIA GPU (建议显存 16GB 以上以运行较大模型，如 6.7B\u002F9B)\n*   **软件依赖**:\n    *   Python 3.9\n    *   Conda (推荐用于环境管理)\n    *   GCC (用于编译测试代码)\n    *   Objdump (GNU Binutils 的一部分，用于反汇编)\n    *   CUDA Toolkit (需与 PyTorch 版本匹配)\n\n## 安装步骤\n\n### 1. 克隆项目\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile.git\ncd LLM4Decompile\n```\n\n### 2. 创建并激活虚拟环境\n```bash\nconda create -n 'llm4decompile' python=3.9 -y\nconda activate llm4decompile\n```\n\n### 3. 安装 Python 依赖\n*(注：若下载速度慢，可配置 pip 使用国内镜像源，如清华源)*\n```bash\npip install -r requirements.txt -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n### 4. 验证系统工具\n确保 `gcc` 和 `objdump` 已安装：\n```bash\ngcc --version\nobjdump --version\n```\n\n## 基本使用\n\n以下示例演示如何使用 **LLM4Decompile-End (V1.5)** 模型，将编译后的二进制文件反汇编并还原为 C 代码。\n\n### 第一步：预处理（编译与反汇编）\n首先将 C 代码编译为二进制，并使用 `objdump` 提取特定函数的汇编指令。\n\n```python\nimport subprocess\nimport os\n\n# 配置项：替换为你想要反编译的函数名\nfunc_name = 'func0' \nOPT = [\"O0\", \"O1\", \"O2\", \"O3\"]\nfileName = 'samples\u002Fsample' # 你的文件路径前缀\n\nfor opt_state in OPT:\n    output_file = fileName +'_' + opt_state\n    input_file = fileName+'.c'\n    \n    # 1. 使用 GCC 编译代码 (Linux 环境)\n    compile_command = f'gcc -o {output_file}.o {input_file} -{opt_state} -lm'\n    subprocess.run(compile_command, shell=True, check=True)\n    \n    # 2. 将二进制文件反汇编为汇编指令\n    compile_command = f'objdump -d {output_file}.o > {output_file}.s'\n    subprocess.run(compile_command, shell=True, check=True)\n    \n    input_asm = ''\n    with open(output_file+'.s') as f:\n        asm = f.read()\n        # 检查函数是否存在\n        if '\u003C'+func_name+'>:' not in asm: \n            raise ValueError(\"compile fails\")\n        \n        # 提取目标函数的汇编代码块\n        asm = '\u003C'+func_name+'>:' + asm.split('\u003C'+func_name+'>:')[-1].split('\\n\\n')[0] \n        \n        # 清洗汇编代码：移除地址和机器码，保留助记符\n        asm_clean = \"\"\n        asm_sp = asm.split(\"\\n\")\n        for tmp in asm_sp:\n            if len(tmp.split(\"\\t\"))\u003C3 and '00' in tmp:\n                continue\n            idx = min(len(tmp.split(\"\\t\")) - 1, 2)\n            tmp_asm = \"\\t\".join(tmp.split(\"\\t\")[idx:])  # 移除二进制码\n            tmp_asm = tmp_asm.split(\"#\")[0].strip()    # 移除注释\n            asm_clean += tmp_asm + \"\\n\"\n    \n    input_asm = asm_clean.strip()\n    \n    # 构造模型输入 Prompt\n    before = f\"# This is the assembly code:\\n\"\n    after = \"\\n# What is the source code?\\n\"\n    input_asm_prompt = before + input_asm.strip() + after\n    \n    # 保存处理后的汇编文件\n    with open(fileName +'_' + opt_state +'.asm', 'w', encoding='utf-8') as f:\n        f.write(input_asm_prompt)\n```\n\n**汇编格式说明**：\n处理后的 `.asm` 文件内容应如下所示：\n```text\n\u003Cfunc0>:\nendbr64\nlea    (%rdi,%rsi,1),%eax\nretq\n```\n\n### 第二步：执行反编译\n加载模型并将汇编指令转换为 C 代码。\n\n```python\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\nimport torch\n\n# 选择模型路径 (此处以 6.7B V1.5 为例)\nmodel_path = 'LLM4Binary\u002Fllm4decompile-6.7b-v1.5' \n\n# 加载分词器和模型\ntokenizer = AutoTokenizer.from_pretrained(model_path)\nmodel = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.bfloat16).cuda()\n\n# 读取预处理后的汇编文件 (以 O0 优化等级为例)\nwith open(fileName +'_' + \"O0\" +'.asm', 'r') as f:\n    asm_func = f.read()\n\n# 推理生成\ninputs = tokenizer(asm_func, return_tensors=\"pt\").to(model.device)\nwith torch.no_grad():\n    # max_new_tokens 需根据上下文长度调整，最大支持 4096\n    outputs = model.generate(**inputs, max_new_tokens=2048)\n\n# 解码输出结果\nc_func_decompile = tokenizer.decode(outputs[0][len(inputs[0]):-1])\n\n# 对比原始代码（可选）\nwith open(fileName +'.c', 'r') as f:\n    func = f.read()\n\nprint(f'Original function:\\n{func}')\nprint(f'Decompiled function:\\n{c_func_decompile}')\n```\n\n### Docker 快速启动（可选）\n如果你希望使用容器化环境，可以使用以下命令：\n\n```bash\n# 构建镜像\ndocker build -t llm4decompile .\n\n# 启动容器（需挂载 GPU）\ndocker run --gpus all -it --name llm4decompile llm4decompile \u002Fbin\u002Fbash\n\n# 在容器内运行演示脚本\ncd ghidra\npython demo.py\n```","某安全团队在分析一个遗留的闭源金融系统时，需要理解其核心加密模块的逻辑以修复严重漏洞，但手头只有编译后的二进制文件。\n\n### 没有 LLM4Decompile 时\n- 逆向工程师必须依赖传统反编译器（如 Ghidra）生成的伪代码，其中变量名多为 `var_1`、`func_2` 等无意义符号，阅读极其困难。\n- 为了理清业务逻辑，专家需花费数天时间手动追踪寄存器状态和内存跳转，人工推导变量含义，效率极低且容易出错。\n- 面对经过高度优化的二进制代码，传统工具输出的控制流混乱不堪，难以直接还原为可重新编译的高质量源代码。\n- 团队中初级成员因无法读懂晦涩的汇编逻辑，完全无法参与协助，导致项目进度严重依赖个别资深专家。\n\n### 使用 LLM4Decompile 后\n- LLM4Decompile 直接利用大模型能力，将二进制文件转换为带有语义化变量名（如 `encryptionKey`、`userBalance`）的可读源码。\n- 借助其“从骨架到皮肤”的两阶段恢复技术，自动重构了清晰的函数结构，将原本数天的手动分析工作缩短至几小时。\n- 生成的代码具备高达 64.9% 的可重执行率，修复后的逻辑可直接编译验证，大幅降低了人工修正代码的成本。\n- 输出结果通俗易懂，使得初级分析师也能快速理解核心算法，团队得以并行协作，加速了漏洞修复进程。\n\nLLM4Decompile 通过将晦涩的二进制码“翻译”为人类可读的高质量源码，彻底打破了逆向工程中的认知壁垒，让黑盒分析变得高效且民主化。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falbertan017_LLM4Decompile_9a4bf092.png","albertan017",null,"https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Falbertan017_eda3d1b1.png","Ph.D. candidate\r\nThe Hong Kong Polytechnic University (Jointly with Southern University of Science and Technology)  \r\nhanzhuo.tan@connect.polyu.hk","https:\u002F\u002Fgithub.com\u002Falbertan017",[82,86,90],{"name":83,"color":84,"percentage":85},"Python","#3572A5",92.1,{"name":87,"color":88,"percentage":89},"Shell","#89e051",7.2,{"name":91,"color":92,"percentage":93},"Dockerfile","#384d54",0.7,6499,467,"2026-04-13T15:07:14","MIT","Linux","必需 NVIDIA GPU。训练示例提及 A100 40G；推理代码使用 torch.bfloat16 并调用 .cuda()，建议显存 16GB+ 以运行较大模型（如 9B\u002F22B），较小模型（1.3B\u002F6.7B）可适当降低。","未说明",{"notes":102,"python":103,"dependencies":104},"该工具主要面向 Linux x86_64 架构的二进制文件反编译。环境设置推荐使用 conda。核心流程依赖外部工具：需安装 GCC 用于编译 C 代码，以及 objdump (属于 binutils) 用于将二进制反汇编为汇编指令。代码示例显示模型加载使用 bfloat16 精度，因此需要支持该精度的较新 NVIDIA GPU。Docker 部署需启用 GPU 支持 (--gpus all)。","3.9",[105,106,107,108],"torch","transformers","gcc","binutils (objdump)",[15],[111,112,113,114],"decompile","reverse-engineering","large-language-models","binary","2026-03-27T02:49:30.150509","2026-04-14T12:27:59.384354",[118,123,128,133,137,141],{"id":119,"question_zh":120,"answer_zh":121,"source_url":122},32788,"在 strip-only（仅去符号）场景下，如何恢复变量名或生成高质量的函数摘要？","在 strip-only 场景下，由于缺乏真实变量名作为基准，直接恢复“真实”变量名非常困难。建议结合以下学术工具和方法：\n1. ReSym：用于从去符号二进制文件中恢复变量名和数据结构符号（需自行集成到 IDA 工作流）。\n2. CLAP：通过对比语言 - 汇编预训练，辅助汇编代码的总结和检索。\n3. Idioms：专注于联合代码和类型预测，适合需要同时恢复变量类型的场景。\n此外，若能以较高置信度获取优化后的函数名或变量名，可作为提示词引导 LLM 提升最终摘要的语义质量。","https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Fissues\u002F54",{"id":124,"question_zh":125,"answer_zh":126,"source_url":127},32789,"为什么使用 deepseek-code-1.3-base 微调后的模型推理输出为空？","这通常是因为推理时使用的 Prompt 模板不正确。请确保推理时使用与项目一致的 Prompt 模板（参考 LLM4Decompile-Ref Colab 中的模板）。此外，官方发布的 llm4decompile-1.3b-v2 模型使用了更大的上下文长度（model_max_length 从 1024 增加到 4096）和更大的数据集（每 epoch 2B tokens，共训练 2 epochs），而开源的 decompile-ghidra-100k 数据集仅为完整数据的一部分，因此自行微调的效果可能不如官方模型。","https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Fissues\u002F46",{"id":129,"question_zh":130,"answer_zh":131,"source_url":132},32790,"如何获取 decompile-bench 数据集中函数的 DWARF 符号信息？","由于二进制文件中存在命名空间差异等问题，直接匹配 DWARF 符号与函数名可能失败。建议使用 IDA Pro 等工具提取函数信息，其匹配率远高于自定义脚本。对于数据集中因内联导致的重复函数（如 ncnn::fastFree 出现 551 次），项目已通过三步过滤处理：1) 单二进制内去重；2) 跨二进制使用 MinHash 对源码去重；3) 跨四种优化级别对汇编去重。最终数据集约为原始大小的 2%。","https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Fissues\u002F62",{"id":134,"question_zh":135,"answer_zh":136,"source_url":127},32791,"官方模型 llm4decompile-1.3b-v2 的训练配置是怎样的？","该模型基于 2B tokens\u002Fepoch 的数据量训练了 2 个 epoch，样本最大长度（model_max_length）设置为 4096。相比之下，开源的 decompile-ghidra-100k 数据集仅是完整训练数据的一小部分，且默认训练参数中 model_max_length 为 1024。若要复现官方性能，需使用更大数据集并将上下文长度扩展至 4096。",{"id":138,"question_zh":139,"answer_zh":140,"source_url":132},32792,"项目中如何处理因模板实例化或内联导致的重复函数问题？","项目采用三级过滤策略：首先，在单个二进制文件内，对映射到同一源函数的多个二进制函数，仅保留 DWARF 段交集最大的一个；其次，使用 MinHash 算法在所有二进制文件的同一优化级别下对源代码进行去重；最后，跨四种优化级别对对应的汇编代码再次去重。每一步可消除约 20–30% 的数据，最终使数据集缩小至原始大小的约 2%，显著提升数据质量。",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},32793,"是否有计划将 LLM4Decompile 迁移到 MIPS 等其他架构？","目前社区有用户表达了对 MIPS 架构的支持兴趣，并愿意协作降低算力成本。但官方尚未正式支持 MIPS。由于训练需要大量 GPU 资源（如 A100 集群），若无免费或低成本算力支持，短期内难以推进多架构版本。欢迎社区贡献者共同参与数据构建和微调工作。","https:\u002F\u002Fgithub.com\u002Falbertan017\u002FLLM4Decompile\u002Fissues\u002F3",[]]