> 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/en-us/knowledge-base/data.md).

# Knowledge Base Data

This page is for users who want to understand the underlying workings of the knowledge base. If you only need to use the knowledge base, you can refer directly to [Knowledge Base Tutorial](/docs/en-us/knowledge-base/knowledge-base.md).

## Core Principles

Documents added to the knowledge base will be**split into small chunks → converted into numeric vectors by the embedding model → stored in the local database**. When asking a question, the knowledge base converts the question into a similar vector, retrieves the most similar chunks, and provides these chunks to the chat model as context.

<figure><img src="/files/ade75a9173f41300ffb2ff9ff34cc89f128a428a" alt=""><figcaption><p>Knowledge base processing flowchart</p></figcaption></figure>

## A bit more detailed

1. **Preparation before ingestion**
   * Documents (PDF, Word, web pages, etc.) first undergo [Document preprocessing](/docs/en-us/knowledge-base/document-preprocessing.md)(OCR, etc.), becoming plain text
   * The plain text is split into small chunks of about 200–500 Chinese characters (chunk), making retrieval easier
2. **Embedding and storage**
   * Each chunk is handed to [embedding model](/docs/en-us/knowledge-base/emb-models-info.md) processing to obtain a set of numbers (vectors)
   * These numbers + the original text chunks are all stored in Cherry Studio's local database (based on the open-source libSQL)
3. **Query**
   * When you ask a question, the question text is also converted into numbers by the embedding model
   * The system finds several chunks that are "most similar to the question numbers"
   * These chunks, together with the question, are sent to the chat model, which generates the final answer

## Data storage location

**All data is stored locally**and is not uploaded to the cloud (if the embedding model used is itself a cloud service, the text chunks will briefly pass through that service during embedding processing).

* **macOS**:`~/Library/Application Support/CherryStudio`
* **Windows**:`%APPDATA%\CherryStudio`
* **Linux**:`~/.config/CherryStudio`

## Data privacy recommendations

If the materials involve sensitive information (contracts, medical records, internal code, etc.):

* Use**Local embedding model**(for example via [Ollama](/docs/en-us/pre-basic/providers/ollama.md) or [LM Studio](/docs/en-us/pre-basic/providers/lm-studio.md) Run `bge-m3`), fully offline throughout
* It is also recommended to choose a locally deployed chat model
* Can be paired with [Change storage location](/docs/en-us/pre-basic/personalization-settings/storage.md) to store data on an encrypted disk

## Further reading

* Vector database (libSQL / Turso):<https://turso.tech/libsql>
* For embedding and retrieval-augmented generation, you can look up materials related to "vector embedding" and "RAG"

***

### 💡 Get help and submit feedback

If you encounter any questions, bugs, or have suggestions for feature improvements during configuration or use, please refer to [Feedback and Suggestions](/docs/en-us/question-contact/suggestions.md) the official channels provided there.


---

# 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/en-us/knowledge-base/data.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.
