NER Retriever: Zero-Shot Named Entity Retrieval with Type-Aware Embeddings

Or Shachar, Uri Katz, Yoav Goldberg, Oren Glickman · DOI

Abstract

Traditional Named Entity Recognition (NER) systems are often constrained by predefined schemas, limiting their utility in open-ended search scenarios. We introduce NER Retriever, a zero-shot framework designed for Named Entity Retrieval (NERetrieval). By extracting "type-aware" internal representations—specifically mid-layer Value (V) vectors—from Large Language Models (LLMs) and refining them via contrastive learning, our system enables the retrieval of arbitrary entity types from natural language queries. NER Retriever significantly outperforms lexical and sentence-level baselines on diverse benchmarks, including MultiCoNER 2 and Few-NERD, while maintaining high storage efficiency.

Introduction

Standard NER models typically classify text spans into a small set of fixed categories (e.g., Person, Location). However, real-world information needs are often ad-hoc and fine-grained, such as searching for "rare tropical fruits" or "19th-century poets." Existing approaches to this "NERetrieval" task often rely on sentence-level embeddings, which can dilute entity-specific information with irrelevant context, or LLM prompting, which is computationally prohibitive at scale. NER Retriever addresses these challenges by building a searchable index of entity-specific, type-aware embeddings.

Methodology

The NER Retriever pipeline consists of three distinct stages:

  1. Entity Detection: A category-agnostic model (based on Qwen 2.5) identifies potential entity spans within the corpus. This step focuses on "entity-ness" rather than classification.
  2. Type-Aware Embedding Extraction: The system extracts internal representations from a frozen LLM (e.g., Llama 3.1 8B). Empirical analysis revealed that the "Value" (V) vectors in the middle layers (specifically around layer 17) contain the most potent taxonomic information for entity typing.
  3. Contrastive Projection: A lightweight Multi-Layer Perceptron (MLP) projects these high-dimensional LLM vectors into a 500-dimensional space. The MLP is trained using a triplet contrastive loss to align entity mentions with their corresponding natural language type descriptions.
The NER Retriever architecture extracts contextual representations from middle LLM layers for indexing and retrieval.

At retrieval time, a user's query is embedded into the same shared space, allowing for efficient nearest-neighbor search against the indexed entity mentions.

Empirical Analysis of LLM Representations

A key contribution of this work is the discovery of the "mid-layer sweet spot." While many embedding techniques use the final layers of an LLM, our research shows that these layers are often optimized for next-token prediction and general semantics, which can obscure specific categorical details.

Heatmap showing AUC for type discrimination across different LLM components and layers, identifying layer 17's Value vectors as optimal.

As shown in the heatmap above, the middle layers—particularly the Value projection (V proj) components—exhibit the highest Area Under the Curve (AUC) for distinguishing between entity types. This suggests that these layers act as an internal "knowledge store" for taxonomic information.

Results and Discussion

NER Retriever was evaluated on several benchmarks, including Few-NERD (66 types) and MultiCoNER 2 (33 types).

  • Superior Performance: On MultiCoNER 2, NER Retriever achieved an R-Precision of 0.32, vastly outperforming E5-Mistral (0.09) and BM25 (0.08).
  • Zero-Shot Generalization: The system successfully retrieved entities for 100 held-out types in the NERetrieve test set, demonstrating its ability to leverage the latent knowledge of the base LLM for unseen categories.
  • Efficiency: By compressing representations into 500 dimensions, the system reduced index storage requirements by 79% compared to state-of-the-art dense models like NV-Embed v2.

Conclusion

NER Retriever provides a scalable and flexible solution for open-ended entity search. By "peeking" into the middle layers of LLMs, the framework captures rich taxonomic information that is often lost in standard output embeddings. Future work will explore the use of domain-specific LLMs to enhance performance in specialized fields like medicine or law, and aim to mitigate the "detection bottleneck" where imperfect span identification limits overall retrieval accuracy.

Summary updated

BibTeX
@misc{shachar2025ner,
  author = {Or Shachar and Uri Katz and Yoav Goldberg and Oren Glickman},
  title = {{NER Retriever: Zero-Shot Named Entity Retrieval with Type-Aware Embeddings}},
  year = {2025},
  eprint = {2509.04011},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.04011},
}
Figure