كود في: تمكين نماذج اللغة الكبيرة من خلال توليد HDL عبر التلخيص متعدد المستويات CodeV: Empowering LLMs With HDL Generation Through Multilevel Summarization

شارك:
المجلة: IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems، المجلد: 45، العدد: 4
DOI: https://doi.org/10.1109/tcad.2025.3604320
تاريخ النشر: 2025-08-29
المؤلف: Zhenyun Du وآخرون
الموضوع الرئيسي: أبحاث هندسة البرمجيات

نظرة عامة

تناقش هذه القسم التحديات والتقدم في تدفق تصميم المعالجات باستخدام لغات وصف الأجهزة (HDLs) مثل Verilog و Chisel. على الرغم من التحسينات الكبيرة في مهام الترميز للغات البرمجة من خلال نماذج اللغة الكبيرة (LLMs)، فإن فعاليتها في توليد HDL محدودة بسبب نقص مجموعات بيانات HDL عالية الجودة. تعتمد الأساليب التقليدية التي تتكيف مع LLMs لتصميم الأجهزة غالبًا على مجموعات بيانات اصطناعية، مما يؤدي إلى نتائج دون المستوى، خاصةً أن النماذج المتقدمة مثل GPT تواجه صعوبة في مهام HDL. يبرز المؤلفون ثلاث ملاحظات رئيسية: (1) كود HDL في العالم الحقيقي ذو جودة أعلى مقارنة بالكود الذي تم إنشاؤه بواسطة LLM، (2) LLMs مثل GPT-3.5 أكثر كفاءة في تلخيص كود HDL من توليده، و (3) يمكن أن يؤدي تضمين علامات لغة صريحة إلى تحسين تكيف LLM مع اللغات المستهدفة في السيناريوهات التي تعاني من نقص البيانات.

لمعالجة هذه القضايا، يقترح البحث خط أنابيب جديد للتدريب الدقيق لتوليد HDL يجمع بين عملية توليد بيانات تلخيص متعددة المستويات مع طريقة تدريب إشرافية جديدة تُدعى Chat-FIM-Tag. يحسن هذا الخط من توليد كود HDL من أوصاف اللغة الطبيعية ويدعم مهامًا متنوعة، بما في ذلك الدردشة وملء الكود. يقدم المؤلفون CodeV، وهي سلسلة من LLMs لتوليد HDL، حيث يظهر CodeV-All قدرات محسنة عبر لغات متعددة (Verilog و Chisel) ومهام (الدردشة وملء الوسط). من الجدير بالذكر أن CodeV-All يحقق أداءً على معيار VerilogEval يعادل أو يتجاوز أداء CodeV-Verilog، الذي تم ضبطه بدقة لـ Verilog، مما يمثل تقدمًا كبيرًا في LLMs مفتوحة المصدر لتوليد HDL في سيناريوهات متعددة.

مقدمة

تناقش مقدمة ورقة البحث التعقيدات والتكاليف المرتبطة بتصميم المعالجات، خاصةً في ترميز لغات وصف الأجهزة (HDLs) مثل Verilog و Chisel. بينما أظهرت نماذج اللغة الكبيرة (LLMs) وعدًا كبيرًا في توليد كود البرمجيات من اللغة الطبيعية، فإن تطبيقها في توليد HDL يعيقه نقص بيانات التدريب عالية الجودة. على سبيل المثال، تحتوي أكبر مجموعة بيانات مفتوحة المصدر، The Stack v2، على 1.91 مليون سطر من كود Verilog مقارنة بـ 80.6 مليون سطر من كود Python، مما يبرز الفجوة في الموارد المتاحة. لم تؤدِ المحاولات الأولية لتكييف LLMs لتوليد HDL من خلال التدريب الدقيق إلى نتائج مرضية، ويرجع ذلك أساسًا إلى الأداء الضعيف لـ LLMs في مجال HDL، كما يتضح من الفرق الملحوظ في درجات المعايير (88.4% لـ Python مقابل 43.5% لـ Verilog).

يحدد المؤلفون التحديات الرئيسية في المشهد الحالي، مشيرين إلى أن كود HDL في العالم الحقيقي عمومًا ذو جودة أعلى من ذلك الذي تنتجه LLMs، والتي تميل إلى توليد كود يحتوي على المزيد من الأخطاء النحوية وأقل وضوحًا. يؤكدون أن LLMs أكثر فعالية في تلخيص كود HDL الموجود بدلاً من توليده من الصفر. علاوة على ذلك، تقتصر المنهجيات الحالية على توليد كود Verilog من أوصاف اللغة الطبيعية ولا تستوعب سيناريوهات أخرى، مثل ملء الكود غير المكتمل أو دعم لغات مثل Chisel. تمهد هذه القسم الطريق لاستكشاف تقنيات محسنة لتوليد HDL تستفيد من بيانات حقيقية عالية الجودة وتعالج قيود تطبيقات LLM الحالية في تصميم الأجهزة.

الطرق

في قسم الطرق، يصف المؤلفون نهجهم لجمع كود HDL (لغة وصف الأجهزة) عالي الجودة، مع التركيز بشكل خاص على Verilog و SystemVerilog. تبدأ عملية الجمع بالزحف إلى مستودعات GitHub لجمع ملفات Verilog التي تحتوي على وحدات كاملة، يتم تعريفها من خلال وجود كل من كلمات “module” و “endmodule”. للحفاظ على سلامة مجموعة البيانات، يتم استبعاد الملفات التي تحتوي على مراجع خارجية (مثل تلك التي تحتوي على كلمات “include” أو “import”)، حيث إن إعادة بناء هذه التبعيات تمثل تحديات كبيرة.

يقوم المؤلفون بمزيد من تحسين مجموعة البيانات من خلال معالجة التعليقات داخل الكود. يصنفون التعليقات إلى نوعين: تعليقات تتعلق بالتنفيذ، والتي توفر سياقًا أساسيًا لفهم الكود (مثل أوصاف الإشارات وشرح الوحدات)، وتعليقات غير ذات صلة، والتي تشمل التراخيص ومعلومات المؤلف. لتعزيز تدريب نماذج اللغة (LLMs)، يتم الاحتفاظ فقط بالتعليقات المتعلقة بالتنفيذ، بينما يتم إزالة التعليقات غير ذات الصلة باستخدام التعبيرات العادية. بالإضافة إلى ذلك، يتم التخلص من أي ملفات تتجاوز 4096 حرفًا لضمان التوحيد في مجموعة البيانات.

المناقشة

في هذا القسم، يناقش المؤلفون تطوير إطار عمل CodeV، الذي يهدف إلى تعزيز توليد لغة وصف الأجهزة (HDL) من خلال خط أنابيب جديد للتدريب الدقيق. تبدأ العملية بجمع وتصنيف وحدات HDL عالية الجودة من المستودعات مفتوحة المصدر، تليها استخدام GPT-3.5 لتوليد ملخصات متعددة المستويات لهذه الوحدات. ينتج عن ذلك مجموعة بيانات عالية الجودة من أزواج الوصف-الكود التي تُستخدم لتدريب نماذج اللغة الكبيرة (LLMs)، مع التركيز بشكل خاص على مهام توليد HDL. تشير النتائج إلى أنه بينما تواجه LLMs صعوبة في توليد كود HDL (33.5% pass@1 لتوليد Verilog)، فإنها تؤدي بشكل أفضل بكثير في تلخيص كود HDL الموجود (64.7% pass@1). كما يبرز المؤلفون أهمية استخدام علامات لغة صريحة لتحسين أداء النموذج، خاصةً عندما تكون البيانات نادرة.

تم تصميم طريقة التدريب الدقيق الإشرافية المقترحة Chat-FIM-Tag لمعالجة تحديات المهام متعددة السيناريوهات، مما يمكّن النموذج من التعامل بفعالية مع كل من مهام توليد الكود وملء المهام عبر لغات HDL المختلفة، وهي Verilog و Chisel. تظهر النتائج أن نماذج CodeV تحقق أداءً رائدًا في مختلف المعايير، متجاوزة النماذج الحالية، بما في ذلك GPT-3.5. من الجدير بالذكر أن CodeV-All-QC تحقق نسبة 80.1% pass@1 على معيار VerilogEval-Machine، مما يبرز قدرة الإطار على التعميم عبر لغات ومهام HDL متعددة. يخطط المؤلفون لجعل مجموعة بياناتهم المكونة من 185 ألف زوج وصف-كود عالي الجودة مفتوحة المصدر لتعزيز المزيد من البحث والتعاون في مجالات LLMs وأتمتة التصميم الإلكتروني.

Journal: IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, Volume: 45, Issue: 4
DOI: https://doi.org/10.1109/tcad.2025.3604320
Publication Date: 2025-08-29
Author(s): Zhenyun Du et al.
Primary Topic: Software Engineering Research

Overview

The section discusses the challenges and advancements in the design flow of processors using hardware description languages (HDLs) such as Verilog and Chisel. Despite significant improvements in coding tasks for software languages through large language models (LLMs), their effectiveness in HDL generation is limited due to the lack of high-quality HDL datasets. Traditional approaches that adapt LLMs for hardware design often rely on synthetic datasets, which yield subpar results, particularly as even advanced models like GPT struggle with HDL tasks. The authors highlight three key observations: (1) real-world HDL code is of superior quality compared to LLM-generated code, (2) LLMs like GPT-3.5 are more proficient at summarizing HDL code than generating it, and (3) incorporating explicit language tags can enhance LLM adaptation to target languages in data-scarce scenarios.

To address these issues, the paper proposes a novel finetuning pipeline for HDL generation that combines a multi-level summarization data synthesis process with a new supervised fine-tuning method called Chat-FIM-Tag. This pipeline improves the generation of HDL code from natural language descriptions and supports various tasks, including chat and code infilling. The authors introduce CodeV, a series of HDL generation LLMs, with CodeV-All demonstrating enhanced capabilities across multiple languages (Verilog and Chisel) and tasks (chat and fill-in-middle). Notably, CodeV-All achieves performance on the VerilogEval benchmark that is comparable to or exceeds that of CodeV-Verilog, which is specifically fine-tuned for Verilog, marking a significant advancement in open-source LLMs for multi-scenario HDL generation.

Introduction

The introduction of the research paper discusses the complexities and costs associated with processor design, particularly in coding hardware description languages (HDLs) like Verilog and Chisel. While large language models (LLMs) have shown significant promise in generating software code from natural language, their application in HDL generation is hindered by a lack of high-quality training data. For instance, the largest open-source dataset, The Stack v2, contains only 1.91M lines of Verilog code compared to 80.6M lines of Python code, highlighting the disparity in available resources. Initial attempts to adapt LLMs for HDL generation through fine-tuning have not yielded satisfactory results, primarily due to the poor performance of LLMs in the HDL domain, as evidenced by a notable difference in benchmark scores (88.4% for Python vs. 43.5% for Verilog).

The authors identify key challenges in the current landscape, noting that real-world HDL code is generally of higher quality than that produced by LLMs, which tend to generate code with more syntax errors and less clarity. They emphasize that LLMs are more effective at summarizing existing HDL code rather than generating it from scratch. Furthermore, existing methodologies are limited to generating Verilog code from natural language descriptions and do not accommodate other scenarios, such as infilling incomplete code or supporting languages like Chisel. This section sets the stage for exploring improved techniques for HDL generation that leverage high-quality real-world data and address the limitations of current LLM applications in hardware design.

Methods

In the Methods section, the authors describe their approach to collecting high-quality HDL (Hardware Description Language) code, specifically focusing on Verilog and SystemVerilog. The collection process begins with crawling GitHub repositories to gather Verilog files that contain complete modules, defined by the presence of both “module” and “endmodule” keywords. To maintain the integrity of the dataset, files that include external references (e.g., those containing “include” or “import” keywords) are excluded, as reconstructing these dependencies poses significant challenges.

The authors further refine the dataset by addressing comments within the code. They categorize comments into two types: implementation-related comments, which provide essential context for understanding the code (such as signal descriptions and module explanations), and unrelated comments, which include licenses and author information. To enhance the training of language models (LLMs), only implementation-related comments are retained, while unrelated comments are removed using regular expressions. Additionally, any files exceeding 4096 characters are discarded to ensure uniformity in the dataset.

Discussion

In this section, the authors discuss the development of the CodeV framework, which aims to enhance hardware description language (HDL) generation through a novel fine-tuning pipeline. The process begins with the collection and filtering of high-quality HDL modules from open-source repositories, followed by the use of GPT-3.5 to generate multi-level summaries of these modules. This results in a high-quality dataset of description-code pairs that are utilized to fine-tune large language models (LLMs), specifically targeting HDL generation tasks. The findings indicate that while LLMs struggle with generating HDL code (33.5% pass@1 for Verilog generation), they perform significantly better in summarizing existing HDL code (64.7% pass@1). The authors also highlight the importance of using explicit language tags to improve model performance, particularly when data is scarce.

The proposed Chat-FIM-Tag supervised fine-tuning method is designed to address the challenges of multi-scenario tasks, enabling the model to effectively handle both code generation and infilling tasks across different HDL languages, namely Verilog and Chisel. The results demonstrate that the CodeV models achieve state-of-the-art performance on various benchmarks, surpassing existing models, including GPT-3.5. Notably, CodeV-All-QC achieves an impressive 80.1% pass@1 on the VerilogEval-Machine benchmark, showcasing the framework’s capability to generalize across multiple HDL languages and tasks. The authors plan to open-source their dataset of 185K high-quality description-code pairs to promote further research and collaboration in the fields of LLMs and electronic design automation.

شارك: