> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/agent-builder/knowledge-base.md).

# Knowledge Base

## What Is This? <a href="#what-is-this" id="what-is-this"></a>

A Knowledge Base is the enterprise knowledge encyclopedia for your Agent. You add company documents, FAQs, and web content to the Knowledge Base, and the Agent can answer user questions based on this data.

Without a Knowledge Base, the Agent can only respond using the language model's general knowledge. With a Knowledge Base, it can answer enterprise-specific questions like "What is our company's return policy?"

## What Can Go in a Knowledge Base? <a href="#what-can-go-in-knowledge-base" id="what-can-go-in-knowledge-base"></a>

| Data Type           | Description                                 | Suitable Scenarios                                       |
| ------------------- | ------------------------------------------- | -------------------------------------------------------- |
| **Document Upload** | PDF, Word, Excel, TXT, etc.                 | Product manuals, internal guidelines, contract templates |
| **FAQ**             | Question-answer pairs                       | Frequently asked questions, standard responses           |
| **Crawler Import**  | Automatically scrape content from web pages | Official website information, public data                |

## How Is It Different from a Database? <a href="#knowledge-base-vs-database" id="knowledge-base-vs-database"></a>

This is the most frequently asked question:

|                  | Knowledge Base                                                       | Database                                             |
| ---------------- | -------------------------------------------------------------------- | ---------------------------------------------------- |
| **Data Type**    | Unstructured (documents, articles, FAQs)                             | Structured (tables, fields, numbers)                 |
| **Query Method** | Semantic search ("What is the return policy?")                       | SQL queries ("What was last month's revenue?")       |
| **Best For**     | Knowledge-based questions, policy guidelines, operating instructions | Data queries, statistical analysis, real-time status |

**Simple rule of thumb**: If the answer is in a "document," use a Knowledge Base; if the answer is in a "report," use a Database.

> **Advanced Note**: The Knowledge Base uses RAG (Retrieval-Augmented Generation) technology under the hood. Uploaded documents are split into paragraphs and converted into vectors. When a user asks a question, the system finds the most relevant paragraphs and provides them to the Agent as the basis for its response.

## What Do I Need to Do? <a href="#what-do-i-need-to-do" id="what-do-i-need-to-do"></a>

1. **Create a Knowledge Base** — Name it and select an Embedding model
2. **Import Data** — Upload documents, create FAQs, or use a crawler to scrape content
3. **Search Test** — Test the Knowledge Base with sample questions to verify it finds the correct answers
4. **Attach to an Agent** — Link this Knowledge Base in the Agent settings

## Further Reading <a href="#further-reading" id="further-reading"></a>

* [Knowledge Base Overview](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/tree/main/en/km/km.md)
* [How to Create a Knowledge Base: Basic Settings](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/tree/main/en/km/km-basic-settings.md)
* [How to Create FAQs](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/tree/main/en/km/faq.md)
* [Document Management: Tags and Metadata](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/tree/main/en/km/tags-and-metadata.md)
* [Search Test](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/tree/main/en/km/test-search-result.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/agent-builder/knowledge-base.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
