与文本一样,程序也具有风格,并且就程序的可读性、可维护性和性能而言,某些编程风格比其他风格更可取。然而,除了行长度限制等琐碎的风格准则外,代码风格迁移很难实现自动化。受语言模型在文本风格迁移中取得成功的启发,我们研究代码语言模型是否能够执行代码风格迁移。与文本迁移不同,代码风格迁移具有严格要求:系统需要识别要更改的代码行,正确更改它们,并保持程序的其余部分不变。我们设计了 CSB(Code Style Benchmark,代码风格基准),这是一个涵盖五大类代码风格迁移任务的基准套件,包括将 for 循环转换为列表推导式、消除代码重复、为方法添加装饰器等。随后,我们使用这些测试来检验大型预训练代码语言模型或微调模型能否正确执行风格迁移,并依据严格指标来测试迁移确实发生且代码仍能通过功能测试。令人惊讶的是,语言模型未能完成所有任务,这表明它们在需要代码理解的任务上表现不佳。我们将公开大规模语料库,以帮助社区构建更好的代码模型。
英文摘要:
Like text, programs have styles, and certain programming styles are more desirable than others for program readability, maintainability, and performance. Code style transfer, however, is difficult to automate except for trivial style guidelines such as limits on line length. Inspired by the success of using language models for text style transfer, we investigate if code language models can perform code style transfer. Code style transfer, unlike text transfer, has rigorous requirements: the system needs to identify lines of code to change, change them correctly, and leave the rest of the program untouched. We designed CSB (Code Style Benchmark), a benchmark suite of code style transfer tasks across five categories including converting for-loops to list comprehensions, eliminating duplication in code, adding decorators to methods, etc. We then used these tests to see if large pre-trained code language models or fine-tuned models perform style transfer correctly, based on rigorous metrics to test that the transfer did occur, and the code still passes functional tests. Surprisingly, language models failed to perform all of the tasks, suggesting that they perform poorly on tasks that require code understanding. We will make available the large-scale corpora to help the community build better code models.
InMind: Evaluating LLMs in Capturing and Applying Individual Human Reasoning Styles
Nankai University(南开大学);Shanghai Innovation Institute(上海创新研究院);Shanghai AI Laboratory(上海人工智能实验室);Fudan University(复旦大学);Johns Hopkins University(约翰霍普金斯大学);Wuhan University(武汉大学);University of Science and Technology of China(中国科学技术大学)
Break the Checkbox: Challenging Closed-Style Evaluations of Cultural Alignment in LLMs
Department of Computer Science, National Center for Text Mining, The University of Manchester(计算机科学系,文本挖掘国家中心,曼彻斯特大学);Department of Computer Science and Engineering, Islamic University of Technology(计算机科学与工程系,伊斯兰技术大学)
code_transformed: The Influence of Large Language Models on Code
Huazhong University of Science and Technology(华中科技大学);École normale supérieure - Université PSL(巴黎高等师范学院-巴黎大学);Laboratoire LATTICE(LATTICE实验室);International School for Advanced Studies (SISSA)(国际先进研究学院(SISSA))
University of Massachusetts, Amherst(马萨诸塞大学阿默斯特分校);Emory University(埃默里大学);University of Minnesota(明尼苏达大学);University of Massachusetts, Lowell(马萨诸塞大学洛厄尔分校);UMass Chan Medical School(UMass Chan医学学院)
Communication styles and reader preferences of LLM- and human-authored COVID-19 information explanations: a case study
School of Interactive Computing, Georgia Institute of Technology(交互计算学院,佐治亚理工学院);Amazon(亚马逊);Siebel School of Computing and Data Science, University of Illinois Urbana-Champaign(Siebel计算与数据科学学院,伊利诺伊大学厄巴纳-香槟分校)
Imitate Before Detect: Aligning Machine Stylistic Preference for Machine-Revised Text Detection
Fudan University(复旦大学);South China University of Technology(华南理工大学);Wuhan University(武汉大学);Fenz AI;UC San Diego(加州大学圣地亚哥分校);UIUC(伊利诺伊大学厄巴纳-香槟分校);CMU(卡内基梅隆大学);PolyU(香港理工大学);Stanford University(斯坦福大学);NUS (Chongqing) Research Institute(新加坡国立大学(重庆)研究院);Georgia Tech(佐治亚理工学院)
DRESSing Up LLM: Efficient Stylized Question-Answering via Style Subspace Editing
School of Computer Science, Peking University(北京大学计算机学院);Center on Frontiers of Computing Studies, Peking University(北京大学计算前沿研究中心);National Research and Engineering Center of Software Engineering, Peking University(北京大学国家软件工程研究与工程中心)
A Multi-Task Role-Playing Agent Capable of Imitating Character Linguistic Styles
Institute of Information Engineering, Chinese Academy of Sciences(中国科学院信息工程研究所);School of Cyber Security, University of Chinese Academy of Sciences(中国科学院大学网络空间安全学院);Huawei Technologies Co., Ltd.(华为技术有限公司)
ProSwitch: Knowledge-Guided Instruction Tuning to Switch Between Professional and Non-Professional Responses
Zhejiang University of Science and Technology(浙江科技大学);Fudan University(复旦大学);Zhejiang University(浙江大学);The Chinese University of Hong Kong(香港中文大学);Tsinghua University(清华大学)
CoCoNUTS: Concentrating on Content while Neglecting Uninformative Textual Styles for AI-Generated Peer Review Detection
Chinese Information Processing Laboratory, Institute of Software, Chinese Academy of Sciences(中国科学院软件研究所中文信息处理实验室);University of Chinese Academy of Sciences(中国科学院大学)
Controllable Navigation Instruction Generation with Chain of Thought Prompting
School of Artificial Intelligence, Beihang University(北京航空航天大学人工智能学院);College of Computer Science and Technology, Zhejiang University(浙江大学计算机科学与技术学院);Department of Computer Science and Technology, Tsinghua University(清华大学计算机科学与技术系)