# Conditioning LLMs to Generate Code-Switched Text

Source: [Conditioning LLMs to Generate Code-Switched Text](<https://www.sota2.com/research/paper/68fa78c51e209131cea7a6a5>)

Collection index: [llms.txt](<https://www.sota2.com/research/llms.txt>)

Data updated: 2026-03-10T05:00:05.424Z

Authors: Maite Heredia, Gorka Labaka, Jeremy Barnes, Aitor Soroa

Published: 2025-02-18T15:04:13.000Z

## Abstract

Code-switching (CS) is still a critical challenge in Natural Language Processing (NLP), due to the limited availability of large-scale, diverse CS datasets for robust training and evaluation. Despite recent advances, the capabilities and limitations of LLMs in handling CS are still not fully understood. In this work, we investigate the extent to which LLMs can be used in a framework for CS text generation, focusing on the English-Spanish language pair. Our proposed methodology consists of back-translating natural CS sentences into monolingual English, and using the resulting parallel corpus to fine-tune LLMs to turn monolingual sentences into CS. We thoroughly analyse the models' performance through a study on human preferences, a qualitative error analysis, an evaluation with popular reference-based metrics and LLM-based judgment. Results show that fine-tuning can be a key step to ensure that current LLMs consistently generate fluent code-switched text and that our methodology generates high-quality outputs, expanding research opportunities in CS communication. We find that traditional metrics do not correlate with human judgement when assessing the quality of the generated CS data, but LLM-based judgment aligns more closely with human preferences. We release our code and generated dataset under a CC-BY-NC-SA license.

## Recorded benchmark results

A research result applies to its stated dataset, split, metric and evaluation configuration. Compare like-for-like settings, preserve the metric's unit and direction, and distinguish paper-reported results from independent reproduction. The best result recorded here is not a claim of exhaustive, current global coverage.

- [Code-switched Text Generation on EN-CS In domain (test)](<https://www.sota2.com/research/sota/code-switched-text-generation-on-en-cs-in-domain-test.md>): Code-switched Text Generation; EN-CS In domain (test); BLEU: 35.56.

- [Human Preference Evaluation for Code-switched Text Generation on In-Domain Data](<https://www.sota2.com/research/sota/human-preference-evaluation-for-code-switched-text-generation-on-in-domain-data.md>): Code-switched Text Generation; English-to-Code-Switched human preference evaluation (In domain); Preference Score: 573.5.

- [Code-switched Text Generation on EN-CS Out of domain (test)](<https://www.sota2.com/research/sota/code-switched-text-generation-on-en-cs-out-of-domain-test.md>): Code-switched Text Generation; EN-CS Out of domain (test); BLEU: 15.65.

- [Human Preference Evaluation for Code-switched Text Generation on EN-CS (Out of domain)](<https://www.sota2.com/research/sota/human-preference-evaluation-for-code-switched-text-generation-on-en-cs-out-of-domain.md>): Code-switched Text Generation; English-to-Code-Switched human preference evaluation (Out of domain); Score: 282.

- [Code-Switching Generation on Code-Switching (CS) Generation Evaluation Dataset](<https://www.sota2.com/research/sota/code-switching-generation-on-code-switching-cs-generation-evaluation-dataset.md>): Code-Switching Generation; Code-Switching (CS) Generation Evaluation Dataset; Score: 603.

## Original sources and implementation

[Original paper](<https://arxiv.org/abs/2502.12924>)

[PDF](<https://arxiv.org/pdf/2502.12924.pdf>)
