# Knowledge Base And RAG

## 1. Purpose

The knowledge base lets FastBee answer questions based on platform documents, project delivery files, product manuals, and protocol materials. Use it when answers must be grounded in specific documents.

## 2. Workflow

```mermaid
%%{init: {"flowchart": {"htmlLabels": false}}}%%
flowchart LR
  A["Create knowledge base"] --> B["Upload documents"]
  B --> C["Parse and chunk"]
  C --> D["Build version"]
  D --> E["Test retrieval"]
  E --> F["Publish version"]
  F --> G["Use in chat or protocol adaptation"]
```

## 3. Document Preparation

| Item | Recommendation |
| --- | --- |
| File content | Remove unrelated pages, repeated covers, and obsolete appendix content. |
| Naming | Include product, module, version, and date. |
| Permission | Confirm whether the document contains customer-sensitive information. |
| Format | Prefer structured Markdown, PDF, Word, or text files that can be parsed reliably. |

## 4. Version Management

Use versions to keep retrieval stable. After documents change, create a new version, test retrieval, and publish it only after the result is acceptable. Keep the previous version available for rollback.

## 5. Retrieval Validation

| Check Item | Expected Result |
| --- | --- |
| Hit accuracy | The returned chunks come from the expected document and section. |
| Answer grounding | The answer does not invent content outside the retrieved context. |
| Version status | Only the published version is used by production users. |
| Permission | Users cannot retrieve knowledge outside their authorized scope. |

## 6. Common Problems

| Problem | Check |
| --- | --- |
| No answer | Model availability, published version, document parsing status. |
| Wrong answer | Chunk size, document quality, prompt, and retrieval top-k. |
| Old answer | Whether the new version has been published. |
| Slow answer | Model latency, retrieval index size, and timeout settings. |

## Related Docs

* [AI Overview](https://www.fastbee.cn/doc/en/business/v2/manual/ai-overview.html)
* [Model Provider](https://www.fastbee.cn/doc/en/business/v2/manual/ai-provider.html)
* [Protocol Adaptation](https://www.fastbee.cn/doc/en/business/v2/manual/ai-protocol-adaptation.html)
