第184章 LearningService
184.1 学习服务的提出
在前面的系统结构中,ICAI已经形成了从目标、能力、方法、决策、行为、执行、结果、反馈,到记忆、经验、风险、诊断和修复的完整运行链。
但是,仅仅记录这些数据还不能形成真正意义上的持续认知系统。
如果一次行为执行成功,系统只保存“成功”这个结果,而没有更新相关能力;如果某个方法连续执行失败,系统仍然继续认为该方法可用;如果某个对象状态已经发生变化,系统仍然按照旧知识进行判断,那么系统虽然拥有大量历史数据,却不能产生有效的认知更新。
因此,需要建立 LearningService(学习服务)。
LearningService不是机器学习模型,也不是神经网络训练器,而是ICAI中的认知数据更新服务。
其基本任务是:
根据真实执行结果、反馈、验证结果、历史、记忆、经验、知识和诊断结果,对现有知识、能力和方法进行确定性的更新。
因此,本章将学习定义为:
Learning=Evidence+Comparison+Verification+UpdateLearning = Evidence + Comparison + Verification + Update
其中:
Evidence:证据;Comparison:比较;Verification:验证;Update:更新。
学习不是简单地“增加数据”,而是:
利用已经发生并经过验证的事实,改变系统未来的认知计算依据。
184.2 LearningService的定义
LearningService可以定义为:
LearningService是ICAI中负责接收学习数据、分析实际结果、确认变化、更新知识、更新能力和更新方法的应用服务。
其核心模型为:
LS=(L,K,C,M)LS=(L,K,C,M)
其中:
L:Learning,学习处理;K:Knowledge Update,知识更新;C:Capability Update,能力更新;M:Method Update,方法更新。
因此:
LearningService=Learning+KnowledgeUpdate+CapabilityUpdate+MethodUpdateLearningService = Learning + KnowledgeUpdate + CapabilityUpdate + MethodUpdate
LearningService本身不直接代表知识、能力或方法。
它负责协调:
LearningService
↓
LearningEngine
↓
Knowledge / Capability / Method
↓
Repository
↓
MySQL
也就是说:
- Knowledge负责“知道什么”;
- Capability负责“能做什么”;
- Method负责“怎么做”;
- LearningService负责“根据实际发生的结果,是否需要改变这些内容”。
184.3 ICAI中的学习定义
ICAI中的学习与传统机器学习中的“模型训练”不同。
本系统不通过:
- Transformer;
- Neural Network;
- Embedding;
- Vector Search;
- LLM;
- Prompt Engineering;
- 大模型参数训练;
形成学习能力。
ICAI中的学习是:
对已发生事实进行记录、比较、验证、归纳,并根据明确规则修改知识、能力和方法状态。
因此可以建立:
Learning=History+Memory+Experience+Feedback+VerificationLearning = History + Memory + Experience + Feedback + Verification
但是这些数据并不是全部直接修改系统,而必须经过验证和更新规则。
完整过程为:
Execution
→ Result
→ Feedback
→ History
→ Memory
→ Experience
→ Verification
→ Learning
→ Knowledge Update
→ Capability Update
→ Method Update
因此,学习发生在真实运行数据之后。
184.4 学习数据来源
LearningService不自己制造事实。
学习数据必须来自系统已经产生的真实数据。
主要来源包括:
| 数据来源 | 学习意义 |
|---|---|
| Result | 实际结果 |
| Feedback | 结果和状态反馈 |
| State History | 状态变化 |
| Behavior History | 行为执行历史 |
| Decision History | 决策历史 |
| Memory | 已保存的重要信息 |
| Experience | 已形成的经验 |
| Knowledge | 当前知识 |
| Verification | 验证结果 |
| Diagnosis | 异常原因 |
| Repair | 修复结果 |
| Risk | 风险变化 |
| Conflict | 冲突变化 |
因此:
LearningData=R+F+H+M+E+K+V+D+RpLearningData = R+F+H+M+E+K+V+D+Rp
其中:
R= Result;F= Feedback;H= History;M= Memory;E= Experience;K= Knowledge;V= Verification;D= Diagnosis;Rp= Repair。
184.5 学习不是简单记录
必须严格区分:
记录
学习
更新
记录只回答:
发生了什么?
学习回答:
这次发生的事情是否能够改变未来的认知依据?
更新回答:
应该改变什么?
例如某个方法执行一次失败。
系统不能直接得到:
Method = Invalid
因为一次失败可能来自:
- 对象状态错误;
- 环境条件不满足;
- 能力不足;
- 参数错误;
- 资源不足;
- 方法本身不适用;
- Action执行错误;
- 外部环境变化。
因此:
Failure
→ Feedback
→ Diagnosis
→ Evidence
→ Verification
→ Learning
→ Method Update
而不是:
Failure → Method Invalid
这也是ICAI学习系统与简单统计系统的重要区别。
184.6 Learning的基本计算模型
学习可以表示为:
Lt+ΔF→Lt+1L_t + \Delta F \rightarrow L_{t+1}
其中:
L_t:当前学习数据;ΔF:经过验证的新事实;L_{t+1}:更新后的学习数据。
进一步:
ΔF=Verified(Evidence)\Delta F = Verified(Evidence)
因此:
Lt+1=Update(Lt,Verified(Evidence))L_{t+1} = Update(L_t,Verified(Evidence))
这个模型说明:
未验证的数据不能直接作为正式学习结果。
184.7 知识更新
184.7.1 知识的作用
第174章已经定义Knowledge:
K=(S,P,O,C,St)K=(S,P,O,C,S_t)
其中:
S:Subject,主体;P:Predicate,关系或谓词;O:Object,对象;C:Condition,成立条件;S_t:知识状态。
Knowledge描述的是:
系统当前认为某个事实、关系或规则是什么。
LearningService负责判断:
新发生的事实是否需要改变已有知识。
184.7.2 知识更新模型
知识更新可以表示为:
Kt+1=Kt+ΔKK_{t+1}=K_t+\Delta K
其中:
K_t:当前知识;ΔK:经过验证的知识变化;K_{t+1}:更新后的知识。
但ΔK不能直接来自任何输入。
必须满足:
ValidUpdate=Evidence∧Comparison∧Verification∧ConditionValidUpdate = Evidence \land Comparison \land Verification \land Condition
也就是说:
新事实
→ 比较旧知识
→ 判断差异
→ 验证证据
→ 判断条件
→ 形成知识变化
→ 更新知识
184.8 知识更新的类型
LearningService中的知识更新至少包括以下几种类型。
1. 新增知识
原系统没有该事实:
Unknown
→ Evidence
→ Verification
→ New Knowledge
例如:
Object A
has
Property B
经过实际验证后,新增:
A → has → B
2. 修改知识
已有知识发生变化:
K_old
→ New Evidence
→ Verification
→ K_new
例如:
设备状态 = Available
实际运行后发现:
设备状态 = Maintenance
则知识需要更新。
3. 失效知识
知识曾经有效,但当前条件已经不成立:
Valid
→ Environment Change
→ Re-evaluation
→ Outdated
因此知识状态不能只有:
valid / invalid
而应至少支持:
candidate
valid
verified
unverified
outdated
invalid
conflicted
archived
4. 冲突知识
系统同时出现两个互相冲突的知识:
K1
↕
Conflict
↕
K2
此时不能简单删除其中一个,而应进入:
Conflict Detection
→ Evidence Comparison
→ Verification
→ Resolution
184.9 能力更新
Capability在第159章中定义为:
C=(T,Co,S,R,V)C=(T,Co,S,R,V)
其中:
T:Capability Type;Co:Condition;S:State;R:Range;V:Verification。
LearningService需要解决的问题是:
实际运行结果是否证明当前能力定义仍然正确?
184.10 能力更新的来源
能力更新主要来自:
Execution
Result
Feedback
Verification
Experience
Diagnosis
例如系统原本认为:
Capability A
State = Available
实际执行:
Execution
→ Result
→ Success
→ Verification
则可以增加该能力的实际验证记录。
如果多次实际执行失败,则不能直接删除能力,而应重新评估:
Capability
→ Failure History
→ Diagnosis
→ Condition Check
→ Range Check
→ State Re-evaluation
最终可能产生:
Available
→ Limited
或者:
Available
→ Unavailable
184.11 能力状态更新
能力状态可以表示为:
Unknown
→ Candidate
→ Available
→ Limited
→ Unavailable
→ Blocked
→ Recovered
状态更新必须依据事实。
例如:
Capability A
Range = 100
实际验证发现:
Range = 60
则不能继续认为:
Range = 100
而应更新为:
Range = 60
或者:
VerifiedRange = 60
DeclaredRange = 100
这样系统才能区分:
理论能力范围与实际验证能力范围。
184.12 能力更新模型
能力更新可以表示为:
Ct+1=Update(Ct,F,V,E)C_{t+1}=Update(C_t,F,V,E)
其中:
C_t:当前能力;F:Feedback;V:Verification;E:Experience;C_{t+1}:更新后的能力。
能力更新主要包括:
Type Update
Condition Update
State Update
Range Update
Verification Update
因此:
ΔC=ΔT+ΔCo+ΔS+ΔR+ΔV\Delta C = \Delta T+\Delta Co+\Delta S+\Delta R+\Delta V
并不是每一次学习都会修改所有字段。
例如:
成功执行
→ Verification增加
可能只增加验证证据,而不改变能力范围。
184.13 方法更新
Method在第160章定义为:
M=(T,C,P,A,R)M=(T,C,P,A,R)
其中:
T:Method Type;C:Method Condition;P:Process;A:Action;R:Result。
方法描述:
在什么条件下,通过什么过程和动作获得什么结果。
LearningService需要根据实际执行情况判断:
当前方法是否仍然适合当前条件。
184.14 方法更新来源
方法更新主要来自:
Method Execution
→ Result
→ Feedback
→ Comparison
→ Diagnosis
→ Experience
→ Verification
→ Method Update
方法更新可以来源于:
- 成功执行;
- 部分成功;
- 执行失败;
- 重试成功;
- Action失败;
- 条件变化;
- 环境变化;
- 资源变化;
- 新经验形成;
- 修复结果;
- 方法之间的比较。
184.15 方法更新类型
方法更新主要包括:
1. 条件更新
原方法:
Method A
Condition = C1
实际运行发现只有:
C1 ∧ C2
才能稳定完成。
则:
Condition
C1
↓
C1 ∧ C2
2. 流程更新
原流程:
A1 → A2 → A3
实际执行发现:
A1 → A3 → A2
结果更稳定,则可以形成新的方法流程候选。
3. Action更新
如果:
A2
持续失败,而:
A4
能够达到相同目标,则可以产生:
A2
→ Replacement Candidate
→ A4
但是否真正替换,应由DecisionService进行选择。
因此:
LearningService可以产生方法更新候选,但不应该绕过DecisionService直接进行所有决策。
4. 方法状态更新
方法可以具有:
inactive
ready
running
completed
failed
blocked
cancelled
学习后可能发生:
ready
→ limited
或者:
ready
→ blocked
也可能:
failed
→ revised
→ ready
184.16 学习与决策的关系
LearningService不等于DecisionService。
两者职责不同:
LearningService
负责:
过去发生了什么
→ 应该更新什么
DecisionService
负责:
当前有哪些候选
→ 当前选择哪个
因此:
Experience
→ LearningService
→ Capability / Method Update
→ DecisionService
→ Candidate Evaluation
→ Selected Candidate
学习改变未来决策的依据。
决策使用学习后的依据。
184.17 学习与知识、能力、方法的关系
三者可以形成一个递进结构:
Knowledge
↓
知道什么
↓
Capability
↓
能做什么
↓
Method
↓
怎么做
而LearningService负责根据实际运行结果不断更新三者:
Result
↓
Feedback
↓
Verification
↓
LearningService
├── Knowledge Update
├── Capability Update
└── Method Update
因此形成:
Experience→Learning→Knowledge→Capability→Method→DecisionExperience \rightarrow Learning \rightarrow Knowledge \rightarrow Capability \rightarrow Method \rightarrow Decision
184.18 LearningService的核心流程
完整流程可以定义为:
Receive Learning Data
↓
Validate Evidence
↓
Load Current Knowledge
↓
Load Current Capability
↓
Load Current Method
↓
Compare Actual / Expected
↓
Diagnosis / Verification
↓
Generate Learning Result
↓
Update Knowledge
↓
Update Capability
↓
Update Method
↓
Record Learning History
↓
Generate New Experience
↓
Return Updated Cognitive State
这里有一个重要原则:
学习结果必须可以追溯。
系统必须能够回答:
为什么知识发生了变化?
为什么能力发生了变化?
为什么方法发生了变化?
因此每一次更新都必须保留:
source
evidence
old_value
new_value
reason
condition
verification
time
184.19 LearningResult
可以定义统一的学习结果对象:
LR=(I,T,O,B,N,R,V,Tm)LR=(I,T,O,B,N,R,V,Tm)
其中:
I:Learning ID;T:Learning Type;O:Target Object;B:Before;N:New Value;R:Reason;V:Verification;Tm:Time。
例如:
Learning ID:
L00021
Type:
METHOD_UPDATE
Target:
Method A
Before:
A1 → A2 → A3
New:
A1 → A3 → A2
Reason:
Repeated execution comparison
Verification:
Verified
Time:
2026-09-11
这样系统以后能够追踪:
方法为什么变成现在这个样子。
184.20 LearningService的PHP工程结构
在ICAI的PHP OOP架构中,可以定义:
class LearningService
{
protected $learningRepository;
protected $knowledgeService;
protected $capabilityService;
protected $methodService;
protected $verificationService;
public function __construct(
$learningRepository,
$knowledgeService,
$capabilityService,
$methodService,
$verificationService
) {
$this->learningRepository = $learningRepository;
$this->knowledgeService = $knowledgeService;
$this->capabilityService = $capabilityService;
$this->methodService = $methodService;
$this->verificationService = $verificationService;
}
public function learn($data)
{
$validated = $this->validateEvidence($data);
if (!$validated) {
return false;
}
$result = $this->generateLearningResult($data);
if (!$result) {
return false;
}
$this->updateKnowledge($result);
$this->updateCapability($result);
$this->updateMethod($result);
$this->learningRepository->save($result);
return $result;
}
}
这里LearningService只是协调服务。
具体计算应继续分离到Engine。
184.21 LearningEngine
可以建立:
class LearningEngine
{
public function analyze($learningData)
{
$result = array();
$result['knowledge'] = $this->analyzeKnowledge($learningData);
$result['capability'] = $this->analyzeCapability($learningData);
$result['method'] = $this->analyzeMethod($learningData);
return $result;
}
protected function analyzeKnowledge($data)
{
return array();
}
protected function analyzeCapability($data)
{
return array();
}
protected function analyzeMethod($data)
{
return array();
}
}
实际系统中,每一个分析函数都应该根据明确规则计算,而不是调用生成式模型。
184.22 LearningService与其他Service的关系
LearningService位于整个认知更新链的重要位置:
FeedbackService
↓
MemoryExperienceService
↓
RiskConflictService
↓
DiagnosisRepairService
↓
LearningService
↓
KnowledgeService
CapabilityService
MethodService
↓
DecisionService
↓
BehaviorService
但是这不是单向结构。
系统实际运行是循环的:
Decision
→ Behavior
→ Action
→ Execution
→ Result
→ Feedback
→ Memory
→ Experience
→ Learning
→ Knowledge / Capability / Method
→ Decision
因此LearningService是认知循环中的更新节点。
184.23 数据库设计
可以建立学习记录表:
CREATE TABLE learning_records (
id INT NOT NULL AUTO_INCREMENT,
learning_type VARCHAR(50) NOT NULL,
target_type VARCHAR(50) NOT NULL,
target_id INT NOT NULL,
old_value TEXT,
new_value TEXT,
reason TEXT,
evidence TEXT,
verification_status VARCHAR(30),
created_at DATETIME NOT NULL,
PRIMARY KEY (id)
);
学习证据可以独立保存:
CREATE TABLE learning_evidence (
id INT NOT NULL AUTO_INCREMENT,
learning_id INT NOT NULL,
source_type VARCHAR(50) NOT NULL,
source_id INT NOT NULL,
evidence_type VARCHAR(50),
evidence_value TEXT,
verified TINYINT(1) NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL,
PRIMARY KEY (id)
);
学习历史:
CREATE TABLE learning_history (
id INT NOT NULL AUTO_INCREMENT,
learning_id INT NOT NULL,
target_type VARCHAR(50) NOT NULL,
target_id INT NOT NULL,
action VARCHAR(50) NOT NULL,
before_value TEXT,
after_value TEXT,
reason TEXT,
created_at DATETIME NOT NULL,
PRIMARY KEY (id)
);
184.24 学习更新的安全机制
LearningService不能允许任意数据直接修改核心认知对象。
必须建立:
Evidence
→ Validation
→ Verification
→ Update Permission
→ Update
→ History
而不能:
Input
→ Direct Update
因此可以定义:
CanLearn=Evidence∧Valid∧Verified∧ApplicableCanLearn = Evidence \land Valid \land Verified \land Applicable
只有:
CanLearn = TRUE
才允许进入正式学习更新。
184.25 学习更新的最小原则
ICAI学习必须遵守最小修改原则。
即:
如果新事实只证明一个字段发生变化,就不要修改整个对象。
例如:
Capability:
Type = Search
Range = 100
State = Available
新验证只证明:
Range = 80
那么更新应该是:
Range: 100 → 80
而不是:
Capability全部重建
同样:
Method
Process
Action
Condition
只有被证据证明需要变化的部分才进行更新。
这可以减少认知系统中的无效变化。
184.26 学习更新与版本
对于核心知识、能力和方法,应保留版本或历史。
例如:
Method A v1
↓
Learning
↓
Method A v2
历史记录:
v1
Condition = C1
v2
Condition = C1 ∧ C2
这样系统可以追溯:
Current Method
← Previous Method
← Learning Record
← Evidence
← Execution
因此学习不是覆盖历史,而是:
在历史基础上形成新的有效状态。
184.27 学习与经验的区别
Experience和Learning也不能混淆。
Experience表示:
从过去事件中形成的结构化模式。
Learning表示:
根据经过验证的信息,改变系统未来认知依据的过程。
因此:
History
→ Memory
→ Experience
→ Learning
→ Knowledge / Capability / Method Update
例如:
历史:
方法A执行10次
经验:
条件C1下,方法A通常可以完成任务
学习:
将方法A的适用条件增加C1
所以:
Experience是学习的重要输入,Learning是认知更新过程。
184.28 学习与统计的关系
ICAI可以使用统计数据,但统计不是学习本身。
例如:
Method A
执行次数 = 20
成功次数 = 17
失败次数 = 3
可以计算:
SuccessRate=1720=0.85SuccessRate=\frac{17}{20}=0.85
这个结果可以作为方法评价依据。
但是:
SuccessRate = 0.85
并不自动意味着:
Method = Best
它只是学习计算中的一个证据。
最终仍然需要结合:
Condition
Capability
Resource
Result
Verification
Risk
History
进行确定性判断。
184.29 一个完整学习案例
假设系统需要完成任务:
Goal A
当前存在:
Method A
Method B
系统通过DecisionService选择:
Method A
执行过程:
Method A
→ Action A1
→ Action A2
→ Action A3
→ Result
结果:
Partial Success
Feedback记录:
Expected = Complete
Actual = Partial
随后DiagnosisService发现:
Action A2
在当前对象状态下执行效果不足。
经过Repair:
A2
→ A4
再次执行:
A1
→ A4
→ A3
→ Complete
Verification:
Passed
LearningService得到:
Evidence = Verified
于是产生:
Method A v1
A1 → A2 → A3
更新为候选:
Method A v2
A1 → A4 → A3
同时可能更新:
Knowledge
记录:
Condition C下,A4比A2更适合当前对象状态
并更新:
Capability
记录实际验证能力范围。
最终:
Knowledge Update
+
Capability Update
+
Method Update
下一次DecisionService再次面对相同条件时,就不再使用旧的认知状态。
184.30 LearningService的完整架构
最终可以建立:
LearningService
│
┌────────────┼────────────┐
↓ ↓ ↓
KnowledgeUpdate CapabilityUpdate MethodUpdate
│ │ │
↓ ↓ ↓
KnowledgeService CapabilityService MethodService
│ │ │
└────────────┼────────────┘
↓
Repository
↓
MySQL
其输入:
Result
Feedback
History
Memory
Experience
Verification
Diagnosis
Repair
其输出:
Knowledge Update
Capability Update
Method Update
Learning History
184.31 LearningService在ICAI中的完整位置
到本章为止,ICAI已经形成:
Need
→ Goal
→ Capability
→ Method
→ Decision
→ Behavior
→ Action
→ Execution
→ Result
→ Feedback
→ History
→ Memory
→ Experience
→ Risk / Conflict
→ Diagnosis
→ Repair
→ Verification
→ Learning
→ Knowledge Update
→ Capability Update
→ Method Update
→ Decision
因此整个系统已经形成真正的闭环:
CognitiveCycle=Perception→Decision→Execution→Feedback→Learning→Update→DecisionCognitiveCycle = Perception \rightarrow Decision \rightarrow Execution \rightarrow Feedback \rightarrow Learning \rightarrow Update \rightarrow Decision
其中LearningService承担的是:
把已经发生的运行事实转换为未来可使用的认知变化。
184.32 本章小结
LearningService是ICAI持续认知能力中的核心应用服务。
它不是大模型训练系统,也不是神经网络学习系统,而是建立在:
事实
+
反馈
+
历史
+
记忆
+
经验
+
验证
+
规则
+
离散计算
基础上的确定性认知更新机制。
其核心模型为:
LS=(L,K,C,M)LS=(L,K,C,M)
即:
L:学习;K:知识更新;C:能力更新;M:方法更新。
完整过程为:
真实执行
→ 结果
→ 反馈
→ 历史
→ 记忆
→ 经验
→ 验证
→ 学习
→ 知识更新
→ 能力更新
→ 方法更新
→ 新决策
→ 新行为
→ 新执行
由此,ICAI不再只是一个保存知识和执行规则的系统,而形成了一个能够根据自身实际运行结果不断修正认知依据的离散认知闭环。
最终可以将第184章的核心思想概括为:
Learning=Verified Experience→Cognitive UpdateLearning = Verified\ Experience \rightarrow Cognitive\ Update
即:
学习不是产生一个新的模型,而是让已经验证的经验改变系统未来的知识、能力和方法。
这也是ICAI区别于静态规则系统的关键所在。