# 知識庫教程

喺 0.9.1 版本入面，CherryStudio 帶嚟咗期待已久嘅知識庫功能。

下面我哋會按步驟展示 CherryStudio 嘅詳細使用說明。

## 添加嵌入模型

1. 喺模型管理服務入面搵模型，可以撳「嵌入模型」快速篩選；
2. 搵到需要嘅模型，添加到我嘅模型。

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

## 建立知識庫

1. 知識庫入口：喺 CherryStudio 左側工具欄，撳知識庫圖示，即可進入管理頁面；
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>


---

# Agent Instructions: 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:

```
GET https://docs.cherry-ai.com/docs/zhong-wen-fan-ti/knowledge-base/knowledge-base.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
