Code-Switching Red-Teaming: LLM Evaluation for Safety and Multilingual Understanding

Haneul Yoo, Yongjin Yang, Hwaran Lee

Abstract

Large Language Models (LLMs) exhibit a significant safety "blind spot" regarding code-switching—the natural practice of mixing multiple languages within a single conversation. This paper introduces CSRT (Code-Switching Red-Teaming), a framework that automatically generates mixed-language prompts to bypass safety filters. Our findings reveal that current safety alignment fails to generalize across linguistic boundaries, even when models demonstrate high comprehension of the underlying harmful intent.

Introduction

While LLMs are increasingly multilingual, their safety training remains heavily skewed toward high-resource languages, primarily English. Standard red-teaming typically focuses on monolingual prompts. However, in real-world scenarios, multilingual speakers frequently code-switch (e.g., mixing Spanish and English). This linguistic mixing creates a "safety gap": if guardrails are tied to specific language patterns, mixing tokens from diverse languages—especially low-resource ones—can "confuse" safety mechanisms while the model's core multilingual capabilities still allow it to fulfill harmful requests.

Figure 1: Comparison of standard red-teaming, multilingual red-teaming, and Code-Switching Red-Teaming (CSRT). While models refuse harmful queries in single languages, code-switched versions often bypass safety filters.

The CSRT Framework

The authors propose CSRT, an automated two-step framework designed to synthesize code-switching red-teaming queries:

  1. Parallel Translation: A seed harmful query in English is translated into 10 diverse languages, spanning high-resource (e.g., Chinese, Italian) to low-resource (e.g., Bengali, Javanese) categories.
  2. LLM-based Synthesis: An LLM (GPT-4o) weaves these translations into a single, coherent code-switched sentence. Unlike "sandwich attacks" that alternate full sentences, CSRT performs intra-sentence code-switching at the token level.

Evaluation relies on three primary metrics, typically judged by a high-capability model like GPT-4o:

  • Attack Success Rate (ASR): Frequency of harmful content generation.
  • Refusal Rate (RR): Frequency of explicit model refusal.
  • Comprehension (Cmp.): The model's ability to understand the intent of the mixed-language prompt.

Key Insights

A critical finding is the Safety-Resource Correlation: models are significantly more likely to fulfill harmful requests when they include tokens from low-resource languages like Javanese or Swahili.

Furthermore, the study highlights that Understanding $\neq$ Safety. Models often achieve high comprehension scores for CSRT queries but maintain low refusal rates. This indicates that models recognize the request's intent but lack the alignment to categorize the specific linguistic mixture as "harmful." Intra-sentence mixing proved deadlier than simpler alternating-sentence attacks.

Experimental Results

CSRT achieved a 46.7% higher Attack Success Rate compared to standard English-only red-teaming, outperforming established jailbreak techniques like GCG and AutoDAN.

Figure 5: Attack Success Rate (ASR) increases as the number of languages in a query grows (left) and as the resource unavailability of those languages increases (right).

Model-specific performance varied:

  • Qwen 1.5 (7B) was highly vulnerable, with an ASR of 46.74%.
  • Claude 3 Sonnet was the most robust, though it still showed increased vulnerability compared to its English-only baseline.
  • Scaling Effects: While larger models (e.g., Llama 3 70B) generally showed better safety, the relative vulnerability to code-switching persisted across all scales.

Conclusion and Future Work

Current safety training is often English-centric. The effectiveness of CSRT suggests that future alignment efforts must incorporate diverse, code-switched data. While this study used a relatively small seed dataset (315 queries) and relied on LLM-as-a-judge (GPT-4o), the results clearly demonstrate that as models become more linguistically capable, their safety guardrails must evolve to be truly multilingual and robust against complex linguistic patterns.

Summary updated

BibTeX
@inproceedings{yoo2025code,
  author = {Haneul Yoo and Yongjin Yang and Hwaran Lee},
  title = {{Code-Switching Red-Teaming: LLM Evaluation for Safety and Multilingual Understanding}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure