arXiv:2610.20272cs.CLOct 2026

Manuscript Offprint

arXiv:2610.20272

CSWBench: Evaluating Context-Sensitive Code-Switching in Creative Writing

Zewen Jiang, Yahan Li, Chenlu Guo, Diana Inkpen, Yuan Wu, Yi Chang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language models (LLMs) have demonstrated multilingual capabilities across diverse language generation and understanding tasks. Yet effective code-switching requires more than multilingual proficiency: models must decide when, where, and why to switch languages in ways that fit the surrounding context. This context-sensitive ability remains insufficiently evaluated. We introduce CSWBench, a benchmark for evaluating context-sensitive code-switching in creative writing through two complementary settings: Focused Narrative and Extended Narrative. We further propose CSWEval, a theory-informed framework with two complementary levels: event-level evaluation of Licensing, Contextual Appropriateness, and Functional Gain, and whole-text evaluation of task-specific quality—overall literary and narrative quality in Focused Narrative and quality emphasizing multilingual organization in Extended Narrative. Evaluating twelve LLMs, we find that models exhibit meaningful but uneven code-switching competence across narrative contexts. Model differences are particularly pronounced in multilingual literary integration, while multilingual-focused dimensions show stronger difficulty effects overall than the general narrative dimensions; narratively salient switches are associated with stronger contextual and functional realization; and event-level CS quality is moderately associated with whole-text performance. The artifact is available at https://github.com/TPSJASPER/CSWBench.

1 Introduction

Code-switching (CS) refers to the alternation between two or more languages or language varieties

Figure

Figure 1: Illustrative distinction between genuine code-switching and surface multilingual material. The examples distinguish meaningful language switches from English expressions that do not constitute code-switching (CS). A genuine switch involves English use attributable to current speaker or discourse voice as part of an ongoing interaction or narrative. By contrast, proper names, conventionalized borrowings, and quoted or displayed English without active uptake are excluded. The distinction depends on how English participates in discourse, rather than on the mere presence of English words.

within the same interaction or discourse (Gardner-Chloros, 2009; Bullock and Toribio, 2009). Its meaning depends on social and conversational context, serving identity expression, relationship negotiation, interlocutor accommodation, and affective communication (Gumperz, 1982; De Fina, 2007; Ladegaard, 2018; Giles et al., 1991). Such context-sensitive language choices are also common in contemporary digital communication, where they serve a range of communicative and pragmatic functions (Bali et al., 2014; Rudra et al., 2016; Rijhwani et al., 2017).

Existing code-switching evaluations have largely

BenchmarkTaskGranularityGenerationCS ChoiceCS Orch.Salience
LinCE (Aguilar et al., 2020)CS NLPToken / Utterance××××
CodeMixBench (Yang and Chai, 2025)CS UnderstandingToken / Text△×××
ChiEngMixBench (Yang et al., 2026)CS GenerationSentence Pair / Text✓✓××
LitBench (Fein et al., 2026)Creative WritingStory Pair✓×××
WritingBench (Wu et al., 2025b)WritingWhole Text✓×××
CSWBenchCreative WritingEvent + Whole Text✓✓✓✓

Table 1: Comparison of CSWBench with representative code-switching and writing benchmarks. Task denotes the evaluation setting; Granularity lists representative assessment units. Generation denotes evaluation of generated text; CS Choice indicates whether switching decisions are evaluated against contextual conditions; CS Orch. indicates whether multilingual behavior is assessed across a text; and Salience indicates whether the narrative importance of individual switches is considered. √ denotes explicit coverage, △ partial coverage, and × an aspect not evaluated. NLP = natural language processing; CS = code-switching; Orch. = orchestration.

examined how models process code-switched inputs through downstream NLP tasks, including language identification, named entity recognition, question answering, and natural language inference (Aguilar et al., 2020; Khanuja et al., 2020). LLM-era studies have extended this paradigm to translation, reasoning, and truthfulness (Huzaifah et al., 2024; Yang and Chai, 2025; Mohamed et al., 2026). Meanwhile, generated CS has been evaluated for fluency, naturalness, and semantic fidelity (Heredia et al., 2025; Aksüt et al., 2026), or against naturally occurring switching patterns (Sterner and Teufel, 2025; Winata et al., 2026). Yet whether LLMs can make contextually appropriate, functionally motivated code-switching decisions remains comparatively underexplored.

Creative writing foregrounds the context-sensitive nature of code-switching, as literary language choices can be deliberately staged within a narrative (Grutman, 2024). Characters' linguistic resources, relationships, and circumstances provide grounds for judging individual switches. For example, a character who speaks English cautiously might repeat an interlocutor's English phrase to challenge a claim. Whether this switch is convincing depends on the character's established language abilities, its fit with the ongoing exchange, and the contribution it makes to the disagreement. Across a narrative, such choices can also shape characterization, relationships, and narrative development (Gardner-Chloros and Weston, 2015; Baldo and Deganutti, 2024). Creative writing thus makes the contextual grounding, local functions, and broader narrative roles of code-switching observable and evaluable.

To fill this gap, we introduce CSWBench, a benchmark for evaluating whether LLMs can use code-switching as a context-sensitive language choice in creative writing. Drawing on spontaneous and controlled Chinese–English source material, CSWBench transforms screened bilingual records into structured narrative prompts that preserve their interactional grounding while adding limited narrative scaffolding through model-assisted construction, programmatic checks, and recorded screening and refinement. The benchmark comprises two complementary settings: Focused Narrative, which foregrounds individual code-switching choices within their local narrative contexts, and Extended Narrative, which places greater emphasis on the organization and development of multilingual behavior across the narrative as a whole.

Drawing on sociolinguistic and literary theories of code-switching, we develop CSWEval, a multi-level evaluation framework that assesses individual switching events in terms of Licensing, Contextual Appropriateness, and Functional Gain, together with task-specific whole-text quality, including multilingual organization in Extended Narrative. Evaluating twelve contemporary LLMs reveals three recurring patterns. First, multilingual literary integration clearly differentiates models, while multilingual-focused dimensions show stronger difficulty effects overall than the general narrative dimensions. Second, switches that carry greater narrative importance also tend to be more successfully realized in their immediate context and function. Third, local CS quality is moderately associated with whole-text performance.

Our contributions are threefold:

(i) We introduce CSWBench, a benchmark for evaluating context-sensitive code-switching in creative writing through complementary Focused and Extended Narrative settings that foreground local multilingual choices and whole-text multilingual organization, respectively.

(ii) We develop CSWEval, a theory-informed, evidence-grounded evaluation framework that distinguishes Licensing, Contextual Appropriateness, and Functional Gain at the event level from task-specific quality at the whole-text level.

(iii) We conduct a systematic evaluation of twelve contemporary LLMs, providing empirical evidence on where models succeed and fail in using code-switching as a context-sensitive narrative resource.

References (41)