Understanding and Mitigating Language Confusion in LLM s (2024)

Abstract: We investigate a surprising limitation of LLMs: their inability to consistently generate text in a user’s desired language. We create the Language Confusion Benchmark (LCB) to evaluate such failures, covering 15 typologically diverse languages with existing and newly-created English and multilingual prompts. We evaluate a range of LLMs on monolingual and cross-lingual generation reflecting practical use cases, finding that Llama Instruct and Mistral models exhibit high degrees of language confusion and even the strongest models fail to consistently respond in the correct language. We observe that base and English-centric instruct models are more prone to language confusion, which is aggravated by complex prompts and high sampling temperatures. We find that language confusion can be partially mitigated via few-shot prompting, multilingual SFT and preference tuning. We release our language confusion benchmark, which serves as a first layer of efficient, scalable multilingual evaluation.

## introduction large language models (llms) are increasingly used in a variety of applications across the globe (kaddour et al., 2023). while early llms focused on english (joshi et al., 2020; hu et al., 2020), recent models are more multilingual. nevertheless, llms do not provide equal utility to non-english speakers due to higher latency, increased costs, and reduced performance (ahia et al., 2023; asai et al., 2023; held et al., 2023). to be useful, an llm must understand intent and provide a response that is appropriate in both form, e.g., correct grammar, style, tone, register, and content, e.g., truthful, coherent, concise (grice, word-level confusion prompt: 以下リストした3つの言葉を使用して、面白い物語を1500文字 以内書いて:・ティッシュー ・タイピング ・怒り completion: … 最近の成績不振で上司に怒鳴られたことがきっかけ だった。ジョンは自分のデスクに座り、深呼吸をしようと試みた。しかし、 落ち着くどころか、怒りはますます膨れ上がり、 eventually, 彼はキー ボードを激しく叩き始め... 1975; wilson and sperber, 2012). while contentrelated issues such as hallucinations have attracted substantial attention (ji et al., 2023; bang et al., 2023), they are often subtle and difficult to evaluate (gudibande et al., 2024; hosking et al., 2024), particularly in multilingual settings (guerreiro et al., 2023). form-related errors indicate a more obvious failure to fulfill a request and-in extreme casesmay cause confusing or unintelligible responses. we identify a surprising form limitation that drastically reduces llms' utility for non-english languages: llms are often unable to consistently generate text in the user's desired language, or the appropriate language given the context. we call this category of error "language confusion". @xcite take an arabic prompt as an example: an llm may inappropriately respond fully in english (fullresponse confusion), produce some lines in the desired language and some in another language (line-level confusion), or sporadically insert single words or phrases in another language (word-level confusion). figure 1 shows example errors. even if such errors occur rarely, they cause a jarring user 经验 (experience). we investigate language confusion on the line and word level in two practical settings: a) monolingual generation, where a user queries the llm in a given language, implicitly requesting an answer in the same language; and b) cross-lingual generation, where a user explicitly instructs a model to generate text in a different language. we create and release a language confusion benchmark covering 15 typologically diverse languages, sourcing prompts from public english and multilingual instruction datasets, and additionally creating new data with more complex prompts. we evaluate a range of state-of-the-art llms including llama, command r, mistral, and openai family models. we find that llama instruct and mistral llms exhibit severe language confusion in many languages. while command r and openai models fare much better on monolingual generation, even the strongest cannot consistently generate text in the correct language cross-lingually. our contributions are the following: ## language confusion benchmark while some datasets to evaluate llms' performance on natural code-switched data exist (khanuja et al., 2020; winata et al., 2023), there are none designed to assess language confusion in llms. we create the language confusion benchmark (lcb) by collecting a diverse set of prompts reflecting realistic use cases across a typologically diverse set of languages. the benchmark is easily extensible, cheap, and efficient to evaluate. ## when does language confusion occur? we study a sample of prompts to better understand where language confusion occurs. intuitively, if a token in an undesired language is assigned sufficient probability, it may be sampled. we observe that language confusion typically occurs when the distribution over next tokens is flat and the nucleus is large (see §a.10 for background). we generate responses to 15 chinese prompts from okapi with command r. @xcite we examine outputs to identify instances of english language confusion, finding it in 5 of 15 outputs. for each, we find the first position where an english token was responses are split into those which had at least one cp ("has cp") or zero cps ("no cp"). @xcite when intentional, such points are referred to in the codeswitching literature as "switch points". we coin a new term here to indicate that this switching is erroneous. @xcite there are 3 examples of line-level confusion. we label the initial switching point from chinese to english as the cp. ## mitigating language confusion based on the insights from our analyses in §4.5 and §5, we propose inference-time and training-time mitigations for language confusion. ## discussion we discuss several aspects that raise important questions including the behavior of base models, the english centricity of models, the impact of preference tuning, and the importance of other factors in appendix a.11. ## related work code-switching there has been much research on natural alternations between languages, i.e., code-switching (dogruöz et al., 2021) in natural language processing (nlp). prior work focused on evaluating capabilities on standard nlp tasks using code-switching data (khanuja et al., 2020; winata et al., 2023) including sentiment analysis, machine translation, summarization and word-level language identification. these tasks typically employ data created by humans where word-level code-switching occurs between english and another language such as hindi, spanish, or arabic. current models still struggle to generate and understand code-switched text in some languages (yong et al., 2023; zhang et al., 2023). in contrast, we investigate unnatural and erroneous code-switchingor language confusion-in the llm's generations. language confusion prior work has observed 'source language hallucinations' in zero-shot crosslingual transfer (vu et al., 2022; li and murray, 2023; pfeiffer et al., 2023; chirkova and nikoulina, 2024) when models are fine-tuned on english data and applied to generate text in another language. the problem of language confusion is known in the machine translation field as 'off-target translation' (chen et al., 2023; sennrich et al., 2024). it typically occurs on english-centric multilingual models, when used in a zero-shot manner (to translate between two languages unseen at training). for llms, there is no source language per se. a few studies (kew et al., 2023; faisal and anastasopoulos, 2023; chen et al., 2024) have provided evidence of llms generating in an incorrect language on the response level. holtermann et al. (2024) analyze which languages are confused on the response level using mainly smaller llms. to the best of our knowledge, we are the first to show results on the line and word level and the first to systematically study language confusion in llms. ## conclusion we have introduced the language confusion benchmark. we have shown that some llms exhibit severe language confusion and even the strongest llms do not achieve perfect performance cross-lingually. we observed that base and englishcentric instruct models are particularly susceptible to language confusion, which is exacerbated by complex prompts. finally, we proposed measures to mitigate language confusion at inference and training. our benchmark is efficient to evaluate and easy to extend and can help ensure that models achieve equal utility across languages.