# How the Article-Analyzer Extracts Entities from Knowledge Base Wikis in Understand-Anything

> Discover how the article-analyzer extracts entities from knowledge base wikis using LLM semantic inference and markdown parsing. Convert wiki prose into structured knowledge graph nodes with Understand Anything.

- Repository: [Egonex/Understand-Anything](https://github.com/Egonex-AI/Understand-Anything)
- Tags: internals
- Published: 2026-06-27

---

**The article-analyzer agent combines deterministic markdown parsing with LLM-driven semantic inference to discover entities implicit in wiki prose, converting them into structured knowledge graph nodes while filtering duplicates from explicit wikilinks.**

The `article-analyzer` agent in the Egonex-AI/Understand-Anything repository transforms raw markdown wiki pages into structured knowledge graphs. Unlike simple link extraction, this component identifies semantic entities mentioned in text but not explicitly linked, bridging the gap between raw content and actionable knowledge graph data.

## Structural Preprocessing with extract-structure.mjs

Before any LLM invocation, the pipeline runs deterministic preprocessing via `extract-structure.mjs`. This script parses every markdown file using **tree-sitter** for code blocks and language-specific parsers for other content.

The parser produces a deterministic JSON structure that records headings, front-matter, tags, and explicit wikilinks. This structured representation serves as the foundation for all subsequent entity extraction, ensuring the LLM receives consistent, machine-readable input rather than raw markdown.

## LLM-Driven Semantic Inference

The core extraction logic resides in [`understand-anything-plugin/packages/core/src/analyzer/llm-analyzer.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/core/src/analyzer/llm-analyzer.ts) (lines 81-106). The agent feeds the pre-processed JSON to the LLM via the `llm-analyzer` module, prompting the model to identify implicit knowledge.

The prompt specifically requests a JSON list of **entity** nodes—and optionally **claim**, **topic**, and **source** nodes—that are implicit in the text and not already represented by explicit wikilinks. This distinction ensures the system captures semantic meaning beyond surface-level linking.

```json
{
  "entities": [
    { "name": "OpenAI", "type": "organization", "description": "AI research lab" },
    { "name": "GPT-4", "type": "model", "description": "large language model" }
  ]
}

```

## Creating Entity Nodes and Graph Edges

Each extracted entity becomes a graph node of type `entity`. The core schema defines this node type in [`understand-anything-plugin/packages/core/src/schema.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/core/src/schema.ts) (line 375), with the TypeScript union declared in [`understand-anything-plugin/packages/core/src/types.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/core/src/types.ts) (line 7).

The analyzer generates edges connecting newly identified entities to the source article node or to other entities when the LLM indicates implicit relationships. The system filters out duplicate edges that already exist from explicit wikilinks, preventing redundancy while maintaining relationship integrity.

```typescript
import { addNode, addEdge } from "@understand-anything/core";

entities.forEach(e => {
  const nodeId = addNode({ kind: "entity", name: e.name, meta: e });
  addEdge({ source: articleNodeId, target: nodeId, kind: "mentions" });
});

```

## Batch Processing Limits and Pipeline Integration

To maintain graph performance and manage API costs, the agent caps extraction volumes per batch:

- **5-15 entities** per batch
- **5-10 claims** per batch  
- **10-20 implicit edges** per batch

These limits ensure the knowledge graph remains manageable while processing large wiki corpora.

The `article-analyzer` runs sequentially in the pipeline after `knowledge-scanner` and `format-detector`, and before `relationship-builder` (lines 174-183). This positioning ensures entity nodes are available when downstream agents compute cross-article relationships.

```typescript
await dispatch({
  name: "article-analyzer",
  batchSize: 10,
  args: {
    extractionFile: `${projectRoot}/.understand-anything/tmp/ua-article-extract-results.json`,
  },
});

```

## Summary

- **Structural preprocessing** via `extract-structure.mjs` converts markdown to deterministic JSON using tree-sitter and language-specific parsers.
- **LLM inference** through the `llm-analyzer` module identifies implicit entities not captured by explicit wikilinks.
- **Node creation** uses the `entity` type defined in [`schema.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/schema.ts) and [`types.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/types.ts) to populate the knowledge graph.
- **Edge deduplication** prevents duplicate relationships between explicit wikilinks and LLM-generated connections.
- **Batch limits** enforce constraints of 5-15 entities and 10-20 edges per processing batch.
- **Pipeline position** places the analyzer between format detection and relationship building for optimal data flow.

## Frequently Asked Questions

### What is the difference between explicit wikilinks and LLM-extracted entities?

Explicit wikilinks are markdown syntax links (e.g., `[[Entity Name]]`) that users manually create in wiki pages. LLM-extracted entities are semantic concepts identified by the language model that appear in prose but lack explicit linking syntax. The article-analyzer captures both types but uses deduplication logic to ensure they do not create redundant graph nodes.

### How does the article-analyzer handle code blocks in markdown?

The analyzer uses **tree-sitter** parsers to accurately identify and process code blocks within markdown files. This ensures that code snippets are properly parsed as distinct structural elements rather than prose text, preventing the LLM from hallucinating entities from programming syntax while preserving the structural integrity of the document.

### What are the batch size limits for entity extraction?

The system enforces strict caps to maintain performance: approximately **5-15 entities**, **5-10 claims**, and **10-20 implicit edges** per batch. These limits prevent overwhelming the knowledge graph with excessive nodes from a single article and help manage LLM API rate limits and costs during bulk processing.

### Where is the entity node type defined in the Understand-Anything codebase?

The `entity` node type is formally defined in [`understand-anything-plugin/packages/core/src/schema.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/core/src/schema.ts) at line 375, with the TypeScript type union appearing in [`understand-anything-plugin/packages/core/src/types.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/core/src/types.ts) at line 7. The UI layer also recognizes this type in [`understand-anything-plugin/packages/dashboard/src/store.ts`](https://github.com/Egonex-AI/Understand-Anything/blob/main/understand-anything-plugin/packages/dashboard/src/store.ts) (lines 14-27), ensuring consistent handling across the entire system.