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

# Knowledge Base

> Give your agents specialized knowledge from your documents.

The Knowledge Base lets you upload documents that your agents can reference during conversations. Using vector search and RAG (Retrieval-Augmented Generation), agents find relevant information from your documents to provide accurate, grounded responses.

## How It Works

1. **Upload** documents (PDF, TXT, MD, DOCX)
2. **Processing** — Documents are chunked and converted into vector embeddings
3. **Storage** — Embeddings are stored in PostgreSQL with pgvector
4. **Retrieval** — When relevant, agents search your knowledge base and include findings in their responses

## Adding Documents

<Steps>
  <Step title="Navigate to Knowledge">
    Go to your agent's settings and select the **Knowledge** tab.
  </Step>

  <Step title="Upload files">
    Drag and drop files or click to browse. Supported formats:

    | Format       | Extensions      |
    | ------------ | --------------- |
    | PDF          | `.pdf`          |
    | Text         | `.txt`, `.md`   |
    | Documents    | `.docx`         |
    | Spreadsheets | `.csv`, `.xlsx` |
  </Step>

  <Step title="Wait for processing">
    Documents are automatically chunked and embedded. This may take a few moments for large files.
  </Step>

  <Step title="Verify">
    Your documents appear in the knowledge list. You can preview chunks and test search queries.
  </Step>
</Steps>

## How Agents Use Knowledge

When you ask a question, the agent:

1. Converts your question into a vector embedding
2. Searches the knowledge base for semantically similar chunks
3. Includes the most relevant chunks as context
4. Generates a response grounded in your documents

<Tip>
  For best results, upload well-structured documents with clear headings and sections. The chunking algorithm preserves document structure.
</Tip>

## Managing Knowledge

* **Add** new documents at any time
* **Remove** outdated documents
* **Re-sync** to update embeddings after document changes
* **Test** search queries to verify retrieval quality
