Abstract
Multilingual Information Extraction (IE) remains a significant challenge due to schema inconsistency and weak alignment across languages. We present KnowCoder-X, a novel framework that utilizes Python code as a "universal language" for IE tasks. By defining extraction schemas as Python classes and employing a specialized cross-lingual alignment phase, KnowCoder-X bridges the gap between high-resource and low-resource languages. Our results demonstrate that KnowCoder-X outperforms ChatGPT by over 30% on unseen languages and establishes new state-of-the-art benchmarks across 64 IE tasks.
Introduction
Information Extraction (IE)—the process of identifying entities, relations, and events in text—is notoriously difficult to scale across languages. While modern Large Language Models (LLMs) show some ability to transfer knowledge from high-resource languages like English, a massive performance gap remains. The core challenge is two-fold: representing extraction rules consistently across languages and aligning the extraction logic with the syntax and semantics of lower-resource languages. KnowCoder-X addresses these issues through a "Code-as-Schema" philosophy and a two-phase training approach.
Methodology
Unified Code Representation
KnowCoder-X represents schemas as Python classes instead of natural language prompts. For example, a "Person" entity is defined as a class inheriting from a base Entity class. This leverages the strict structure of code to create a language-agnostic ontology. Whether the input text is in Korean or English, the output format remains a standardized Python list of instantiated objects, allowing the model to focus on semantic understanding rather than formatting.
IE Cross-Lingual Alignment Phase
To synchronize extraction capabilities, the researchers introduced a specific instruction-tuning task called Translated Instance Prediction. The model is given a source-language sentence and its extracted entities, then asked to predict the corresponding entities for a translated version of that sentence. This forces the model to align the extraction process across linguistic boundaries.
The Three-Stage Data Pipeline
To power this alignment, a robust pipeline was developed to create high-quality parallel data:
- Joint Translation: Translates the sentence and the extracted spans simultaneously to maintain context.
- Span Rephrase: Fixes spans that were lost or mistranslated.
- Sentence Rephrase: Adjusts the translated sentence to ensure it naturally contains all the required spans.
Experimental Evaluation
The study utilizes a massive array of 64 IE benchmarks for evaluation, including the new ParallelNER dataset, a high-quality bilingual (English-Chinese) parallel NER set containing 257,190 samples. Evaluation also spanned Multiconer22 (9 unseen languages) and MasakhaNER 2.0 (20 low-resource African languages).
Key Results
Superior Generalization
On 29 unseen languages, KnowCoder-X outperformed ChatGPT by 30.17% and the previous state-of-the-art (SoTA) by 20.03%. This suggests that strengthening the alignment between any two languages helps the model better utilize its internal multilingual map.
The "Alignment Jump"
The impact of the alignment phase is best seen in pilot tests: a LLaMA2-7B model's Chinese IE performance jumped from a 5.9 F1 score to 52.7 simply by adding the proposed alignment training. Furthermore, on the MasakhaNER 2.0 benchmark for low-resource African languages, KnowCoder-X achieved an average improvement of 11.43% over previous specialized models.
Conclusion
KnowCoder-X demonstrates that treating IE as a code generation task is a highly effective strategy for multilingual scaling. By standardizing schemas through Python classes and focusing on cross-lingual alignment, the framework significantly reduces the performance gap between languages. Future work will involve expanding the alignment phase to more diverse language pairs and refining the model's performance on domain-specific jargon.
The code and datasets are available at: https://github.com/ICT-GoKnow/KnowCoder
Summary updated