Large Language Models for Stemming: Promises, Pitfalls and Failures

Shuai Wang, Shengyao Zhuang, Guido ZucconarXiv 2024

TL;DR

While Large Language Models (LLMs) excel at understanding context, directly using them to replace traditional text stemmers in Information Retrieval (IR) pipelines yields surprisingly poor results and high computational costs. However, using LLMs as intelligent "entity shields"—identifying proper nouns that should not be stemmed while letting traditional algorithms handle the rest—significantly boosts retrieval effectiveness.

What Problem Does This Paper Address?

Stemming is a foundational text preprocessing step in Information Retrieval (IR) systems like BM25. By reducing words to their base or root form (e.g., converting "programming" and "programs" to "program"), stemmers help match user queries to relevant documents even when exact word forms differ.

However, traditional stemmers (like the rule-based Porter stemmer or dictionary-based Krovetz stemmer) operate on words in isolation. They lack context awareness, which leads to errors. For instance, a traditional stemmer might mistakenly stem the company name "Programs PTY. LTD." into "program," destroying the specific meaning of the entity and introducing noise into search results. Given LLMs' profound grasp of context, the authors of this paper ask a natural question: Can we leverage LLMs to build a better, context-aware stemming pipeline?

Methods

The authors investigate three distinct avenues for integrating LLMs (specifically GPT-3.5, LlaMa-2-7b-chat, and SOLAR-10.7B-instruct) into the stemming process:

  1. Vocabulary Stemming (VS): A cost-efficient approach where the unique vocabulary of a collection is extracted, and the LLM is prompted to provide the root form for each isolated word.
  2. Contextual Stemming (CS): The entire document or query is fed into the LLM, which is tasked with outputting a fully stemmed version of the text while contextually avoiding proper nouns.
  3. Entity-based Contextual Stemming (ECS): Instead of asking the LLM to stem text, the LLM is used purely as a Named Entity Recognition (NER) tool to extract entities (names, brands, organizations) that should be protected. The remaining text is then stemmed using a traditional tool like the Porter stemmer.

The authors test two variations of ECS:

  • ECS.1: Entities are indexed only in their original, unstemmed form.
  • ECS.2: Entities are indexed in both their original and stemmed forms to maximize matching flexibility.
Fig. 1. Pipeline for stemming techniques described in the study.

The prompts used to instruct the LLMs for each method are structured as one-shot tasks, as detailed in the paper's prompt registry.

Table 1. Prompts for three LLM-based stemming methods. Italicised text indicates variables that are replaced with the respective content.

Datasets

Due to the massive computational footprint of running LLMs over large text corpora, the authors evaluated their methods on two moderately sized, standard IR benchmarks:

  • Trec-Covid: Consists of 171,332 biomedical documents and 50 test queries.
  • Trec-Robust04-LAT: A subset of the TREC Robust04 collection containing 171,332 news-wire articles from the LA Times and 249 test queries.

To keep the computational load manageable, documents were truncated to their first 300 words.

Key Insights and Ideas

  • LLMs are Terrible at Direct Stemming: Counter-intuitively, using LLMs to directly stem text (VS and CS methods) performed significantly worse than the classic, 40-year-old Porter stemmer. LLMs struggle with the highly specific, rigid constraints of morphological reduction at scale.
  • Contextual Stemming is a Computational Nightmare: Running full-document contextual stemming (CS) on just one of the small test datasets required over 200 hours on an Nvidia A100 GPU, making it entirely impractical for production-scale IR.
  • The "Entity Shield" Strategy Wins: The true value of LLMs in this pipeline is not their ability to stem, but their ability to identify what to leave alone.
  • Dual-Indexing Entities is Crucial: Simply leaving entities unstemmed (ECS.1) didn't outperform the baseline. The breakthrough came with ECS.2, which indexes both the raw and stemmed versions of entities, capturing both highly specific entity matches and broader conceptual matches.

Key Results

The quantitative evaluation highlights a clear winner: the ECS.2 pipeline combining LlaMa-2 (for entity extraction) and the Porter stemmer.

As shown in the main results table, this specific combination achieved a statistically significant improvement over the standalone Porter stemmer baseline. On the Trec-Covid dataset, it boosted Mean Average Precision (MAP) from 0.1896 (Porter baseline) to 0.2410. On the Trec-Robust04-LAT dataset, MAP increased from 0.0853 to 0.0962. Interestingly, LlaMa-2 outperformed both the commercial GPT-3.5 model and a task-specific, fine-tuned RoBERTa NER model in this hybrid pipeline.

Table 2. Main result table for LLM-based stemming methods. Statistical significance is assessed using a Student’s two-tailed paired t-test with a Bonferroni correction (𝑝< 0.05) with respect to the Porter Stemmer, denoted by *.

Limitations and Future Work

Despite the performance gains of the ECS.2 method, the authors note several limitations:

  • Computational Overhead: Even though ECS is cheaper than full contextual stemming (because the LLM generates fewer output tokens), running an LLM for entity extraction across millions of documents remains computationally expensive compared to traditional pipelines.
  • Document Truncation: The experiments were limited to the first 300 words of each document due to budget constraints; performance on full-length documents remains unexamined.
  • Language Constraint: This study focused exclusively on English.

For future work, the authors suggest exploring how these foundational models perform as stemmers for morphologically rich languages other than English, which currently lack highly optimized rule-based stemmers. They also propose integrating LLM-powered query term expansion directly into the ECS framework.

Summary updated

BibTeX
@misc{wang2024large,
  author = {Shuai Wang and Shengyao Zhuang and Guido Zuccon},
  title = {{Large Language Models for Stemming: Promises, Pitfalls and Failures}},
  year = {2024},
  eprint = {2402.11757},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.11757},
}
Figure