Abstract
Recent research in information extraction (IE) focuses on utilizing code-style inputs to enhance structured output generation. The intuition behind this is that the programming languages (PLs) inherently exhibit greater structural organization than natural languages (NLs). This structural advantage makes PLs particularly suited for IE tasks. Nevertheless, existing research primarily focuses on Python for code-style simulation, overlooking the potential of other widely-used PLs (e.g., C++ and Java) during the supervised fine-tuning (SFT) phase. In this research, we propose Multiple Programming Languages with large language models for information extraction (abbreviated as MPL), a novel framework that explores the potential of incorporating different PLs in the SFT phase. Additionally, we introduce function-prompt with virtual running to simulate code-style inputs more effectively and efficiently. Experimental results on a wide range of datasets demonstrate the effectiveness of MPL. Furthermore, we conduct extensive experiments to provide a comprehensive analysis. Our code and additional files are in the supplementary materials.
Introduction
Information Extraction (IE)—the process of identifying entities, relations, and events in text—is fundamentally a structured prediction task. While Large Language Models (LLMs) have shown remarkable proficiency in natural language (NL), NL instructions can be ambiguous for complex IE tasks. Recent research has moved towards "code-style" prompting, framing IE tasks as code generation. Programming languages (PLs) offer a more formal and structured scaffolding than NL, which helps guide LLMs toward structured outputs.
However, current code-style IE methods suffer from two main drawbacks. First, they rely almost exclusively on Python, ignoring the unique structural benefits of other languages like C++ or Java. Second, the prevalent "class-prompt" approach is highly verbose, requiring the model to repeatedly define classes and constructors, which wastes tokens and reduces training efficiency.
Methodology
We introduce MPL (Multiple Programming Languages), a framework designed to overcome these limitations through two core innovations:
Multi-PL Supervised Fine-Tuning (SFT)
MPL shifts the paradigm by training the model on IE tasks reformulated into multiple programming languages, including Python, C++, and Java. This cross-linguistic training encourages the model to develop a robust, language-agnostic understanding of information structure. The structural diversity of different PLs acts as a powerful regularizer, improving generalization.
Function-Prompt with Virtual Running
To address the verbosity of traditional class-prompts, MPL utilizes a "function-prompt" approach. Instead of complex class definitions, the task is wrapped in a single function. The prompt includes a function call with the input text, and the model is tasked with generating the "return" value—the extracted data—simulating a "virtual running" environment.
Experimental Setup
MPL was evaluated across a broad range of IE benchmarks, including ACE05 (NER, RE, EAE, EE), BC5CDR, CoNLL03, DIANN, NCBID, OntoNotes 5.0, WNUT2017, and RAMS. We tested the framework using several model backbones: CodeLLaMA-7B, CodeLLaMA-13B, and LLaMA3-8B.
Results and Analysis
MPL consistently outperformed existing state-of-the-art models such as GoLLIE and KnowCoder. As shown in the performance summary, the MPL-8B model (based on LLaMA3) achieved an average score of 77.6, notably outperforming the much larger GoLLIE-34B model (76.5).
Diversity and Efficiency
Our analysis reveals that diversity in programming languages is more effective than simply increasing the volume of single-language training data. While tripling Python-only data led to overfitting, distributing the same data across three PLs significantly improved results. Furthermore, the function-prompt approach reduced average input length by approximately 20%, enhancing both training efficiency and model focus.
In zero-shot settings, MPL demonstrated strong generalization, particularly on the Broad_Twitter dataset, where it outperformed GoLLIE-34B by over 5 points. The framework is backbone-agnostic, showing consistent improvements across all tested LLMs.
Conclusion
The MPL framework highlights the benefits of using multiple programming languages and efficient function-based prompting for information extraction. By leveraging the structural properties of various PLs and reducing prompt redundancy, MPL achieves superior performance and efficiency compared to existing methods. Future work will explore expanding the set of programming languages and further optimizing the training process.
Summary updated