{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/explanation-based-in-context-demonstrations","title":"Explanation based In-Context Demonstrations Retrieval for Multilingual Grammatical Error Correction","arxiv_id":"2502.08507","date":"2025-02-12","proceeding":null,"authors":["Wei Li","Wen Luo","Guangyue Peng","Houfeng Wang"],"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.","url_abs":"https://arxiv.org/abs/2502.08507v1","url_pdf":"https://arxiv.org/pdf/2502.08507v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"explanation-based-in-context-demonstrations","repo_url":"https://github.com/gmago-leway/fewshotgec","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"grammatical-error-correction","task_name":"Grammatical Error Correction"},{"task_slug":"in-context-learning","task_name":"In-Context Learning"},{"task_slug":"retrieval","task_name":"Retrieval"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[{"method_slug":"focus","method_name":"Focus"},{"method_slug":"gee","method_name":"GEE"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2502.08507","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2502.08507"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/TartuNLP/estgec","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"deterministic:regex_extraction","url":"https://github.com/GMago-LeWay/FewShotGEC","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":5},"by_repo_kind":{"official":{"samples":5,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"b5c7b2f5cf30567d","entry":"gec_extract_answer","repo":"GMago-LeWay/FewShotGEC","repo_kind":"official","path":"icl.py","file_url":"https://github.com/GMago-LeWay/FewShotGEC/blob/HEAD/icl.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b5c7b2f5cf30567d"}},{"code_sha256_prefix":"9d5aa9ff4a2580b5","entry":"gec_extract_answer","repo":"GMago-LeWay/FewShotGEC","repo_kind":"official","path":"icl_prepare.py","file_url":"https://github.com/GMago-LeWay/FewShotGEC/blob/HEAD/icl_prepare.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9d5aa9ff4a2580b5"}},{"code_sha256_prefix":"6cf7ccab9586de56","entry":"gec_split_answer","repo":"GMago-LeWay/FewShotGEC","repo_kind":"official","path":"icl.py","file_url":"https://github.com/GMago-LeWay/FewShotGEC/blob/HEAD/icl.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6cf7ccab9586de56"}},{"code_sha256_prefix":"07b276811116091c","entry":"postprocess","repo":"GMago-LeWay/FewShotGEC","repo_kind":"official","path":"generate.py","file_url":"https://github.com/GMago-LeWay/FewShotGEC/blob/HEAD/generate.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"07b276811116091c"}},{"code_sha256_prefix":"ca931f77e5edb0c1","entry":"start_end_extraction","repo":"GMago-LeWay/FewShotGEC","repo_kind":"official","path":"generate.py","file_url":"https://github.com/GMago-LeWay/FewShotGEC/blob/HEAD/generate.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ca931f77e5edb0c1"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}