# Simple Spatial Token Baseline Experiments This document defines two lightweight spatial-token baselines for comparing against the current SELD233-based spatial encoder in the Qwen spatial QA setup. ## Goal The current strong model path is: ```text FOA audio -> DCASE/SELD233 feature bridge -> SELD233 backbone -> spatial adapter -> 2.5 Hz spatial tokens -> projector -> Qwen LLM ``` For 20 s audio with task `235`, the expected rate is: ```text feature frames: 100 Hz, hop_len=160 SELD frames: 10 Hz, feature_to_seld_ratio=10 spatial tokens: 2.5 Hz, downsample_factor=4 20 s segment: 50 spatial tokens ``` Every baseline below must match the same spatial token rate and prompt contract: ```text <|AUDIO|><|spatial|> ``` The comparison should answer whether the full SELD233 encoder is actually needed, or whether simpler spatial cues already explain most of the QA gains. ## Baseline A: Raw FOA Intensity Vector Tokens Use only the FOA intensity-vector channels as spatial input. The existing feature bridge already computes baseline-compatible features: ```text [B, 7, T_feat, F] channels 0..3: W/X/Y/Z log-mel channels 4..6: FOA intensity-vector features ``` For task `235`, `F=128`. The IV baseline should use channels `4..6` only. Do not use full frequency averaging as the primary baseline. It is too lossy: it collapses `[3, F]` IV structure into only 3 numbers per frame before the 0.4 s temporal pooling step. Keep it only as a lower-bound sanity check. Recommended default token construction: ```text IV features: [B, 3, T_feat, F] frequency pooling: pool F into 8 or 16 mel bands -> [B, 3, T_feat, F_band] temporal pooling: average every 40 feature frames -> [B, T_spat, 3 * F_band] optional window statistics: concat mean/std/max over each 0.4 s window token MLP: 3 * F_band * N_stats -> D_token, where D_token matches the current spatial token dim projector: reuse the existing spatial projector into Qwen hidden size ``` For 20 s clips this gives: ```text T_feat=2000 T_spat=ceil(2000 / 40)=50 ``` This is a valid low-capacity baseline. It gives the LLM explicit FOA direction cues without using the trained SELD233 temporal encoder. Suggested IV variants: - `iv_3d`: mean over all frequency bins, then temporal pool to 2.5 Hz. Use this only as a very weak lower bound. - `iv_band8`: pool the 128 mel bins into 8 bands, then temporal pool to 2.5 Hz. This is the recommended first baseline. - `iv_band16`: pool into 16 bands. Use this if `iv_band8` is too weak. - `iv_band8_stats`: pool into 8 bands and concatenate mean/std over the 0.4 s temporal window. Use this if source activity changes inside the window matter. Important controls: - Normalize IV features with the same frontend normalization when possible. - Verify FOA axis convention before interpreting azimuth/elevation results. - Keep the IV MLP small, otherwise it stops being a "simple feature" baseline. - Report parameter count separately from the main SELD233 spatial branch. - Report `iv_3d` separately from band-preserving IV. They answer different questions: `iv_3d` tests whether almost no spatial detail is enough; band IV tests whether simple spatial features are enough. ## Baseline B: CNN Neural IV Tokens Train a small CNN to convert audio-derived spatial features into token vectors. Recommended input: ```text FOA feature tensor [B, 7, T_feat, F] or IV-only tensor [B, 3, T_feat, F] ``` Recommended architecture: ```text 2D CNN over time-frequency temporal downsampling to 2.5 Hz MLP projection to D_token existing spatial projector to Qwen hidden size ``` The CNN should be deliberately small. A reasonable first version is: ```text Conv2d(C_in -> 32, kernel=3, padding=1) GELU Conv2d(32 -> 64, kernel=3, stride=(4, 2), padding=1) GELU frequency pooling temporal pooling/resampling to T_spat MLP(64 -> D_token) ``` This baseline answers a different question from raw IV: ```text Can a shallow trainable spatial frontend learn enough for QA without the pretrained SELD233 backbone? ``` To avoid making this an unfair hidden strong encoder, keep the CNN shallow and train it only under the same QA supervision used by the other spatial QA runs. ## Required Negative Controls These controls are needed to interpret the baseline results. - `audio_only`: base Qwen with no spatial tokens. - `zero_spatial`: keep `<|spatial|>` placeholders but feed zero vectors. - `shuffled_spatial`: feed valid spatial tokens from another sample in the batch or from another file with the same length. - `iv_shuffled`: same as raw IV baseline, but shuffle IV tokens across samples. If `zero_spatial` or `shuffled_spatial` performs close to the real spatial baseline, the model is mostly exploiting prompt/answer priors rather than the spatial tokens. ## Optional Upper Bounds These are not required for the first baseline pass, but they are useful if the results remain ambiguous. - `oracle_angle_bin`: feed label-derived angle-bin IDs as tokens. This estimates whether the LLM can use perfect discrete spatial information. - `oracle_active_time`: feed label-derived active-time bins. This estimates the ceiling for the simplified v4 time questions. - `direct_probe`: train a small classifier on frozen spatial tokens for azimuth/elevation bin and active-at-time tasks. This separates encoder quality from LLM generation quality. ## Training Matrix Run all baselines on `qa_pairs_v4` first. It avoids direct continuous angle and time regression, which was too brittle for causal LM text generation. Recommended first-pass matrix: ```text audio_only zero_spatial shuffled_spatial iv_tokens iv_tokens + shuffled control cnn_neural_iv SELD233 stage3 model ``` Use the same QA data, LoRA target modules, learning rate range, and checkpoint selection rule where possible. For spatial-token baselines, start with: ```text train adapter/token frontend + projector + LLM LoRA freeze Qwen base weights freeze or omit SELD233 backbone ``` If the raw IV baseline is competitive with the full SELD233 branch, the current model may not be using the SELD233 temporal encoder effectively. If the CNN baseline is competitive but raw IV is not, then a lightweight trainable frontend may be enough for the QA task. If all simple baselines fail but SELD233 improves, the pretrained SELD encoder is adding useful structure. ## Metrics For `qa_pairs_v4`, report metrics by task and question class. Core metrics: ```text azimuth bin choice accuracy elevation bin choice accuracy active-at-time yes/no accuracy active-at-time balanced accuracy time-bin choice accuracy distance tolerance accuracy count accuracy source identification accuracy ``` Do not rely only on overall exact match. For yes/no and multiple-choice tasks, also compare against the class-prior baseline and random baseline: ```text yes/no random baseline: 50% 4-way choice random baseline: 25% class-prior baseline: majority label accuracy in the test split ``` ## Implementation Notes The clean implementation point is to add a pluggable spatial-token source before the existing projector path: ```text --spatial-token-source seld233 | iv | cnn_iv | zero | shuffled ``` All token sources should return: ```text spatial_tokens: [B, T_spat, D_token] spatial_token_lengths: [B] ``` That keeps the existing tokenizer, placeholder expansion, RoPE modal order, and Qwen spatial injection path unchanged. Precomputing token caches is acceptable and probably preferable for the first baseline pass: ```text precompute_iv_spatial_tokens.py precompute_cnn_iv_spatial_tokens.py ``` The training script can then load these as `spatial_tokens` directly, bypassing the SELD233 backbone while preserving the same LLM-side path. ## Main Risks - Raw IV tokens may encode direction but not source identity. Source-specific questions still require the audio branch and LLM to select the right event. - CNN Neural IV can become a strong encoder if it is too wide or too deep. - Choice QA can overestimate spatial reasoning if distractors are weak. Use the v4 distractor design and keep the negative controls. - Active-at-time QA must be balanced; otherwise a majority-class yes/no model can look good without using spatial or temporal evidence.