Skip to content

自进化 AI 系统

Phase 100 | v5.0.0 | 状态: ✅ 生产就绪 | 8 IPC Handlers | 3 数据库表

ChainlessChain 自进化 AI 系统实现了 AI 模型的自主进化能力,包括自动架构搜索(NAS for Edge)、持续学习(无灾难性遗忘)、自诊断与自修复、行为预测与主动服务、能力自评估与自动升级,并通过进化成长日志可视化追踪 AI 的演进轨迹。

核心特性

  • 🧠 自动架构搜索(NAS for Edge): 针对边缘设备自动搜索最优模型架构,平衡精度与推理速度,支持 ONNX/TFLite 导出
  • 📚 持续学习(无灾难性遗忘): 基于 EWC(弹性权重巩固)+ 知识蒸馏的增量学习方案,新知识不覆盖旧知识
  • 🔧 自诊断与自修复: 自动检测模型退化(精度下降/延迟升高/异常输出),触发自修复流程(重训练/回滚/降级)
  • 🔮 行为预测与主动服务: 基于用户行为序列预测下一步操作,提前准备资源、预加载数据、主动推荐
  • 📊 能力自评估与自动升级: 定期评估模型在各维度的能力得分,低于阈值时自动触发升级流程
  • 📈 进化成长日志: 完整记录 AI 每次进化的触发原因、变更内容、效果对比,支持时间线可视化

系统架构

┌─────────────────────────────────────────────────┐
│           SelfEvolvingAIManager                 │
│    (调度 / 配置 / 进化成长日志 / 模型导出)       │
└───┬──────┬──────┬──────┬──────┬────────────────┘
    │      │      │      │      │
    ▼      ▼      ▼      ▼      ▼
┌──────┐┌──────┐┌──────┐┌──────┐┌──────────┐
│ NAS  ││持续  ││自诊断││行为  ││ 能力     │
│ 架构 ││学习  ││自修复││预测  ││ 评估     │
│ 搜索 ││(EWC) ││引擎  ││引擎  ││ + 升级   │
└──┬───┘└──┬───┘└──┬───┘└──┬───┘└────┬─────┘
   │       │       │       │         │
   ▼       ▼       ▼       ▼         ▼
┌─────────────────────────────────────────────────┐
│  SQLite 持久化 (assessments / training_logs /    │
│  growth_log) + ONNX/TFLite 模型导出              │
└─────────────────────────────────────────────────┘

关键文件

文件职责
src/main/ai-engine/evolution/self-evolving-manager.js自进化核心管理器
src/main/ai-engine/evolution/capability-assessor.js多维度能力评估
src/main/ai-engine/evolution/continual-learner.jsEWC/蒸馏增量学习
src/main/ai-engine/evolution/self-diagnosis.js自诊断与自修复引擎
src/main/ai-engine/evolution/behavior-predictor.js用户行为预测与主动服务
src/main/ai-engine/evolution/evolution-ipc.jsIPC 处理器(8 个)
src/renderer/pages/ai/EvolutionDashboardPage.vue进化成长日志可视化页面
src/renderer/stores/evolution.tsPinia 状态管理

能力评估流程

定时评估任务


┌──────────────┐    评分 ≥ 阈值    ┌──────────┐
│  能力评估    │ ─────────────────▶ │  记录日志 │
│  (多维度)    │                    └──────────┘
└──────┬───────┘
       │ 评分 < 阈值

┌──────────────┐    成功    ┌──────────────┐
│  自动升级    │ ─────────▶ │  A/B 验证    │
│  (增量训练)  │            │  + 灰度发布  │
└──────┬───────┘            └──────┬───────┘
       │ 失败                      │ 通过
       ▼                           ▼
┌──────────────┐            ┌──────────────┐
│  自诊断      │            │  正式发布    │
│  + 自修复    │            │  + 记录进化  │
└──────────────┘            └──────────────┘

能力评估

javascript
// 评估 AI 当前各维度能力
const assessment = await window.electron.ipcRenderer.invoke(
  "evolution:assess-capability",
  {
    dimensions: [
      "reasoning",
      "coding",
      "writing",
      "translation",
      "summarization",
      "qa",
    ],
    benchmarkSuite: "standard-v2",
    sampleSize: 100,
  },
);
// assessment = {
//   modelId: "chainless-ai-v4.5",
//   timestamp: 1710000000,
//   overall: 0.87,
//   dimensions: [
//     { name: "reasoning", score: 0.91, threshold: 0.85, status: "pass", trend: "+0.03" },
//     { name: "coding", score: 0.89, threshold: 0.85, status: "pass", trend: "+0.05" },
//     { name: "writing", score: 0.85, threshold: 0.85, status: "borderline", trend: "-0.01" },
//     { name: "translation", score: 0.82, threshold: 0.85, status: "below", trend: "-0.04" },
//     { name: "summarization", score: 0.93, threshold: 0.85, status: "pass", trend: "+0.02" },
//     { name: "qa", score: 0.84, threshold: 0.85, status: "borderline", trend: "0.00" },
//   ],
//   recommendations: [
//     { dimension: "translation", action: "incremental-training", priority: "high" },
//     { dimension: "qa", action: "data-augmentation", priority: "medium" },
//   ]
// }

增量训练

javascript
// 触发无灾难性遗忘的增量训练
const training = await window.electron.ipcRenderer.invoke(
  "evolution:train-incremental",
  {
    targetDimensions: ["translation", "qa"],
    strategy: "ewc", // "ewc" (弹性权重巩固) | "distillation" (知识蒸馏) | "replay" (经验回放)
    dataSource: {
      type: "curated", // "curated" | "user-feedback" | "synthetic"
      samples: 5000,
    },
    constraints: {
      maxDegradation: 0.02, // 其他维度最大允许退化 2%
      maxDuration: 3600000, // 最大训练时长 1h
      deviceTarget: "edge", // "edge" | "cloud" | "hybrid"
    },
  },
);
// training = {
//   trainingId: "train-001",
//   status: "completed",
//   duration: 2400000,
//   results: {
//     translation: { before: 0.82, after: 0.88, improvement: "+0.06" },
//     qa: { before: 0.84, after: 0.87, improvement: "+0.03" },
//     reasoning: { before: 0.91, after: 0.90, degradation: "-0.01", withinLimit: true },
//   },
//   modelVersion: "chainless-ai-v4.5.1",
//   exportFormats: ["onnx", "tflite"]
// }

自诊断

javascript
// AI 系统自诊断
const diagnosis = await window.electron.ipcRenderer.invoke(
  "evolution:self-diagnose",
  {
    checks: [
      "accuracy",
      "latency",
      "memory",
      "output-quality",
      "hallucination-rate",
    ],
  },
);
// diagnosis = {
//   status: "degraded",
//   issues: [
//     {
//       check: "latency",
//       status: "warning",
//       current: 1200,
//       baseline: 800,
//       message: "推理延迟较基线升高 50%",
//       suggestedFix: "quantize-model",
//     },
//     {
//       check: "hallucination-rate",
//       status: "critical",
//       current: 0.08,
//       baseline: 0.03,
//       message: "幻觉率异常升高",
//       suggestedFix: "rollback-to-stable",
//     },
//   ],
//   healthy: ["accuracy", "memory", "output-quality"]
// }

自修复

javascript
// 根据诊断结果执行自修复
const repair = await window.electron.ipcRenderer.invoke(
  "evolution:self-repair",
  {
    issues: ["latency", "hallucination-rate"],
    strategy: "auto", // "auto" | "rollback" | "retrain" | "quantize" | "degrade-gracefully"
    dryRun: false,
  },
);
// repair = {
//   repairId: "repair-001",
//   actions: [
//     { issue: "latency", action: "quantize-model", status: "completed", result: "延迟从 1200ms 降至 650ms" },
//     { issue: "hallucination-rate", action: "rollback-to-stable", status: "completed", result: "回滚至 v4.5.0,幻觉率恢复至 0.03" },
//   ],
//   newModelVersion: "chainless-ai-v4.5.0-patched",
//   verificationPassed: true
// }

行为预测

javascript
// 预测用户下一步行为并主动准备
const prediction = await window.electron.ipcRenderer.invoke(
  "evolution:predict-behavior",
  {
    userId: "user-001",
    contextWindow: 20, // 最近 20 个行为作为上下文
    predictionHorizon: 3, // 预测未来 3 步
  },
);
// prediction = {
//   userId: "user-001",
//   predictions: [
//     { action: "open-knowledge-base", confidence: 0.92, preload: ["kb-index", "recent-notes"] },
//     { action: "search-notes", confidence: 0.78, preload: ["search-index"] },
//     { action: "ask-ai-question", confidence: 0.65, preload: ["llm-session", "rag-context"] },
//   ],
//   proactiveActions: [
//     { type: "preload-data", target: "kb-index", estimatedSavings: "800ms" },
//     { type: "warm-cache", target: "llm-session", estimatedSavings: "1200ms" },
//   ]
// }

进化成长日志

javascript
// 查看 AI 进化历史
const growthLog = await window.electron.ipcRenderer.invoke(
  "evolution:get-growth-log",
  {
    fromDate: "2026-01-01",
    toDate: "2026-03-10",
    includeMetrics: true,
  },
);
// growthLog = {
//   entries: [
//     {
//       id: "evo-001",
//       date: "2026-01-15",
//       type: "incremental-training",
//       trigger: "capability-assessment",
//       description: "翻译能力低于阈值,触发 EWC 增量训练",
//       before: { translation: 0.78, overall: 0.84 },
//       after: { translation: 0.86, overall: 0.87 },
//       duration: 2400000,
//     },
//     {
//       id: "evo-002",
//       date: "2026-02-03",
//       type: "self-repair",
//       trigger: "self-diagnosis",
//       description: "检测到幻觉率升高,自动回滚至稳定版本",
//       before: { hallucinationRate: 0.08 },
//       after: { hallucinationRate: 0.03 },
//       duration: 30000,
//     },
//     {
//       id: "evo-003",
//       date: "2026-03-01",
//       type: "architecture-search",
//       trigger: "scheduled",
//       description: "NAS 搜索到更优的 Edge 架构,推理速度提升 25%",
//       before: { latencyMs: 800, modelSizeMB: 450 },
//       after: { latencyMs: 600, modelSizeMB: 380 },
//       duration: 7200000,
//     },
//   ],
//   summary: {
//     totalEvolutions: 12,
//     overallImprovement: "+15.2%",
//     topImprovedDimension: "coding (+12%)",
//     evolutionFrequency: "4.0/month"
//   }
// }

进化配置

javascript
const config = await window.electron.ipcRenderer.invoke("evolution:configure", {
  autoAssessment: { enabled: true, interval: 604800000 }, // 每周评估
  autoUpgrade: { enabled: true, minScoreThreshold: 0.85 },
  selfDiagnosis: { enabled: true, interval: 86400000 }, // 每天诊断
  selfRepair: { autoRepair: true, requireApproval: false },
  behaviorPrediction: { enabled: true, contextWindow: 20 },
});

模型导出

javascript
// 导出进化后的模型
const exported = await window.electron.ipcRenderer.invoke(
  "evolution:export-model",
  {
    modelVersion: "chainless-ai-v4.5.1",
    format: "onnx", // "onnx" | "tflite" | "coreml" | "openvino"
    quantization: "int8", // "fp32" | "fp16" | "int8" | "int4"
    targetDevice: "edge", // "edge" | "mobile" | "server"
  },
);
// exported = { modelVersion: "chainless-ai-v4.5.1", format: "onnx", quantization: "int8", sizeMB: 125, path: "/models/chainless-ai-v4.5.1-int8.onnx", accuracy: 0.86 }

成长可视化

进化成长日志支持以下可视化模式:

可视化模式说明
时间线视图按时间轴展示每次进化事件,支持钻取详情
雷达图多维度能力得分雷达图,对比不同版本
趋势折线图各维度能力得分随时间的变化趋势
热力图进化频率与维度关联热力图,识别薄弱环节
对比瀑布图单次进化前后各指标变化的瀑布图

IPC 通道

通道参数返回值
evolution:assess-capability{ dimensions?, benchmarkSuite?, sampleSize? }评估结果
evolution:train-incremental{ targetDimensions, strategy, dataSource, ... }训练结果
evolution:self-diagnose{ checks? }诊断报告
evolution:self-repair{ issues, strategy?, dryRun? }修复结果
evolution:predict-behavior{ userId, contextWindow?, predictionHorizon? }行为预测
evolution:get-growth-log{ fromDate?, toDate?, includeMetrics? }进化日志
evolution:configure{ autoAssessment?, autoUpgrade?, ... }配置结果
evolution:export-model{ modelVersion, format, quantization?, ... }导出结果

数据库表

evolution_assessments

字段类型说明
idTEXT PK评估 ID
model_idTEXT模型标识
overall_scoreREAL综合得分
dimensionsJSON各维度评分详情
recommendationsJSON升级建议
benchmark_suiteTEXT使用的评测集
created_atINTEGER评估时间戳

evolution_training_logs

字段类型说明
idTEXT PK训练 ID
typeTEXTincremental/nas/repair
triggerTEXT触发原因
strategyTEXTewc/distillation/replay
before_metricsJSON训练前指标
after_metricsJSON训练后指标
model_version_inTEXT输入模型版本
model_version_outTEXT输出模型版本
durationINTEGER训练时长(ms)
statusTEXTcompleted/failed/cancelled
created_atINTEGER创建时间戳

evolution_growth_log

字段类型说明
idTEXT PK日志 ID
typeTEXT进化类型
triggerTEXT触发来源
descriptionTEXT变更描述
before_stateJSON进化前状态
after_stateJSON进化后状态
durationINTEGER耗时(ms)
verifiedINTEGER是否已验证(0/1)
created_atINTEGER创建时间戳

配置

.chainlesschain/config.json 中配置:

json
{
  "selfEvolvingAI": {
    "enabled": true,
    "autoAssessment": {
      "enabled": true,
      "interval": 604800000,
      "dimensions": [
        "reasoning",
        "coding",
        "writing",
        "translation",
        "summarization",
        "qa"
      ],
      "minScoreThreshold": 0.85
    },
    "continualLearning": {
      "strategy": "ewc",
      "maxDegradation": 0.02,
      "maxTrainingDuration": 3600000,
      "dataSourcePriority": ["user-feedback", "curated", "synthetic"]
    },
    "selfDiagnosis": {
      "enabled": true,
      "interval": 86400000,
      "checks": [
        "accuracy",
        "latency",
        "memory",
        "output-quality",
        "hallucination-rate"
      ]
    },
    "selfRepair": {
      "enabled": true,
      "autoRepair": true,
      "requireApproval": false,
      "strategies": ["quantize", "rollback", "retrain", "degrade-gracefully"]
    },
    "behaviorPrediction": {
      "enabled": true,
      "contextWindow": 20,
      "predictionHorizon": 3,
      "minConfidence": 0.6
    },
    "nas": {
      "enabled": false,
      "targetDevice": "edge",
      "searchBudgetHours": 4,
      "exportFormats": ["onnx", "tflite"]
    }
  }
}

相关文档

基于 MIT 许可发布