WindoneRepo2 / docs /CAUTION.md
Hitelcy's picture
Add definitive WindOneSound V3.2 Architecture Guide (CAUTION.md)
ba6f042 verified
|
Raw History Blame Contribute Delete
4.1 kB
# ⚠️ CAUTION: WindOneSound V3.2 Architecture & Training Guide
## 1. Executive Summary
WindOneSound is a **Multimodal Reasoning Engine**. It listens to audio, builds a causal graph of events, remembers context, and generates natural language. It is NOT a simple transcriber.
## 2. The Data Flow Pipeline
### Stage A: Perception (Frozen)
* **Input:** Raw Audio → BEATs → `[B, T, 768]`.
* **Module:** `PrimitiveExtractor`.
* **Output:** Dense Primitives `[B, T, 512]`.
* **Status:** FROZEN. Load weights from `primitive_extractor_esc50_best.pt`.
### Stage B: Reasoning Core (Trainable)
1. **SourceMemory:** Biases features by speaker/source identity.
2. **TimeConditioning:** Injects sinusoidal time embeddings. **CRITICAL:** Added INSIDE `CausalGraph`, not LLM.
3. **CausalGraphNetwork:** Builds entity-event relationships using bidirectional attention. Uses Time Embeddings to order events.
4. **COGENMemory:** Long-term storage with Top-K slot addressing and Decay Factor (0.995).
* **Output:** `read_out` `[B, T, 512]` (Fully contextualized).
### Stage C: Hybrid Discretization (The Bridge)
* **Module:** `VQPrimitiveTokenizer`.
* **Outputs:**
1. `z_q`: Quantized continuous vectors `[B, T, 512]`.
2. `tokens`: Discrete integer IDs `[B, T]` (0-1023).
* **Purpose:** Filters noise and creates a stable "Audio Vocabulary".
### Stage D: Generation Heads (Trainable)
* **LLM Decoder:** Generates text.
* **Context Input:** HYBRID VECTOR (See Section 3).
* **Text Input:** Question/Prompt tokens.
* **Voice Head:** Synthesizes Mel-Spectrograms from RAW `read_out` (no quantization artifacts).
* **Agent Head:** Outputs action vectors from pooled `read_out`.
## 3. The Hybrid Context Strategy (VQ + Projection)
To maximize performance, we do NOT choose between VQ Tokens and Continuous Projections. We USE BOTH.
**Formula:**
`Final_Context[t] = Linear_Projection(z_q[t]) + Learned_Embedding(VQ_Token_ID[t])`
**Why?**
* **Linear Projection (`z_q`):** Carries rich semantic detail (timbre, pitch, emotion). Essential for descriptive accuracy.
* **Learned Embedding (`Token ID`):** Carries structural information (event boundaries, repetition patterns). Helps the LLM align text timestamps with audio events.
**Implementation Note:**
In `output_heads.py`, ensure `DualOutputHeads.forward` constructs this hybrid tensor before passing it to `self.text_decoder`.
## 4. Training Strategy (Strict Phasing)
### Phase 1: Validation (Done ✅)
* Verify Primitive Extractor quality (>90% ESC-50 Acc).
### Phase 2: Codebook Stabilization (Done ✅)
* Train VQ Tokenizer on frozen primitives. Goal: >95% code usage.
### Phase 3: Reasoning Warm-up
* **Trainable:** SourceMemory, CausalGraph, COGENMemory.
* **Frozen:** PE, VQ, LLM.
* **Task:** Contrastive Learning or Classification to teach temporal/causal structure.
### Phase 4: Joint Multimodal Training
* **Trainable:** Everything EXCEPT PrimitiveExtractor.
* **Optimizer:** AdamW with Parameter Groups:
* VQ Codebook: LR=1e-5
* Graph/Memory: LR=1e-4
* LLM Decoder: LR=5e-4
* Heads: LR=1e-3
* **Loss:** `L_text + 0.1*L_vq + 0.01*L_mel`
## 5. How Time Conditioning Works
Time embeddings are added to primitive features BEFORE the Causal Graph processes them. This allows the Graph's attention mechanism to distinguish between "Event A at t=0" and "Event B at t=5", enabling causal ordering (Cause → Effect). The LLM sees the *result* of this ordering, not the raw time signals.
## 6. QA Capability
The model answers questions via Conditional Generation:
1. User asks: "Was there a dog?"
2. Text Encoder processes question.
3. Cross-Attention looks at Hybrid Audio Context.
4. If "Dog" concepts are present in `z_q` and structured correctly by Graph, LLM predicts "Yes".
## 7. Common Pitfalls
* **NaN Loss:** Clip gradients (max_norm=1.0). Lower VQ LR.
* **Hallucinations:** Ensure `src_key_padding_mask` is used so LLM ignores silent audio frames.
* **Memory Overflow:** Monitor COGEN novelty scores; adjust decay if slots saturate.