Update documentation and technical references for Mindnet v3.0.0: Revise glossary, AI personality concepts, chat backend, configuration, ingestion pipeline, and admin operations to reflect the integration of Mixture of Experts (MoE) architecture and associated features. Enhance clarity on profile-driven orchestration, fallback mechanisms, and pre-synthesis compression across components.
This commit is contained in:
1 parent
9b906bbabf
commit
ac26cc4940
10 files changed
+535
-41
No files matched your search
@@ -1,10 +1,10 @@
|
||||
---
|
||||
doc_type: technical_reference
|
||||
audience: developer, architect
|
||||
scope: backend, chat, llm_service, traffic_control, resilience, agentic_rag
|
||||
scope: backend, chat, llm_service, traffic_control, resilience, agentic_rag, moe
|
||||
status: active
|
||||
version: 2.9.3
|
||||
context: "Technische Implementierung des FastAPI-Routers, des hybriden LLMService (v3.4.2), WP-25 Agentic Multi-Stream RAG und WP-20 Resilienz-Logik."
|
||||
version: 3.0.0
|
||||
context: "Technische Implementierung des FastAPI-Routers, des hybriden LLMService (v3.5.2), WP-25 Agentic Multi-Stream RAG, WP-25a Mixture of Experts (MoE) und WP-20 Resilienz-Logik."
|
||||
---
|
||||
|
||||
# Chat Backend & Agentic Multi-Stream RAG
|
||||
@@ -28,7 +28,31 @@ Der Router nutzt einen **Hybrid-Modus** mit Keyword-Fast-Path und LLM-Slow-Path:
|
||||
* Wenn unklar: Anfrage an `DecisionEngine._determine_strategy()` zur LLM-basierten Klassifizierung.
|
||||
* Nutzt `intent_router_v1` Prompt aus `prompts.yaml`.
|
||||
|
||||
### 1.2 Prompt-Auflösung (Bulletproof Resolution)
|
||||
### 1.2 Mixture of Experts (MoE) Architektur (WP-25a)
|
||||
|
||||
Seit WP-25a nutzt MindNet eine **profilbasierte Experten-Steuerung** statt einer globalen Provider-Konfiguration. Jede Systemaufgabe wird einem dedizierten Profil zugewiesen:
|
||||
|
||||
**Profil-Registry (`llm_profiles.yaml`):**
|
||||
* **`synthesis_pro`:** Hochwertige Synthese für Chat-Antworten
|
||||
* **`tech_expert`:** Fachspezialist für Code & Technik
|
||||
* **`compression_fast`:** Schnelle Kompression & Routing
|
||||
* **`ingest_validator`:** Deterministische Validierung (Temperature 0.0)
|
||||
* **`identity_safe`:** Lokaler Anker (Ollama/Phi-3) für maximale Privacy
|
||||
|
||||
**Rekursive Fallback-Kaskade:**
|
||||
Der `LLMService` (v3.5.2) implementiert eine automatische Fallback-Logik:
|
||||
1. Versucht primäres Profil (z.B. `synthesis_pro`)
|
||||
2. Bei Fehler → `fallback_profile` (z.B. `synthesis_backup`)
|
||||
3. Bei weiterem Fehler → nächster Fallback (z.B. `identity_safe`)
|
||||
4. Schutz gegen Zirkel-Referenzen via `visited_profiles`-Tracking
|
||||
|
||||
**Integration:**
|
||||
* **Intent-Routing:** Nutzt `router_profile` (z.B. `compression_fast`)
|
||||
* **Stream-Kompression:** Nutzt `compression_profile` pro Stream
|
||||
* **Synthese:** Nutzt `llm_profile` aus Strategie-Konfiguration
|
||||
* **Ingestion:** Nutzt `ingest_validator` für binäre Validierungen
|
||||
|
||||
### 1.3 Prompt-Auflösung (Bulletproof Resolution)
|
||||
|
||||
Um Kompatibilitätsprobleme mit verschachtelten YAML-Prompts zu vermeiden, nutzt der Router die Methode `llm.get_prompt()`. Diese implementiert eine **Provider-Kaskade**:
|
||||
* **Spezifischer Provider:** Das System sucht zuerst nach einem Prompt für den aktiv konfigurierten Provider (z.B. `openrouter`).
|
||||
@@ -36,7 +60,7 @@ Um Kompatibilitätsprobleme mit verschachtelten YAML-Prompts zu vermeiden, nutzt
|
||||
* **Basis-Fallback:** Als letzte Instanz wird das `ollama`-Template geladen.
|
||||
* **String-Garantie:** Die Methode garantiert die Rückgabe eines Strings (selbst bei verschachtelten YAML-Dicts), was 500-Fehler bei String-Operationen wie `.replace()` oder `.format()` verhindert.
|
||||
|
||||
### 1.2 Multi-Stream Retrieval (WP-25)
|
||||
### 1.4 Multi-Stream Retrieval (WP-25)
|
||||
|
||||
Anstelle einer einzelnen Suche führt die `DecisionEngine` nun **parallele Abfragen** in spezialisierten Streams aus:
|
||||
|
||||
@@ -57,7 +81,22 @@ Anstelle einer einzelnen Suche führt die `DecisionEngine` nun **parallele Abfra
|
||||
* **Stream-Tracing:** Jeder Treffer wird mit `stream_origin` markiert für Feedback-Optimierung.
|
||||
* **Fehlerbehandlung:** Einzelne Stream-Fehler blockieren nicht die gesamte Anfrage.
|
||||
|
||||
### 1.3 Wissens-Synthese (WP-25)
|
||||
### 1.5 Pre-Synthesis Kompression (WP-25a)
|
||||
|
||||
Wissens-Streams, die den Schwellenwert (`compression_threshold`) überschreiten, werden **asynchron verdichtet**, bevor sie die Synthese erreichen:
|
||||
|
||||
**Kompression-Logik:**
|
||||
* **Schwellenwert:** Konfigurierbar pro Stream (z.B. 2500 Zeichen für Values Stream)
|
||||
* **Profil:** Nutzt `compression_profile` (z.B. `compression_fast` für schnelle Zusammenfassung)
|
||||
* **Parallelisierung:** Mehrere Streams können gleichzeitig komprimiert werden
|
||||
* **Fehlerbehandlung:** Kompressions-Fehler blockieren nicht die Synthese (Original-Content wird verwendet)
|
||||
|
||||
**Vorteile:**
|
||||
* Reduziert Token-Verbrauch bei langen Streams
|
||||
* Beschleunigt Synthese durch kürzere Kontexte
|
||||
* Erhält Relevanz durch intelligente Zusammenfassung
|
||||
|
||||
### 1.6 Wissens-Synthese (WP-25/25a)
|
||||
|
||||
Die Zusammenführung der Daten erfolgt über spezialisierte Templates in der `prompts.yaml`:
|
||||
|
||||
@@ -66,20 +105,29 @@ Die Zusammenführung der Daten erfolgt über spezialisierte Templates in der `pr
|
||||
* **Pre-Initialization:** Alle möglichen Stream-Variablen werden vorab initialisiert (verhindert KeyErrors).
|
||||
* **Provider-spezifische Templates:** Separate Versionen für Ollama, Gemini und OpenRouter.
|
||||
|
||||
**Synthese-Strategien:**
|
||||
* **FACT_WHAT/FACT_WHEN:** Kombiniert Fakten, Biographie und Technik.
|
||||
* **DECISION:** Wägt Fakten gegen Werte ab, evaluiert Risiken.
|
||||
* **EMPATHY:** Fokus auf Biographie und Werte.
|
||||
* **CODING:** Technik und Fakten.
|
||||
**Synthese-Strategien (Profil-gesteuert):**
|
||||
* **FACT_WHAT/FACT_WHEN:** Nutzt `synthesis_pro` - Kombiniert Fakten, Biographie und Technik.
|
||||
* **DECISION:** Nutzt `synthesis_pro` - Wägt Fakten gegen Werte ab, evaluiert Risiken.
|
||||
* **EMPATHY:** Nutzt `synthesis_pro` - Fokus auf Biographie und Werte.
|
||||
* **CODING:** Nutzt `tech_expert` - Spezialisiertes Modell für Code & Technik.
|
||||
|
||||
### 1.4 RAG Flow (Technisch)
|
||||
**Profil-Auflösung:**
|
||||
Jede Strategie kann ein individuelles `llm_profile` definieren. Fehlt diese Angabe, wird `synthesis_pro` als Standard verwendet.
|
||||
|
||||
### 1.7 RAG Flow (Technisch - WP-25a)
|
||||
|
||||
Wenn der Intent nicht `INTERVIEW` ist, wird folgender Flow ausgeführt:
|
||||
|
||||
1. **Intent Detection:** Hybrid Router klassifiziert die Anfrage.
|
||||
1. **Intent Detection:** Hybrid Router klassifiziert die Anfrage via `router_profile` (z.B. `compression_fast`).
|
||||
2. **Multi-Stream Retrieval:**
|
||||
* Parallele Abfragen in spezialisierten Streams via `DecisionEngine._execute_parallel_streams()`.
|
||||
* Jeder Stream nutzt individuelle Filter, Edge-Boosts und Query-Templates.
|
||||
3. **Pre-Synthesis Kompression (WP-25a):**
|
||||
* Streams über `compression_threshold` werden via `compression_profile` verdichtet.
|
||||
* Parallelisierung über `asyncio.gather()` für mehrere Streams gleichzeitig.
|
||||
4. **Wissens-Synthese:**
|
||||
* Strategie-spezifisches `llm_profile` (z.B. `tech_expert` für CODING) steuert die finale Antwortgenerierung.
|
||||
* Fallback-Kaskade bei Fehlern (automatisch via LLMService).
|
||||
3. **Context Formatting:**
|
||||
* Stream-Ergebnisse werden in formatierte Kontext-Strings umgewandelt.
|
||||
* **Ollama Context-Throttling:** Kontext wird auf `MAX_OLLAMA_CHARS` begrenzt (Standard: 10.000).
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
doc_type: technical_reference
|
||||
audience: developer, admin
|
||||
scope: configuration, env, registry, scoring, resilience, modularization, agentic_rag
|
||||
scope: configuration, env, registry, scoring, resilience, modularization, agentic_rag, moe
|
||||
status: active
|
||||
version: 2.9.3
|
||||
context: "Umfassende Referenztabellen für Umgebungsvariablen (inkl. Hybrid-Cloud & WP-76), YAML-Konfigurationen, Edge Registry Struktur und WP-25 Multi-Stream RAG unter Berücksichtigung von WP-14."
|
||||
version: 3.0.0
|
||||
context: "Umfassende Referenztabellen für Umgebungsvariablen (inkl. Hybrid-Cloud & WP-76), YAML-Konfigurationen, Edge Registry Struktur, WP-25 Multi-Stream RAG und WP-25a Mixture of Experts (MoE) unter Berücksichtigung von WP-14."
|
||||
---
|
||||
|
||||
# Konfigurations-Referenz
|
||||
@@ -329,6 +329,80 @@ Alle möglichen Stream-Variablen werden vorab initialisiert (verhindert KeyError
|
||||
**Provider-spezifische Templates:**
|
||||
Separate Versionen für Ollama, Gemini und OpenRouter.
|
||||
|
||||
---
|
||||
|
||||
## 6. LLM Profile Registry (`llm_profiles.yaml` v1.3.0)
|
||||
|
||||
Seit WP-25a nutzt MindNet eine **Mixture of Experts (MoE)** Architektur mit profilbasierter Experten-Steuerung. Jede Systemaufgabe (Synthese, Ingestion-Validierung, Routing, Kompression) wird einem dedizierten Profil zugewiesen, das Modell, Provider und Parameter unabhängig von der globalen Konfiguration definiert.
|
||||
|
||||
### 6.1 Profil-Struktur
|
||||
|
||||
Jedes Profil definiert:
|
||||
* **`provider`:** Cloud-Provider (`openrouter`, `gemini`, `ollama`)
|
||||
* **`model`:** Spezifisches Modell (z.B. `mistralai/mistral-7b-instruct:free`)
|
||||
* **`temperature`:** Kreativität/Determinismus (0.0 = deterministisch, 1.0 = kreativ)
|
||||
* **`fallback_profile`:** Optional: Name des Fallback-Profils bei Fehlern
|
||||
* **`dimensions`:** Optional: Für Embedding-Profile (z.B. 768 für nomic-embed-text)
|
||||
|
||||
**Beispiel:**
|
||||
```yaml
|
||||
synthesis_pro:
|
||||
provider: "openrouter"
|
||||
model: "gemini-1.5-mistralai/mistral-7b-instruct:free"
|
||||
temperature: 0.7
|
||||
fallback_profile: "synthesis_backup"
|
||||
```
|
||||
|
||||
### 6.2 Verfügbare Experten-Profile
|
||||
|
||||
| Profil | Provider | Modell | Temperature | Fallback | Zweck |
|
||||
| :--- | :--- | :--- | :--- | :--- | :--- |
|
||||
| **`synthesis_pro`** | openrouter | gemini-1.5-mistralai/mistral-7b-instruct:free | 0.7 | `synthesis_backup` | Hochwertige Synthese (Chat-Antworten) |
|
||||
| **`synthesis_backup`** | openrouter | mistralai/mistral-large | 0.5 | `identity_safe` | Backup-Cloud-Experte (Resilienz) |
|
||||
| **`tech_expert`** | openrouter | anthropic/claude-3.5-sonnet | 0.3 | `synthesis_pro` | Fachspezialist für Code & Technik |
|
||||
| **`compression_fast`** | openrouter | mistralai/mistral-7b-instruct:free | 0.1 | `identity_safe` | Schnelle Kompression & Routing |
|
||||
| **`ingest_extractor`** | openrouter | mistralai/mistral-7b-instruct:free | 0.2 | `synthesis_backup` | Extraktion komplexer Datenstrukturen |
|
||||
| **`ingest_validator`** | openrouter | mistralai/mistral-7b-instruct:free | 0.0 | `compression_fast` | Binäre Prüfungen (YES/NO, deterministisch) |
|
||||
| **`identity_safe`** | ollama | phi3:mini | 0.2 | *(kein Fallback)* | Lokaler Anker & Privacy (terminaler Endpunkt) |
|
||||
| **`embedding_expert`** | ollama | nomic-embed-text | - | - | Embedding-Modell (dimensions: 768) |
|
||||
|
||||
### 6.3 Fallback-Kaskade (WP-25a)
|
||||
|
||||
Die Profile implementieren eine **rekursive Fallback-Kaskade**:
|
||||
|
||||
1. **Primäres Profil:** System versucht das angeforderte Profil (z.B. `synthesis_pro`)
|
||||
2. **Fallback-Level 1:** Bei Fehler → `fallback_profile` (z.B. `synthesis_backup`)
|
||||
3. **Fallback-Level 2:** Bei weiterem Fehler → nächster Fallback (z.B. `identity_safe`)
|
||||
4. **Terminaler Endpunkt:** `identity_safe` hat keinen Fallback (lokales Modell als letzte Instanz)
|
||||
|
||||
**Schutzmechanismen:**
|
||||
* **Zirkuläre Referenzen:** `visited_profiles`-Tracking verhindert Endlosschleifen
|
||||
* **Background-Semaphore:** Parallele Tasks werden gedrosselt (konfigurierbar via `BACKGROUND_LIMIT`)
|
||||
|
||||
### 6.4 Integration in Decision Engine
|
||||
|
||||
Die `decision_engine.yaml` referenziert Profile über:
|
||||
* **`router_profile`:** Profil für Intent-Erkennung (z.B. `compression_fast`)
|
||||
* **`llm_profile`:** Profil für Strategie-spezifische Synthese (z.B. `tech_expert` für CODING)
|
||||
* **`compression_profile`:** Profil für Stream-Kompression (z.B. `compression_fast`)
|
||||
|
||||
**Stream-Konfiguration:**
|
||||
```yaml
|
||||
values_stream:
|
||||
llm_profile: "identity_safe" # Lokales Modell für Privacy
|
||||
compression_profile: "identity_safe"
|
||||
compression_threshold: 2500
|
||||
```
|
||||
|
||||
### 6.5 Environment-Variablen
|
||||
|
||||
| Variable | Default | Beschreibung |
|
||||
| :--- | :--- | :--- |
|
||||
| `MINDNET_LLM_PROFILES_PATH` | `config/llm_profiles.yaml` | Pfad zur Profil-Registry |
|
||||
|
||||
**Hinweis:** Die `.env` Variablen `MINDNET_LLM_PROVIDER`, `MINDNET_LLM_MODEL` etc. dienen nur noch als Fallback, wenn kein Profil angegeben wird.
|
||||
|
||||
---
|
||||
|
||||
Auszug aus der decision_engine.yaml
|
||||
```yaml
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
doc_type: technical_reference
|
||||
audience: developer, devops
|
||||
scope: backend, ingestion, smart_edges, edge_registry, modularization
|
||||
scope: backend, ingestion, smart_edges, edge_registry, modularization, moe
|
||||
status: active
|
||||
version: 2.13.12
|
||||
context: "Detaillierte technische Beschreibung der Import-Pipeline, Two-Pass-Workflow (WP-15b) und modularer Datenbank-Architektur (WP-14). Integriert Mistral-safe Parsing und Deep Fallback."
|
||||
version: 2.14.0
|
||||
context: "Detaillierte technische Beschreibung der Import-Pipeline, Two-Pass-Workflow (WP-15b), modularer Datenbank-Architektur (WP-14) und WP-25a profilgesteuerte Validierung. Integriert Mistral-safe Parsing und Deep Fallback."
|
||||
---
|
||||
|
||||
# Ingestion Pipeline & Smart Processing
|
||||
@@ -50,9 +50,11 @@ Der Prozess ist **asynchron**, **idempotent** und wird nun in zwei logische Durc
|
||||
* Bei Änderungen löscht `purge_artifacts()` via `app.core.ingestion.ingestion_db` alle alten Chunks und Edges der Note.
|
||||
* Die Namensauflösung erfolgt nun über das modularisierte `database`-Paket.
|
||||
10. **Chunking anwenden:** Zerlegung des Textes basierend auf dem ermittelten Profil (siehe Kap. 3).
|
||||
11. **Smart Edge Allocation & Semantic Validation (WP-15b):**
|
||||
11. **Smart Edge Allocation & Semantic Validation (WP-15b / WP-25a):**
|
||||
* Der `SemanticAnalyzer` schlägt Kanten-Kandidaten vor.
|
||||
* **Validierung:** Jeder Kandidat wird durch das LLM semantisch gegen das Ziel im **LocalBatchCache** geprüft.
|
||||
* **Validierung (WP-25a):** Jeder Kandidat wird durch das LLM semantisch gegen das Ziel im **LocalBatchCache** geprüft.
|
||||
* **Profilgesteuerte Validierung:** Nutzt das MoE-Profil `ingest_validator` (Temperature 0.0 für maximale Determinismus).
|
||||
* **Fallback-Kaskade:** Bei Fehlern erfolgt automatischer Fallback via `fallback_profile` (z.B. `compression_fast` → `identity_safe`).
|
||||
* **Traffic Control:** Nutzung der neutralen `clean_llm_text` Funktion zur Bereinigung von Steuerzeichen (<s>, [OUT]).
|
||||
* **Deep Fallback (v2.11.14):** Erkennt "Silent Refusals". Liefert die Cloud keine verwertbaren Kanten, wird ein lokaler Fallback via Ollama erzwungen.
|
||||
12. **Inline-Kanten finden:** Parsing von `[[rel:...]]` und Callouts.
|
||||
@@ -60,7 +62,9 @@ Der Prozess ist **asynchron**, **idempotent** und wird nun in zwei logische Durc
|
||||
* Jede Kante wird via `EdgeRegistry` normalisiert (z.B. `basiert_auf` -> `based_on`).
|
||||
* Unbekannte Typen werden in `unknown_edges.jsonl` protokolliert.
|
||||
14. **Default- & Strukturkanten:** Anwendung der `edge_defaults` und Erzeugung von Systemkanten (`belongs_to`, `next`, `prev`).
|
||||
15. **Embedding (Async):** Generierung der Vektoren via `nomic-embed-text` (768 Dimensionen).
|
||||
15. **Embedding (Async - WP-25a):** Generierung der Vektoren via `embedding_expert` Profil aus `llm_profiles.yaml`.
|
||||
* **Profil-Auflösung:** Das `EmbeddingsClient` lädt Modell und Dimensionen direkt aus dem Profil (z.B. `nomic-embed-text`, 768 Dimensionen).
|
||||
* **Konsolidierung:** Entfernung der Embedding-Konfiguration aus der `.env` zugunsten zentraler Profil-Registry.
|
||||
16. **Database Sync (WP-14):** Batch-Upsert aller Points in die Collections `{prefix}_chunks` und `{prefix}_edges` über die zentrale Infrastruktur.
|
||||
|
||||
---
|
||||
@@ -189,4 +193,6 @@ Kanten werden nach Vertrauenswürdigkeit (`provenance`) priorisiert. Die höhere
|
||||
|
||||
**2. Mistral-safe Parsing:** Automatisierte Bereinigung von LLM-Antworten in `ingestion_validation.py`. Stellt sicher, dass semantische Entscheidungen ("YES"/"NO") nicht durch technische Header verfälscht werden.
|
||||
|
||||
**3. Profilgesteuerte Validierung (WP-25a):** Die semantische Kanten-Validierung erfolgt zwingend über das MoE-Profil `ingest_validator` (Temperature 0.0 für Determinismus). Dies gewährleistet konsistente binäre Entscheidungen (YES/NO) unabhängig von der globalen Provider-Konfiguration.
|
||||
|
||||
**3. Purge Integrity:** Validierung, dass vor jedem Upsert alle assoziierten Artefakte in den Collections `{prefix}_chunks` und `{prefix}_edges` gelöscht wurden, um Daten-Duplikate zu vermeiden.
|
||||
Reference in new issue
Block a user