You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A set of facilities based on LLM, which can efficiently boost the speed and accuracy of LLM in long context, making it more like a person.
This branch is the v7.0 "Arthur" upgrade of the Phoenix system, focused on true multimodal fusion, primal-sensation/instinct/emotion integration, and comprehensive test coverage.
Features
Core AI Engine
MemeGraph (GNN) — associative memory graph storing learned concepts ("memes") as nodes with weighted edges; supports incremental learning, decay, n-gram indexing, and graph export
SparkArray ensemble — multi-AI voting layer dispatching queries across a controller pool; supports PersonaForestAverager and pluggable factory modules; bigRounds for iterative consensus
Dual-track context — independent GNN graph-context and semantic context system that feed into the Transformer together; GNN keywords harmonize with context hints via Jaccard alignment scoring
Attention-sink context window — configurable maxTokens, importanceThreshold, similarityThreshold, semanticChunkSize, and attention-sink tokens via config/phoenix_tuned.json
True-multimodal semantic units — SemanticUnit/SemanticMemory in semantic_unit.{hpp,cpp} with modality-aware fusion, projection, and cosine-similarity search; integrated into ModernContextManager, ContextBuilder, and MemeGraph for v7.0
Primal sensation / instinct layer — biological interoceptive signals (primal_sensation.{hpp,cpp}) and innate drives (instinct.{hpp,cpp}) with benefit-harm (趋利避害) evaluation wired into CognitionAutonomyManager
Prompt split — immutable SystemPrompt and dynamic MemoryPrompt composed by PromptComposer (prompt_split.{hpp,cpp}); memory portion is regenerated from context and affect signals each turn
External mixed-modal I/O — MixedModalPacket, MixedModalInputBuffer, MixedModalOutputQueue, and MixedModalChannelRegistry (external_mixed_modal_io.{hpp,cpp}) translate external text/image/audio/video/sensor payloads into SemanticUnit objects
Emotion system — pluggable emotion processing layer (emotion_system.cpp) integrated into the response pipeline
World model — scene-level world representation (world_model.hpp) for environment-aware reasoning
Vision / multimodal input — /api/chat and /api/transformer/chat accept imageContext, imageEmbedding, imageEmbeddings, and vision payloads; embedding chunks are injected into graph context
Inference Backends
Ollama — standard and fine-tuning adapter modes (ollama, ollama-fine-tuning)
llama.cpp / llama-server — GGUF model server with LoRA adapter support (llamacpp-lora-files, llamacpp-lora-init-without-apply)
BitNet — 1-bit quantized GGUF inference adapter
Native built-in Transformer — self-contained transformer with checkpoint save/load, pre-training, joint GNN+Transformer training, and GA optimization
Auto-selection — if only one .gguf is in GGUF_models/ the backend picks it automatically; multiple candidates require explicit --llamacpp-model
Online Learning
Reinforcement Learner (RL) — learns from dialog outcomes; triggered every N dialogs (configurable rlEvery) or on-demand via /api/learn/reinforce
Adversarial Learner (ADV) — attack-and-defend training on corpus samples; configurable advEvery
External style adapter — fine-tuning from dialog style via /api/external_style/train_step and /api/fine_tuning/run; bridges learning results to external backends
Transformer feedback loop — user feedback collected at /api/transformer/feedback, triggers background training at /api/transformer/feedback/train
Dialog-triggered auto-learning — after each completed dialog, RL / ADV / GNN-GA fire automatically based on turn counters; counters reset via /api/learn/dialog/reset
Safety & Monitoring
MemeBarrier — background thread scanning the meme graph for anomalous growth patterns; TextCNN + RNN/LSTM Torch models score and isolate malicious nodes; threshold, scan interval, and all model hyperparameters are runtime-configurable via config/phoenix_tuned.json
Bug Shooter — subprocess (bug_shooter.exe) monitoring process memory; soft and hard RSS limits with configurable thresholds
Optimizer Autonomy — self-monitoring autonomy agent that proposes GNN and Transformer upgrades (/api/optimizer/autonomy/iterate, /api/gnn/upgrade, /api/transformer/upgrade)
Route metrics — every API route records latency and success/failure counters; queryable at /api/monitoring/stats; training jobs tracked at /api/monitoring/training
Data Pipeline
Robots corpus — text files in robots/ loaded at startup as the base knowledge corpus; configurable chunk size, warmup limit, shuffle, and autoload
LMDB store — persistent key-value layer with configurable map size; used by MemeGraph and KVMStore for persistent meme and relationship storage
SQLite store — ai_store.sqlite for structured entity and session data
Redis — session caching, inter-process pub/sub (AI-model-workspace channel), and hot matrix cache (configurable DB index and key prefix)
Corpus ingest API — /api/corpus/ingest (single doc), /api/robots/retrain (batch with offset/limit), /api/corpus/online (web research), /api/corpus/crawl (recursive crawl + optional ingest)
Study Engine — asynchronous document queue (/api/study/enqueue) for background learning on ingested content
Dataset catalog — register, activate, and govern external datasets; data cleaning profiles via /api/data/*
Graph export — export active or per-group meme graphs to JSON files via /api/export/graph
Service Architecture
Drogon HTTP gateway (port 5080) — async C++20 HTTP/1.1 server; thread count auto-detected from CPU cores (4–16), overridable via AI_HTTP_THREADS
Controller pool — multiple AI controller instances arranged in named groups; supports single-proc, group-proc, and infer-MP execution modes
Shard manager — query sharding across controller groups for horizontal scaling
Redis synchronizer — cross-process state synchronization and rotation management
Snapshot manager — periodic snapshots of runtime state to snapshots/ for crash recovery
JWT + local-token auth — all /api/* routes require Authorization: Bearer <token>; local tokens (local-{user}-{ts}-{seq}) or JWT; configurable via env AI_AUTH_JWT_SECRET
Developer Tooling
Auto-tuning pipeline — tools/auto_tune_phoenix_params.py runs grid/random search over context window, MemeBarrier, scenario thresholds, and llama-server knobs; writes config/phoenix_tuned.json
Runtime tuned config — runtime_tuned_config.hpp provides phoenix::tuned::value(dotPath, fallback) for zero-rebuild JSON overrides at startup
Memory tier benchmark — tools/run_memory_tier_benchmark_tui.py with TUI progress display; scenario turn thresholds loaded from tools/tuned_scenario_thresholds.py
Module override system — module_overrides/ lets external code replace SparkArray, PersonaForestAverager, and other factory-registered components at link time
Split main — tools/split_main_cpp.py splits main.cpp into main_hub_parts/*.inc segments for parallel compilation and diff readability
Model Deployment Topology (v7.0)
Phoenix can place the three heavy model roles on the local host or on separate
edge devices at startup. Each role is configured independently:
llm — text generation backend (Ollama / llama.cpp server / BitNet).
vision — image encoder / JPEA world model.
speech — audio / 1D JPEA world model.
Configuration comes from command-line arguments, environment variables, or a
JSON file; later sources override earlier ones. Examples:
# 1) Host runs everything (default)
phoenix_main.exe
# 2) Edge LLM on another machine, local vision/speech
phoenix_main.exe \
--llm-placement remote \
--llm-remote-url http://192.168.1.10:11434 \
--llm-remote-method ollama \
--llm-remote-model llama3.1:8b
# 3) Three models on three devices via JSON config
phoenix_main.exe --model-deployment-config config/model_deployment.json
See doc/v7.0/model_deployment.md and config/model_deployment.example.json
for the full argument list, environment variables, and the HTTP/JSON protocol
used by remote vision and speech endpoints.
Helper tools:
# Generate a deployment JSON from the command line
python tools/generate_model_deployment_config.py \
--llm remote --llm-url http://192.168.1.10:11434 --llm-method ollama --llm-model llama3.1:8b \
--vision remote --vision-url http://192.168.1.11:5000/infer \
--speech remote --speech-url http://192.168.1.12:5001/infer \
-o config/model_deployment.json
# Example edge inference server for vision/speech (run on the edge devices)
python tools/model_deployment_edge_example.py --port 5000
Quick Start
Prerequisites
Dependency
Notes
C++20 compiler (g++ / clang++ via MSYS2)
Required
CMake + Ninja
Required
Conan 2.x
C++ dependency management
Redis
Default redis://127.0.0.1:6379
Ollama (optional)
Default http://127.0.0.1:11434
Python 3.10+
Prototype layer and tooling
Python314/ directory
Must contain Python.h, python314.lib, python314.dll
Build
# 1. Install C++ dependencies via Conan
conan install .--build=missing
# 2. Build all binariescompile.bat# Optional: build without edge image/speech (RDK X5 BPU / remote endpoints)# $env:PHOENIX_DISABLE_EDGE_IMAGE = "1"# $env:PHOENIX_DISABLE_EDGE_SPEECH = "1"# compile.bat# Artifacts produced:# phoenix_main.exe — main gateway + AI runtime# bug_shooter.exe — memory monitor subprocess# phoenix_sql_cli.exe — SQL CLI
Download a model
# Place .gguf models in GGUF_models/ (auto-detected if only one present)
ollama pull llama3.1:8b
# or download directly and place the .gguf file in GGUF_models/
The ResNet18-based BPU JEPA encoder (runtime_store/models/bpu_jepa/resnet18_224)
stores the 1x1 concept head in a separate CPU-side ONNX file. To train it on the
frozen ImageNet-pretrained encoder with a VICReg-style loss:
This overwrites model_encoder_head.onnx and updates model.manifest.json.
Use --variance-target to make the concept values larger (default 2.0).
Deployment Matrix Generator
The 649-endpoint deployment space can be generated interactively:
python tools/generate_model_deployment_matrix.py
# source the generated env before compiling when edge devices should be disabledcompile_env_model_deployment.batcompile.bat