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

# Knowledge Base

> Power your agent with document-based knowledge

The Knowledge Base enables RAG (Retrieval-Augmented Generation), allowing your agent to answer questions based on your documents and content.

## Overview

When a caller asks a question:

1. The system searches your knowledge base
2. Relevant content is retrieved
3. The AI uses this content to generate accurate responses

This ensures your agent provides factual, up-to-date information rather than relying solely on training data.

## Setting Up Knowledge Base

### Creating Folders

Organize content into folders:

1. Navigate to **Knowledge Base** in the sidebar
2. Click **Create Folder**
3. Name the folder (e.g., "Product FAQ", "Policies", "Pricing")
4. Click **Create**

<Note>
  Each organization can have up to 3 folders, each with 250 MB capacity.
</Note>

### Adding Documents

#### Upload PDFs

1. Open a folder
2. Click **Upload PDF**
3. Select your file(s)
4. Wait for processing

Supported: PDF files with text content. OCR processes scanned documents.

#### Add Websites

1. Click **Add Website**
2. Enter the URL
3. The system scrapes and processes the content
4. Content is indexed for search

### Folder Limits

| Limit                    | Value          |
| ------------------------ | -------------- |
| Folders per organization | 3              |
| Storage per folder       | 250 MB         |
| File types               | PDF, TXT, DOCX |

## Attaching to Agents

### Global Attachment

Set a default KB folder for your entire agent:

1. Open Flow Builder
2. Click **Knowledge Base** in left sidebar
3. Select a folder
4. Configure retrieval settings

All conversation nodes will use this KB unless overridden.

### Node-Specific Attachment

Override for specific nodes:

1. Select a Conversation node
2. Scroll to **Knowledge Base** section
3. Select a different folder
4. Configure Top-K and reranking

```yaml theme={null}
Node: Billing Questions
Knowledge Base: /Billing-FAQ

Node: Technical Support
Knowledge Base: /Technical-Docs
```

## Retrieval Settings

### Top-K

Number of relevant chunks to retrieve (default: 5):

| Value | Effect                                |
| ----- | ------------------------------------- |
| 1-3   | More focused, may miss context        |
| 5     | Balanced (recommended)                |
| 7-10  | More comprehensive, may include noise |

### Reranking

Re-orders results by relevance (default: enabled):

```yaml theme={null}
Reranking: true  # Recommended for better accuracy
```

Reranking improves accuracy but adds slight latency.

## How RAG Works

```
Caller: "What's your return policy?"
           │
           ▼
┌─────────────────────────┐
│ 1. Search Knowledge Base │
│    Query: "return policy"│
└───────────┬─────────────┘
            │
            ▼
┌─────────────────────────┐
│ 2. Retrieve Top-K Chunks │
│    - "Returns accepted   │
│      within 30 days..."  │
│    - "Refunds processed  │
│      in 5-7 days..."     │
└───────────┬─────────────┘
            │
            ▼
┌─────────────────────────┐
│ 3. Generate Response     │
│    AI combines KB content│
│    with conversation     │
└───────────┬─────────────┘
            │
            ▼
Agent: "Our return policy allows returns within 30 days of purchase.
        Once received, refunds are processed in 5-7 business days."
```

## Best Practices for Content

<AccordionGroup>
  <Accordion title="Keep content current">
    Regularly update your knowledge base with the latest information. Outdated content leads to wrong answers.
  </Accordion>

  <Accordion title="Use clear formatting">
    Structure documents with headings, bullet points, and short paragraphs. This improves retrieval accuracy.
  </Accordion>

  <Accordion title="Remove duplicates">
    Duplicate content can confuse retrieval. Keep one authoritative source for each topic.
  </Accordion>

  <Accordion title="Use specific file names">
    Name files descriptively: "Return-Policy-2024.pdf" not "doc1.pdf"
  </Accordion>
</AccordionGroup>

## Content Types

| Content             | Good For                        |
| ------------------- | ------------------------------- |
| **FAQs**            | Common customer questions       |
| **Product docs**    | Features, specifications, usage |
| **Policies**        | Returns, warranty, terms        |
| **Pricing**         | Plans, features, add-ons        |
| **Troubleshooting** | Common issues and solutions     |

## Example Use Cases

<AccordionGroup>
  <Accordion title="Product Support">
    ```yaml theme={null}
    Folder: /Product-Documentation

    Contents:
    - User manuals for each product
    - Troubleshooting guides
    - Setup instructions
    - Compatibility information

    Usage: Technical support conversations
    ```
  </Accordion>

  <Accordion title="Policy Information">
    ```yaml theme={null}
    Folder: /Company-Policies

    Contents:
    - Return policy
    - Warranty information
    - Privacy policy
    - Terms of service

    Usage: Policy-related questions
    ```
  </Accordion>

  <Accordion title="Sales Enablement">
    ```yaml theme={null}
    Folder: /Sales-Materials

    Contents:
    - Product comparisons
    - Pricing details
    - Feature lists
    - Case studies

    Usage: Sales conversations
    ```
  </Accordion>
</AccordionGroup>

## Troubleshooting

| Issue                       | Solution                                             |
| --------------------------- | ---------------------------------------------------- |
| Wrong answers               | Check if correct folder is attached                  |
| Missing information         | Verify content was processed (check folder contents) |
| Outdated responses          | Update or re-upload source documents                 |
| Too much irrelevant content | Lower Top-K or split into focused folders            |

## Related

<CardGroup cols={2}>
  <Card title="Conversation Stage" icon="comments" href="/agent-builder/stages/conversation">
    Attach KB to conversation nodes
  </Card>

  <Card title="Global Settings" icon="gear" href="/agent-builder/global-settings">
    Set default KB for agent
  </Card>

  <Card title="System Prompt" icon="terminal" href="/agent-config/system-prompt">
    Guide how KB content is used
  </Card>
</CardGroup>
