DocPrism: Local Categorization and External Filtering to Identify Relevant Code-Documentation Inconsistencies

Xiaomeng Xu, Zahin Wahab, Reid Holmes, Caroline LemieuxarXiv 2025 · DOI

Introduction

Maintaining synchronization between source code and its documentation is a persistent challenge in software engineering. When documentation drifts from the implementation, it creates "documentation debt," leading to developer confusion and potential bugs. While Large Language Models (LLMs) possess the semantic understanding necessary to bridge natural language and code, naive application of these models often results in excessive false positives. DocPrism addresses this by introducing a novel methodology—Local Categorization and External Filtering (LCEF)—to distinguish between meaningful inconsistencies and harmless implementation details.

The Challenge of Abstraction

The primary hurdle in automated inconsistency detection is the nature of documentation itself. Effective documentation is an abstraction; it describes what a function does without detailing every line of code. Standard LLM prompts often fail to respect this abstraction, flagging "under-promises"—where code contains more detail than the documentation—as errors. This leads to a "noise" problem where developers are overwhelmed by irrelevant alerts.

The LCEF Methodology

DocPrism utilizes the LCEF framework to refine LLM outputs. The process begins with Local Categorization, a prompting technique that uses a structured JSON schema to force the LLM into "local completion." By breaking the analysis into specific "Check-in" and "Follow-up" keys, the model maintains focus on logical consistency rather than drifting into hallucination.

Figure 2: The DocPrism workflow, illustrating the path from code/doc prompts through the LLM to final filtered output.

The system classifies potential issues into three categories:

  1. Over-Promises: The documentation claims functionality that is absent in the code.
  2. Direct Mismatches: The documentation and code logically contradict one another.
  3. Under-Promises: The code contains implementation details not mentioned in the documentation.

Crucially, DocPrism employs an External Filter to discard "under-promises," which are typically harmless abstractions, before presenting the results to the developer. This strategy effectively "tricks" the LLM into being helpful by giving it a place to categorize minor details without penalizing the final precision.

Evaluation and Results

The researchers evaluated DocPrism using a hand-labeled Python dataset (pandas and requests) and an extension dataset of 1,491 functions across TypeScript, C++, and Java.

Figure 6: Performance metrics for DocPrism across different programming languages, showing consistent precision and low flag rates.

The results demonstrate a massive reduction in noise. In ablation studies, the "flag rate" (the percentage of functions identified as inconsistent) dropped from 98% with standard prompts to just 14% with DocPrism. On the Python dataset, the tool achieved 92% accuracy and 0.64 precision. As shown in Figure 6, these results generalize well across languages, maintaining precision between 0.52 and 0.70 even in complex environments like C++.

Discussion and Limitations

DocPrism's language-agnostic approach allows it to function effectively without rigid syntax trees. However, some limitations remain. The most frequent cause of false positives is a lack of external API knowledge; for instance, the model may not recognize that a specific library call fulfills a documented requirement. Additionally, "semantic gaps" can occur when the model fails to recognize domain-specific synonyms.

Future work aims to move beyond detection to automated rectification, leveraging the LLM's natural language explanations to suggest direct fixes for identified documentation inconsistencies.

Summary updated

BibTeX
@misc{xu2025docprism,
  author = {Xiaomeng Xu and Zahin Wahab and Reid Holmes and Caroline Lemieux},
  title = {{DocPrism: Local Categorization and External Filtering to Identify Relevant Code-Documentation Inconsistencies}},
  year = {2025},
  eprint = {2511.00215},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.00215},
}
Figure