> For the complete documentation index, see [llms.txt](https://docs.cherryai.com.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cherryai.com.cn/docs/zhong-wen-fan-ti/knowledge-base/knowledge-base.md).

# 知識庫教程

知識庫就好似幫 AI 配一本**專屬參考書**：你將自己嘅文件、筆記、網頁放入去，之後傾偈嗰陣叫 AI 翻呢本書嚟答。

> 唔知知識庫可以做乜？先睇 [知識庫（功能介紹）](/docs/zhong-wen-fan-ti/cherry-studio/preview/knowledge-base.md) 嘅幾個使用場景。

呢頁會帶你行完整個流程：**添加嵌入模型 → 建立知識庫 → 放資料 → 喺對話入面調用**。

## 添加嵌入模型

1. 喺 `設定 → 模型服務` 入面，搵到你常用嘅 Provider（如 CherryIN、硅基流動、OpenAI 等）；
2. 撳 **獲取模型列表**，喺頂部 Tab 轉去 **嵌入** 分類；
3. 揀需要嘅嵌入模型加到我嘅模型列表（推薦 `bge-m3` 或者 `text-embedding-3-small`）。

<figure><img src="/files/e5c9735d797d5af48a1476161d123e4539c4ac23" alt=""><figcaption></figcaption></figure>

## 建立知識庫

1. **入口**：頂部 Tab `+` → **啟動台** → 撳 `知識庫`（或者喺左側欄版面下撳知識庫圖示）；
2. **添加**：撳 **+ 添加**，開始建立知識庫；
3. **命名 + 揀模型**：輸入名稱同揀嵌入模型（以 `bge-m3` 為例），就可以完成建立。

<figure><img src="/files/56a31596dc119212fcb284234ddd168b89f4819d" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2f3bc9604bc50bf7263beb17f96f68c927aa7675" alt=""><figcaption></figcaption></figure>

## 添加檔案並向量化

1. 添加檔案：撳添加檔案個按鈕，打開檔案選擇；
2. 揀檔案：揀支援嘅檔案格式，例如 pdf、docx、pptx、xlsx、txt、md、mdx 等，然後打開；
3. 向量化：系統會自動進行向量化處理，當顯示完成時（綠色 ✓），即代表向量化已完成。

<figure><img src="/files/78f4b042cbe048db6d743edfd0c33e0906d0afa4" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/156671e63a098d5d13d320eddfb2142080082944" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/e83bde0d442cffb53c2b531780993cdf3bcf917b" alt=""><figcaption></figcaption></figure>

## 添加多種來源嘅數據

CherryStudio 支援多種添加數據嘅方式：

1. 資料夾目錄：可以添加成個資料夾目錄，呢個目錄底下支援格式嘅檔案會自動向量化；
2. 網址連結：支援網址 URL，例如<https://docs.siliconflow.cn/introduction>；
3. 網站地圖：支援 XML 格式嘅網站地圖，例如<https://docs.siliconflow.cn/sitemap.xml>；
4. 純文字筆記：支援輸入純文字嘅自訂內容。

{% hint style="info" %}
提示：

1. 匯入知識庫嘅文件入面嘅插圖暫時唔支援轉做向量，需要手動轉做文字；
2. 用網址做知識庫來源未必一定成功，有啲網站有比較嚴格嘅反爬機制（或者需要登入、授權等），所以呢個方式未必攞到準確內容。建立完成後建議先搜尋測試吓。
3. 一般網站都會提供 sitemap，例如 CherryStudio 嘅[sitemap](https://docs.cherry-ai.com/sitemap-pages.xml)，一般情況下喺網站嘅根地址（即網址）後面加 /sitemap.xml 就可以攞到相關資訊。例如`aaa.com/sitemap.xml` 。
4. 如果網站冇提供sitemap，或者網址比較雜，可以自己組合一個 sitemap 嘅 XML 檔案嚟用；檔案暫時需要用公網可直接訪問嘅直鏈方式填入，本地檔案連結唔會被識別。

> 1) 可以叫 AI 生成 sitemap 檔案，或者叫 AI 寫一個 sitemap 嘅 HTML 生成器工具；
> 2) 直鏈可以用 OSS 直鏈或者網盤直鏈等方式生成。如果冇現成工具，都可以去[ocoolAI](https://one.ocoolai.com/login)官網，登入之後用網站頂欄嘅免費檔案上傳工具嚟生成直鏈。
>    {% endhint %}

## 搜尋知識庫

當檔案等資料向量化完成後，就可以查詢：

1. 撳頁面下方嘅搜尋知識庫按鈕；
2. 輸入查詢內容；
3. 顯示搜尋結果；
4. 並顯示該條結果嘅匹配分數。

<figure><img src="/files/268effc0bdb93f85bf39e254174e1c2d5f291396" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/dc49adca8afa5e48a9e28454481bd9a949fb0979" alt=""><figcaption></figcaption></figure>

## 喺對話入面引用知識庫生成回覆

1. 建立一個新話題，喺對話工具欄入面撳知識庫，就會展開已經建立嘅知識庫列表，揀需要引用嘅知識庫；
2. 輸入並發送問題，模型就會返回透過檢索結果生成嘅答案；
3. 同時，引用嘅數據來源會附喺答案下方，可以快速睇返源文件。

<figure><img src="/files/c463fc8bc0ece08040774960d8f0b36314c0af30" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/e6bdab1b06d511f1647f766ac3f4ec9ea1b678e6" alt=""><figcaption></figcaption></figure>

***

### 💡 取得幫助同提交反饋

如果你喺配置或者使用過程中遇到任何疑問、Bug 或者有功能改進建議，請參考 [反饋與建議](/docs/zhong-wen-fan-ti/question-contact/suggestions.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.cherryai.com.cn/docs/zhong-wen-fan-ti/knowledge-base/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.
