W iki C hat: Stopping the Hallucination of Large Language Model Chatbots by Few-Shot Grounding on W ikipedia (2023)

Abstract: This paper presents the first few-shot LLM-based chatbot that almost never hallucinates and has high conversationality and low latency. WikiChat is grounded on the English Wikipedia, the largest curated free-text corpus. WikiChat generates a response from an LLM, retains only the grounded facts, and combines them with additional information it retrieves from the corpus to form factual and engaging responses. We distill WikiChat based on GPT-4 into a 7B-parameter LLaMA model with minimal loss of quality, to significantly improve its latency, cost and privacy, and facilitate research and deployment. Using a novel hybrid human-and-LLM evaluation methodology, we show that our best system achieves 97.3% factual accuracy in simulated conversations. It significantly outperforms all retrieval-based and LLM-based baselines, and by 3.9%, 38.6% and 51.0% on head, tail and recent knowledge compared to GPT-4. Compared to previous state-of-the-art retrieval-based chatbots, WikiChat is also significantly more informative and engaging, just like an LLM. WikiChat achieves 97.9% factual accuracy in conversations with human users about recent topics, 55.0% better than GPT-4, while receiving significantly higher user ratings and more favorable comments.

## introduction recent dramatic advances in llm chatbots have made them indispensable tools for millions of people @xcite who have come to rely on their broad skill set. yet, llm chatbots are prone to providing misleading information, or hallucination @xcite , often using a convincing and confident language. notably, llms do not speak accurately about recent events that occurred * equal contribution 1 code and model available at https://github.com/ stanford-oval/wikichat . this paper focuses on three metrics for knowledge-intensive dialogues: factuality, conversationality, and latency. a knowledge-based chatbot needs to be first and foremost factual. we assume access to a source of trusted text corpus; here the english wikipedia is assumed to be factual. while llms tend to hallucinate, they can carry out natural and engaging conversations rather than giving dry answers to users' questions. we refer to the ability to give relevant, informational, natural, non-repetitive and temporally accurate answers collectively as conversationality. we single out latency as the third metric of focus because solutions addressing factuality like @xcite ; @xcite ; @xcite ; @xcite tend to incur a high latency that degrades user experience and hinders adoption. ## design of wikichat given the history of a conversation with a user, wikichat generates its next utterance by (1) curating information that is correct and relevant to the conversation context, and (2) using the gathered information to form the response. each stage of the pipeline in figure 1 is implemented using in-context learning. all prompts are included in appendix f. ## model distillation to improve latency, cost and privacy, we distill wikichat based on a teacher llm into a smaller student model. we use wikichat based on gpt-4 (i.e. wikichat g4 ) as the teacher, and the publicly available llama @xcite model as the student to obtain wikichat l . each few-shot prompt consists of an instruction i and several examples. we use a user simulator (described in section 5.1) to talk to the teacher wikichat about topics from wikipedia, while recording the inputs the underlying teacher llm sees, and the outputs it generates for those inputs. we use these input-output pairs and the instruction i (but not the few-shot examples) to fine-tune the student llm. we distill all 7 subtasks of wikichat into the same student model in a multi-task setting. the llama-based wikichat calls llama in each of the pipeline stages by specifying instruction i and the input. distillation lowers the latency because the student llm is many times smaller than the teacher llm, and has a shorter input length as it sees no few-shot examples, similar to context distillation @xcite . furthermore, we remove chains of thought from the outputs of stages 5 and 7 (verification and refinement), and merge stages 6 and 7. no drop in our metrics of factuality and conversationality is observed, suggesting that chain-of-thought prompting and refinement may only be necessary for incontext learning. fine-tuned models can learn these tasks from just inputs and outputs given a big enough training set. ## a novel evaluation methodology most existing conversational benchmarks are crowdsourced and static. as @xcite says about their use of crowdsourcing, "the intent . . . is that [crowdworkers] can choose a topic they . . . have enough knowledge of so that they can conduct a reasonable conversation." since llms are already good conversants about familiar topics, testing them on these topics would lead to the false conclusion that no innovation is necessary. furthermore, static benchmarks quickly lose their effectiveness in evaluating chatbots' use of up-to-date information whenever a new llm is released. for example, wizard of wikipedia does not contain any topics that are not seen by gpt-3, gpt-4 or llama during their pre-training. here we propose a novel combination of simulated and real user conversations, as well as human and llm-based evaluations, to understand the factuality and conversationality of modern chatbots. ## implementation wikichat using gpt. we create two versions of wikichat based on gpt models: wikichat g3.5 is based on gpt-3.5 (text-davinci-003); wikichat g4 is based on gpt-4 (gpt-4-0314) foot_0 . distilling wikichat to llama. we use llama as the target of distillation as it currently has the highest quality-to-size ratio among the publicly available language models. we generate training data from 750 wikipedia articles covering head, tail and recent topics; these are disjoint from the set of topics we use for evaluation. simulating a 10-turn conversation between the user simulator and wikichat g4 for each topic results in a total of 37,499 (instruction, input, output) tuples. we hold out 5% of these conversations for validation, and fine-tune a 7b-parameter llama on the rest. ## simulated dialogues experiment our first experiment analyzes how our systems perform under various scenarios using simulated users. ## a real user study we conduct a study where participants are asked to chat about a recent topic of their choice, a scenario that is particularly challenging for llms. we use prolific (prolific, 2023) to recruit 40 participants (20 female) for our user study. each person is randomly assigned to either wikichat g4 or gpt-4 without telling them which, and chats for 5 user turns. after each turn, they are asked to rate the response on a scale of 1 to 5. afterwards, we ask each participant to comment on their experience. more details in appendix d. most participants who talked to wikichat g4 reported a positive experience. multiple participants praised its ability to provide "accurate and "upto-date information" and multiple said that it is "natural", "conversational", "detailed" and "direct". they commented that it is "fun to play with" and "impressive" in finding information. more concerning, however, was that conversations that received favorable comments also contain numerous plausible but factually incorrect responses, except that the users did not realize that. this shows how easy it is to be mislead by llmbased chatbots. in summary, our user study suggests that wikichat g4 is successful as an engaging and factual chatbot while gpt-4 frequently hallucinates. ## conclusion this paper shows how we can create a conversational, factual, open-domain chatbot out of llms. the key insight is to properly combine retrieved data with the generative content from llms, with meticulous claim-by-claim fact-checking. we validate this methodology by creating wikichat, which is grounded in wikipedia, the largest hand-curated public text corpus. our best system achieves 97.3% and 97.9% factual accuracy on simulated and real conversations respectively, when gpt-4 only achieves 66.1% and 42.9%. wikichat resembles llms in conversationality and is preferred over gpt-4. we also show that a distilled llama model with just 7b parameters can perform like a 175bparameter wikichat g3.5 model and be as fast, cheaper and more factual than gpt-4. this expands the applicability of this technology.