> ## Documentation Index
> Fetch the complete documentation index at: https://docs.brainstormer.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge Graph

> Understand how entity extraction, relationships, and graph optimization enhance your knowledge base.

The knowledge graph is an advanced feature that extracts structured entities and relationships from your documents. While vector search finds content by meaning, the knowledge graph finds content by connections — enabling discovery paths that pure text similarity cannot.

## What Is the Knowledge Graph?

When you add documents to a knowledge base, the system can extract:

* **Entities** — Named things like people, organizations, products, concepts, locations
* **Relationships** — Connections between entities (e.g., "John works at Acme", "Product X uses Technology Y")
* **Aliases** — Alternative names for the same entity (e.g., "IBM" and "International Business Machines")

These form a graph structure where entities are nodes and relationships are edges, creating a network of connected knowledge across all your documents.

## How It Works

The knowledge graph is built through a three-phase extraction process:

### Phase 1: Entity Extraction

When a document is processed, an LLM analyzes the content to identify:

* **People** — Names, roles, titles
* **Organizations** — Companies, teams, departments
* **Concepts** — Ideas, methodologies, frameworks
* **Products** — Tools, services, software
* **Locations** — Places, regions, markets
* **Other** — Any other identifiable named entities

Extraction works on all content types:

* **Text** — Standard named entity recognition
* **Images** — Entities identified through vision analysis
* **Video** — Entities from transcribed audio and visual frames

<Info>
  Extraction prompts are **seeded with existing KB entities** so the LLM reuses canonical names instead of creating duplicates. If your KB already has an entity "OpenAI", the LLM will use that exact name rather than creating "Open AI" or "openai".
</Info>

### Phase 2: Entity Resolution

After initial extraction, the system runs entity resolution to find and merge duplicates:

1. **Candidate detection** — Entities with similar names are identified using:
   * Levenshtein distance (edit distance)
   * Substring matching
   * Abbreviation matching (e.g., "IBM" vs "International Business Machines")

2. **LLM confirmation** — Candidate pairs are sent to an LLM to confirm whether they refer to the same real-world entity

3. **Merge** — Confirmed duplicates are merged:
   * One entity becomes the canonical version
   * The other's name becomes an alias
   * Relationships, mentions, and metadata are consolidated

### Phase 3: Cross-Document Inference

The final phase discovers relationships between entities that appear in different documents but are never explicitly connected in any single document:

1. Document summaries and entity lists are compared across the knowledge base
2. The LLM identifies implicit relationships (e.g., if Document A mentions "John at Acme" and Document B mentions "Acme's new product", the system infers John may be connected to that product)
3. Inferred relationships are added to the graph with appropriate confidence scores

## Viewing the Knowledge Graph

To explore your knowledge graph:

1. Navigate to **Knowledge** and select a knowledge base.
2. Open the **Entities** view to see all extracted entities.

Each entity shows:

* **Name** and **type** (person, organization, concept, etc.)
* **Aliases** — Alternative names
* **Mention count** — How many times it appears across documents
* **Relationships** — Connected entities and the nature of the connection

## Managing Entities

You can manually curate your knowledge graph:

### Rename Entities

If an entity has the wrong name, you can rename it. The old name automatically becomes an alias, so existing references still work.

### Merge Entities

If the system missed a duplicate, you can manually merge two entities:

1. Select the target (canonical) entity
2. Select the source entity to merge into it
3. The source's name becomes an alias, and all relationships are transferred

### Delete Entities

Remove entities that are irrelevant or incorrect. Deleting an entity also removes all its relationships.

### Pinned Entities

You can define **known entities** that the extraction system should always look for:

1. Open the **Pinned Entities** panel
2. Add entity names and types
3. These entities will be seeded into extraction prompts, improving recognition accuracy for important terms specific to your domain

<Tip>
  Pin your key product names, brand terms, and important people. This significantly improves extraction accuracy for domain-specific terminology that the LLM might not recognize on its own.
</Tip>

## Graph Optimization

The optimization system helps you improve graph quality over time:

### Generate Suggestions

Click **Generate Suggestions** to trigger an analysis that identifies:

* **Duplicate entities** that should be merged
* **Weak relationships** that may be incorrect
* **Missing connections** that could be inferred

Suggestions are generated as a queued background job.

### Review Suggestions

Each suggestion can be:

* **Approved** — Marked as correct, ready to apply
* **Rejected** — Dismissed as incorrect
* **AI auto-resolved** — Let the AI evaluate and resolve pending suggestions automatically

### Apply Changes

Once you have reviewed suggestions, click **Apply Approved** to execute all approved changes at once. This batch operation:

* Merges duplicate entities
* Removes rejected relationships
* Adds inferred connections

## How the Graph Enhances Search

The knowledge graph improves search in several ways:

1. **Entity-based discovery** — When a query mentions a known entity, documents containing that entity and its connected entities are surfaced
2. **Relationship paths** — Search results can include the relationship path that connects the query to the result, helping users understand why a result is relevant
3. **Follow-up suggestions** — Based on entity connections, the system can suggest related questions to explore

Graph-informed results are tagged with `discoveryMethod: "graph"` in the search results, so you can see which results came from graph traversal versus semantic similarity.

<Note>
  The knowledge graph is most valuable when your knowledge base contains interconnected content — multiple documents about the same people, products, or concepts. For a single standalone document, standard vector search is usually sufficient.
</Note>

## Best Practices

<AccordionGroup>
  <Accordion title="Start with pinned entities">
    Before uploading many documents, pin your most important entities (products, key people, core concepts). This seeds the extraction process and improves accuracy from the start.
  </Accordion>

  <Accordion title="Run optimization after bulk uploads">
    After adding a batch of documents, run graph optimization to catch duplicates and discover cross-document connections.
  </Accordion>

  <Accordion title="Review AI suggestions carefully">
    AI-generated merge and relationship suggestions are usually correct, but domain-specific nuances may trip them up. Review before applying, especially for technical or niche terminology.
  </Accordion>

  <Accordion title="Use graph enhancement for cross-document discovery">
    Trigger the enhance-graph process after adding content from multiple related sources. This is where cross-document inference shines — connecting entities that appear in different documents.
  </Accordion>
</AccordionGroup>
