Explanation based In-Context Demonstrations Retrieval for Multilingual Grammatical Error Correction (2025)

Abstract: Grammatical error correction (GEC) aims to correct grammatical, spelling, and semantic errors in natural language text. With the growing of large language models (LLMs), direct text generation has gradually become the focus of the GEC methods, and few-shot in-context learning presents a cost-effective solution. However, selecting effective in-context examples remains challenging, as the similarity between input texts does not necessarily correspond to similar grammatical error patterns. In this paper, we propose a novel retrieval method based on natural language grammatical error explanations (GEE) to address this issue. Our method retrieves suitable few-shot demonstrations by matching the GEE of the test input with that of pre-constructed database samples, where explanations for erroneous samples are generated by LLMs. We conducted multilingual GEC few-shot experiments on both major open-source and closed-source LLMs. Experiments across five languages show that our method outperforms existing semantic and BM25-based retrieval techniques, without requiring additional training or language adaptation. This also suggests that matching error patterns is key to selecting examples. Our code and the constructed database will be publicly available after the paper is published.

## introduction the goal of grammatical error correction (gec) is to correct errors in natural language text, including grammatical, spelling, and certain semantic errors @xcite . in the context of language learning, gec methods can assist learners in correcting mistakes in written text @xcite . gec can be considered a form of machine translation, where the input is a potentially erroneous text, and the output is its corrected version @xcite . as a result, text-to-text generation figure 1 : the comparison between input-based demonstrations and explanation-based demonstrations for gec. samples with similar inputs do not necessarily contain the same grammatical error patterns. however, through preliminary checks and initial explanations, it is possible to retrieve samples with similar errors from a database indexed by grammatical error explanations, even if the semantics of the demonstrations differs significantly from the test input. models underpin many gec approaches @xcite . while edit-based methods exist that modify specific parts of the text for correction @xcite , the rise of large language models (llms) @xcite has made direct text generation the dominant approach in gec. given the need for language learning across different languages, multilingual gec has become an important area of research. this challenge is often tackled by constructing datasets and training models separately for each language @xcite . with large-scale pre-training on multilingual data, the performance of llms in multilingual contexts is gradually improving @xcite , and llms are increasingly being applied to the multilingual gec domain @xcite . few-shot inference can achieve strong performance on downstream tasks through in-context learning (icl) without the need for fine-tuning llms @xcite . effective icl depends on selecting appropriate in-context examples, or demonstrations, which can be guided by established principles @xcite . the selection process can be facilitated through retrieval mechanisms, such as k-nearest neighbors (knn)-based retrieval @xcite ). one advantage of example-based gec systems is that they can enhance system interpretability by providing learners with illustrative examples @xcite . for retrieving in-context examples, previous studies primarily use the test input as the query and the input texts of labeled data as keys for the database @xcite . matching between query and keys is typically based on semantic or syntactic similarities, or methods like bm25 @xcite @xcite . this approach is intuitive since both the test input and the input text of labeled data are from the same domain-if the inputs are similar, the corresponding labels are likely similar as well. however, gec tasks pose a unique challenge, as grammatical errors are often local and bear little correlation to the overall structure of the text. consequently, inputbased retrieval often fails to retrieve references with analogous grammatical errors. we propose that a more fundamental solution lies in using the relationship between the input text and the label as the basis for retrieval. recent works have begun to explore leveraging the interaction between text and label to improve in-context example selection @xcite . for gec, we hypothesize that this relationship can be effectively captured through grammatical error explanations (gee) @xcite . in this paper, we introduce a novel retrieval method based on natural language explanations, applicable in multilingual settings. our method uses gee as both the query and key for retrieval, aiming to retrieve examples with similar grammatical errors to serve as demonstrations for in-context learning. without requiring model training, this approach enhances llm few-shot performance on multilingual gec tasks. figure 1 presents an illustrative example where traditional semantic matching fails to retrieve relevant samples, while explanation-based matching successfully identifies a sample with a similar grammatical error. to implement this, we first use labeled data and llms to generate gee and construct a database. during inference, the input text undergoes a grammar check, providing an initial explanation, which is then matched against the gee database to retrieve suitable demonstrations. these demonstrations are used in the icl process to produce the final grammatical corrections. we conducted experiments on gec datasets across five languages. our proposed method consistently outperforms semantic and bm25 retrieval in terms of the f 0.5 score across both open-source and closed-source models. the advantages of the proposed method contain: 1) it requires no additional training, leveraging icl to tap into the intrinsic gec capabilities of llms. some studies suggest that the f 0.5 score underestimates llm gec performance, with human evaluations yielding better results @xcite . 2) it is highly extendable to multilingual settings, as the use of natural language explanations ensures applicability across languages. 3) the system is more interpretable, with each demonstration linked to a gee. the main contributions of this work are as follows: ## methods this section presents our design of a gec system based on few-shot in-context learning using grammatical error explanation (gee). first, we describe how to construct a database with gee using labeled data in advance. then, we explain the retrieval process based on explanations during inference, where no labels are available. finally, we outline the fewshot template for gec. ## conclusion in conclusion, this paper presents a novel approach for retrieving demonstrations based on grammatical error explanations (gee) to enhance in-context learning (icl) for the multilingual grammatical error correction (gec) task. our method addresses the challenge of selecting effective incontext demonstrations by matching gee within a constructed demonstration database, improving the few-shot performance of llms in multilingual gec without requiring additional training. future work will explore: 1) methods for indexing correct samples with suitable explanations, which was not fully addressed in this work; 2) refining the retrieval method. in this study, only text embeddings were used as representations for explanations; and 3) further refinement of gee. a more systematic form of gee and its evaluation methodologies would facilitate the evolution of retrieval systems based on this framework. additionally, it would also promote the application of gee within the domain of gec. we believe that explanation-based demonstration retrieval has broader implications for icl across all natural language processing downstream tasks. for gec, we consider few-shot inference to be the most effective approach for building an explainable multilingual gec system using llms. as llms' multilingual capabilities continue to improve, we expect that few-shot icl will become an efficient and cost-effective solution for gec.