CodeNER: Code Prompting for Named Entity Recognition

Read full text
Authors: Sungwoo Han, Hyeyeon Kim, Jingun Kwon, Hidetaka Kamigaito, Manabu Okumura
Cited by: 0

Abstract

Recent studies have explored various approaches for treating candidate named entity spans as both source and target sequences in named entity recognition (NER) by leveraging large language models (LLMs). Although previous approaches have successfully generated candidate named entity spans with suitable labels, they rely solely on the input context information when using LLMs, particularly, ChatGPT. However, NER inherently requires capturing detailed labeling requirements with input context information. To address this issue, we propose a novel method that leverages code-based prompting to improve the capabilities of LLMs in understanding and performing NER. By embedding code within prompts, we provide detailed Beginning-Inside-Outside (BIO) schema instructions for labeling, thereby exploiting the ability of LLMs to comprehend long-range scopes in programming languages. Experimental results demonstrate that the proposed code-based prompting method outperforms conventional text-based prompting on ten benchmarks across English, Arabic, Finnish, Danish, and German datasets, indicating the effectiveness of explicitly structuring NER instructions. Furthermore, our in-depth analysis showed that the performance improvement of the proposed method stems from code-based structuring and BIO-guided processing rather than from simple entity-label descriptions. Moreover, the method maintained its effectiveness or demonstrated additional performance improvements when combined with Chain-of-Thought (CoT) prompting and few-shot settings.

Fields of Study & Subjects

Topic Modeling Natural Language Processing Techniques Advanced Graph Neural Networks

Publication details

Journal / source
IEEE Access
Volume
14
Pages
94377–94392
Publication date
1 January 2026
Language
EN