Automatic Generation of Python Programs Using Context-Free Grammars

要約

近年、データが新たな金として台頭し、インテリジェントなシステムを構築するための強力なツールとして機能します。
ただし、特にコードの場合、高品質のデータを入手することは依然として困難です。
これに対処するために、コンテキストフリー文法を使用してランダムな Python プログラムを生成するツールである TinyPy Generator を開発しました。
生成されたプログラムは、構築によって正しいことが保証されます。
私たちのシステムは、カスタム生成ルール (Backus-Naur Form (BNF) 形式) を使用してコードを再帰的に生成します。
これにより、代入のみを含むコードから条件文やループを含むより複雑なコードまで、さまざまなレベルの複雑さのコードを生成できます。
私たちが提案するツールは、大規模な Python コードを簡単に生成できるようにし、幅広いアプリケーションに有益です。
TinyPy Generator は、Python 言語モデルをトレーニングするための大量の Python コードを生成できるため、機械学習の分野で特に役立ちます。
さらに、プログラミング言語を研究している研究者は、このツールを利用して実験用のデータセットを作成でき、コード インタプリタやコンパイラの堅牢性を検証するのに役立ちます。
既存の研究とは異なり、実装はオープンソース化されています。
これにより、ユーザーのニーズに応じたカスタマイズが可能になり、他の言語にも使用できる可能性が広がります。

要約(オリジナル)

In recent years, data has emerged as the new gold, serving as a powerful tool for creating intelligent systems. However, procuring high-quality data remains challenging, especially for code. To address this, we developed TinyPy Generator, a tool that generates random Python programs using a context-free grammar. The generated programs are guaranteed to be correct by construction. Our system uses custom production rules (in the Backus-Naur Form (BNF) format) to recursively generate code. This allows us to generate code with different levels of complexity, ranging from code containing only assignments to more complex code containing conditionals and loops. Our proposed tool enables effortless large-scale Python code generation, beneficial for a wide range of applications. TinyPy Generator is particularly useful in the field of machine learning, where it can generate substantial amounts of Python code for training Python language models. Additionally, researchers who are studying programming languages can utilize this tool to create datasets for their experiments, which can help validate the robustness of code interpreters or compilers. Unlike existing research, we have open-sourced our implementation. This allows customization according to user needs and extends potential usage to other languages.

arxiv情報

著者 Kamel Yamani,Marwa Naïr,Riyadh Baghdadi
発行日 2024-03-11 08:25:52+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.CL, cs.LG, cs.PL パーマリンク