Duan Xufeng, Li Shixuan, Cai Zhenguang G
Department of Linguistics and Modern Languages, The Chinese University of Hong Kong, Hong Kong, China.
Brain and Mind Institute, The Chinese University of Hong Kong, Hong Kong, China.
Behav Res Methods. 2024 Dec 18;57(1):19. doi: 10.3758/s13428-024-02524-y.
The study of large language models (LLMs) and LLM-powered chatbots has gained significant attention in recent years, with researchers treating LLMs as participants in psychological experiments. To facilitate this research, we developed an R package called "MacBehaviour " ( https://github.com/xufengduan/MacBehaviour ), which interacts with over 100 LLMs, including OpenAI's GPT family, the Claude family, Gemini, Llama family, and other open-weight models. The package streamlines the processes of LLM behavioural experimentation by providing a comprehensive set of functions for experiment design, stimuli presentation, model behaviour manipulation, and logging responses and token probabilities. With a few lines of code, researchers can seamlessly set up and conduct psychological experiments, making LLM behaviour studies highly accessible. To validate the utility and effectiveness of "MacBehaviour," we conducted three experiments on GPT-3.5 Turbo, Llama-2-7b-chat-hf, and Vicuna-1.5-13b, replicating the sound-gender association in LLMs. The results consistently demonstrated that these LLMs exhibit human-like tendencies to infer gender from novel personal names based on their phonology, as previously shown by Cai et al. (2024). In conclusion, "MacBehaviour" is a user-friendly R package that simplifies and standardises the experimental process for machine behaviour studies, offering a valuable tool for researchers in this field.
近年来,对大语言模型(LLMs)和由大语言模型驱动的聊天机器人的研究受到了广泛关注,研究人员将大语言模型视为心理实验的参与者。为了推动这项研究,我们开发了一个名为“MacBehaviour ”(https://github.com/xufengduan/MacBehaviour )的R包,它可以与100多种大语言模型进行交互,包括OpenAI的GPT系列、Claude系列、Gemini、Llama系列以及其他开源模型。该包通过提供一套全面的函数,用于实验设计、刺激呈现、模型行为操纵以及记录响应和令牌概率,简化了大语言模型行为实验的流程。只需几行代码,研究人员就可以无缝地设置和进行心理实验,使大语言模型行为研究变得非常容易。为了验证“MacBehaviour”的实用性和有效性,我们对GPT-3.5 Turbo、Llama-2-7b-chat-hf和Vicuna-1.5-13b进行了三项实验,重现了大语言模型中的声音-性别关联。结果一致表明,这些大语言模型表现出类似人类的倾向,即根据新出现的人名的语音来推断性别,正如Cai等人(2024年)之前所表明的那样。总之,“MacBehaviour”是一个用户友好的R包,它简化并规范了机器行为研究的实验过程,为该领域的研究人员提供了一个有价值的工具。