> For the complete documentation index, see [llms.txt](https://whitepaper.virtuals.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whitepaper.virtuals.io/virtuals-bai-pi-shu/guan-yu-virtuals-1/xie-yi/ai-agent-xie-tong-gong-xian-yu-lai-yuan-ji-lu/mian-xiang-ai-agent-zhi-li-de-mo-kuai-hua-gong-shi-kuang-jia/qu-zhong-xin-hua-ai-agent-gong-xian-yu-nft/ai-agents-de-ren-zhi-he-xin.md).

# AI Agents 的认知核心

Cognitive Core 是 VIRTUAL 代理的中央智能层。它使用大型语言模型（LLM）、检索和持久记忆来执行任务并呈现独特的 AI 代理个性。

### 用于 AI 代理的大型语言模型

VIRTUAL 代理使用开源 LLM。Cognitive Core 结合检索增强生成和模型微调，为每个代理构建个性和领域智能。

* **AI 代理个性开发**\
  检索增强生成（RAG）用于构建代理的背景故事、传说、特征和属性。RAG 将语言生成与知识库检索相结合，创造更相关、更逼真的 AI 代理交互。
* **AI 代理中央智能**

  数据量较大的 VIRTUAL 代理使用开源模型的直接微调。微调可提升准确、领域特定的响应。指令微调进一步使 AI 代理的响应和行为与既定规则或目标保持一致。\
  \
  较小的数据集会存储在向量数据库中，并通过 RAG 检索。这使 AI 代理能够高效访问专门信息。

### AI 训练数据预处理

AI 代理训练数据可以包括来自教科书、论坛和维基的文本、视频和音频。Cognitive Core 主要使用基于文本的 LLM。视频和音频训练数据在模型训练前需要转录。

* **数据清理：** 移除噪声和空值，以保持数据完整性和质量。
* **数据转换：** 将数据集标准化，以便进行可靠的模型训练。

### 持久化 AI 代理记忆和对话上下文

VIRTUAL 代理使用持久化记忆系统进行个性化、具备上下文感知的交互。该系统在支持高效长期记忆处理的同时保留对话上下文。

1. **用户和对话识别：** 系统识别用户及其对话，以便准确回忆。
2. **长对话存储：** 系统可高效存储和处理长篇对话。

#### 唯一用户标识符

每位 VIRTUAL 代理用户都会获得一个唯一标识符。这可保持用户特定上下文和对话连续性。

<details>

<summary>示例数据库表</summary>

如下所示生成一个示例数据库表。

```sql
CREATE TABLE Messages (
    message_id VARCHAR(32) NOT NULL PRIMARY KEY,
    conversation_id VARCHAR(32) NOT NULL,
    user_id VARCHAR(32) NOT NULL,
    prompt TEXT NOT NULL,
    timestamp DATETIME NOT NULL,
    response TEXT, 
    FOREIGN KEY (conversation_id) REFERENCES Conversations(conversation_id)
);

```

</details>

#### 向量数据库和记忆检索

嵌入技术将消息向量化为数值格式，以便高效存储和检索。

当 `getPrompt('identifier', 'context', 'params')` 函数运行时，系统会从向量数据库中检索用户的消息。LLM 使用这些检索到的对话历史生成个性化、与上下文相关的响应，而无需从 dApp 添加额外上下文。

[<mark style="color:红色;">了解更多关于为 Cognitive Core 做贡献的信息。</mark>](/virtuals-bai-pi-shu/gou-jian-zhe-zhong-xin/yong-virtuals-gou-jian/agent-gong-xian/wei-cognitive-core-zuo-gong-xian.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://whitepaper.virtuals.io/virtuals-bai-pi-shu/guan-yu-virtuals-1/xie-yi/ai-agent-xie-tong-gong-xian-yu-lai-yuan-ji-lu/mian-xiang-ai-agent-zhi-li-de-mo-kuai-hua-gong-shi-kuang-jia/qu-zhong-xin-hua-ai-agent-gong-xian-yu-nft/ai-agents-de-ren-zhi-he-xin.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.
