Conditioning LLMs to Generate Code-Switched Text

Maite Heredia, Gorka Labaka, Jeremy Barnes, Aitor Soroa
2/18/2025
cs.CLcs.AI

No official code found. Best implementation: hitz-zentroa/cs-generation (1 star, last commit 2025-02-19).

Abstract

Code-switching (CS) is still a critical challenge in Natural Language Processing (NLP). Current Large Language Models (LLMs) struggle to interpret and generate code-switched text, primarily due to the scarcity of large-scale CS datasets for training. This paper presents a novel methodology to generate CS data using LLMs, and test it on the English-Spanish language pair. We propose back-translating natural CS sentences into monolingual English, and using the resulting parallel corpus to fine-tune LLMs to turn monolingual sentences into CS. Unlike previous approaches to CS generation, our methodology uses natural CS data as a starting point, allowing models to learn its natural distribution beyond grammatical patterns. We thoroughly analyse the models' performance through a study on human preferences, a qualitative error analysis and an evaluation with popular automatic metrics. Results show that our methodology generates fluent code-switched text, expanding research opportunities in CS communication, and that traditional metrics do not correlate with human judgement when assessing the quality of the generated CS data. We release our code and generated dataset under a CC-BY-NC-SA license.

View on arXivView PDF

Code Implementations(1)

Code-switching Generation using LLMs: Methodology and Evaluation

10Perl, ShellNov 19, 20241 years ago

Similar Papers

Cite this paper

@article{heredia2025conditioning,
  title  = {Conditioning LLMs to Generate Code-Switched Text},
  author = {Maite Heredia and Gorka Labaka and Jeremy Barnes and Aitor Soroa},
  year   = {2025},
  eprint = {2502.12924},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.12924v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.12924.svg)](https://codeofpaper.com/paper/2502.12924)

Discussion