使用大语言模型实现面向硬件加速的代码检测
Code Detection for Hardware Acceleration Using Large Language Models
AI总结:
本研究首次探索大语言模型在代码检测中的应用,针对C/C++实现的三类核心计算内核,提出新型提示策略,大幅降低假阳性,显著提升检测准确率,对现有最优方法形成挑战。
摘要:
大语言模型(LLM)已被大规模应用于诸多任务,性能往往超越现有最优方法。尽管其在代码生成领域的效用已得到广泛研究(例如AlphaCode),但在代码检测方向的潜力仍有待探索。\n 本工作首次开展了基于LLM的代码检测分析。研究考察了以C/C++实现的核心计算内核,包括矩阵乘法、卷积和快速傅里叶变换。我们提出了一种初步的朴素提示词方法,以及一种面向代码检测的新型提示策略。\n 结果显示,传统提示方法精度很高但准确率不佳(GEMM、卷积和FFT的准确率分别为68.8%、22.3%和79.2%),原因是假阳性数量过多。我们提出的新型提示策略大幅减少了假阳性,实现了优异的整体准确率(三者分别为91.1%、97.9%和99.7%)。这些结果对现有最优代码检测方法构成了相当大的挑战。
英文摘要:
Large language models (LLMs) have been massively applied to many tasks, often surpassing state-of-the-art approaches. While their effectiveness in code generation has been extensively studied (e.g., AlphaCode), their potential for code detection remains unexplored. This work presents the first analysis of code detection using LLMs. Our study examines essential kernels, including matrix multiplication, convolution, and fast-fourier transform, implemented in C/C++. We propose both a preliminary, naive prompt and a novel prompting strategy for code detection. Results reveal that conventional prompting achieves great precision but poor accuracy (68.8%, 22.3%, and 79.2% for GEMM, convolution, and FFT, respectively) due to a high number of false positives. Our novel prompting strategy substantially reduces false positives, resulting in excellent overall accuracy (91.1%, 97.9%, and 99.7%, respectively). These results pose a considerable challenge to existing state-of-the-art code detection methods.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。