{"title":"Code Generation for Collectible Card Games with Complex APIs","authors":"John Licato, Logan Fields, Brayden Hollis","doi":"10.32473/flairs.36.133044","DOIUrl":null,"url":null,"abstract":"Large pre-trained language models (LMs) such as GPT-3 Codex are able to generate code remarkably well given prompts of natural language text. But if we want to use such LMs to generate code compatible with a specific API or library (e.g., an API which provides the environments in which certain rules, laws, or orders are to be carried out), the amount of computational and data resources required to fine-tune such models can be cost prohibitive to most organizations. Given these practical limitations, is it possible to utilize these massive code-generation LMs to write code compatible with a given API? We develop an algorithm that selects code examples using a smaller LM trained to predict which features of an API are likely to be used in the resulting code, which is a simpler problem than actually generating the code. The selected examples are then used to build a prompt for the larger LM, which in turn generates the final code. We demonstrate our results on a benchmark dataset derived from the collectible card game \"Magic: the Gathering,\" and obtain state-of-the-art results.","PeriodicalId":302103,"journal":{"name":"The International FLAIRS Conference Proceedings","volume":"151 ","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2023-05-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"The International FLAIRS Conference Proceedings","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.32473/flairs.36.133044","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0
Abstract
Large pre-trained language models (LMs) such as GPT-3 Codex are able to generate code remarkably well given prompts of natural language text. But if we want to use such LMs to generate code compatible with a specific API or library (e.g., an API which provides the environments in which certain rules, laws, or orders are to be carried out), the amount of computational and data resources required to fine-tune such models can be cost prohibitive to most organizations. Given these practical limitations, is it possible to utilize these massive code-generation LMs to write code compatible with a given API? We develop an algorithm that selects code examples using a smaller LM trained to predict which features of an API are likely to be used in the resulting code, which is a simpler problem than actually generating the code. The selected examples are then used to build a prompt for the larger LM, which in turn generates the final code. We demonstrate our results on a benchmark dataset derived from the collectible card game "Magic: the Gathering," and obtain state-of-the-art results.
大型预训练语言模型(LMs),如GPT-3 Codex,能够在给定自然语言文本提示的情况下非常好地生成代码。但是,如果我们想使用这样的lm来生成与特定API或库(例如,提供执行某些规则、法律或命令的环境的API)兼容的代码,那么对大多数组织来说,微调此类模型所需的计算量和数据资源的成本可能会令人望而生畏。考虑到这些实际限制,是否有可能利用这些大规模代码生成LMs来编写与给定API兼容的代码?我们开发了一种算法,该算法使用经过训练的较小的LM来选择代码示例,以预测可能在结果代码中使用API的哪些特征,这比实际生成代码要简单得多。然后使用选定的示例为较大的LM构建提示符,从而生成最终的代码。我们在收集卡牌游戏“Magic: the Gathering”的基准数据集上展示了我们的结果,并获得了最先进的结果。