Add transition-aware R1 and R2 objectives

This commit is contained in:
Xin Wang
2026-08-26 17:18:50 +08:00
parent 0590df1e88
commit 5923b89d60
27 changed files with 979 additions and 22 deletions

112
README.md
View File

@@ -4,6 +4,9 @@ This project tests whether **Qwen2.5-Omni-3B can replace both the handcrafted
audio/visual feature extractors and the downstream RNN/Transformer used by
EgoSpeak** for egocentric turn-taking anticipation.
The persistent paper index and Chinese summaries are maintained in
[literature_notes](literature_notes/README.md).
The main experiment is deliberately simple:
```text
@@ -160,6 +163,115 @@ reducing background AP. The full protocol, per-seed summary, seed-0 horizon
curves, and machine-readable data are archived in
[`results/easycom_loss_structure_4ep_2026-08-26/`](results/easycom_loss_structure_4ep_2026-08-26/README.md).
#### R1/R2 transition-aware head ablation
The transition target for current state t and future horizon h is one exactly
when the complete three-label activity row changes between t+h-1 and t+h.
This includes onset, offset, speaker handover, and entering or leaving overlap.
It never uses media or labels after the prediction target t+h.
Both variants share the activity MLP trunk and add a small binary 10-horizon
transition readout:
- R1 supervised uses
L = L_activity + 0.2 L_transition,
where L_transition is BCEWithLogits with positive weight 3.
- R2 expected reward uses
L = L_activity + 0.2 L_transition - 0.1 E[R_transition].
For transition probability p and target z, correctness reward is
z p + (1-z)(1-p). Its expectation is computed exactly, weighted with the
same positive weight 3, and normalized by total weight. There is no sampled
policy gradient, so this is the low-variance control rather than a claim of
interactive reinforcement learning.
Run the fixed four-epoch, no-development-set comparison with the same schedule
as the loss-structure ablation:
~~~bash
FEATURE_ROOT=/data1/yfzx/wangx/Datasets/easycom/omni_features/open_stream_2fps_8s_last4_stack
TARGET_ROOT=/data1/yfzx/wangx/Datasets/easycom/easycom_target_frame
for seed in 0 1 2
do
CUDA_VISIBLE_DEVICES=0 \
OMP_NUM_THREADS=4 \
MKL_NUM_THREADS=4 \
OPENBLAS_NUM_THREADS=4 \
python train_turn_head.py \
--feature-root "$FEATURE_ROOT" \
--target-root "$TARGET_ROOT" \
--output "checkpoints/easycom-transition-r1-4ep-seed-$seed.pth" \
--sessions 4 5 6 7 8 9 10 11 12 \
--epochs 4 \
--batch-size 512 \
--learning-rate 7e-5 \
--weight-decay 5e-5 \
--warmup-epochs 1.6 \
--warmup-factor 0.3 \
--dropout 0.2 \
--loss lstr-mce \
--transition-objective r1-supervised \
--transition-loss-weight 0.2 \
--transition-pos-weight 3 \
--layer-fusion concat-mlp \
--expected-mode open-stream-replay \
--seed "$seed" \
--device cuda:0
CUDA_VISIBLE_DEVICES=0 \
OMP_NUM_THREADS=4 \
MKL_NUM_THREADS=4 \
OPENBLAS_NUM_THREADS=4 \
python train_turn_head.py \
--feature-root "$FEATURE_ROOT" \
--target-root "$TARGET_ROOT" \
--output "checkpoints/easycom-transition-r2-4ep-seed-$seed.pth" \
--sessions 4 5 6 7 8 9 10 11 12 \
--epochs 4 \
--batch-size 512 \
--learning-rate 7e-5 \
--weight-decay 5e-5 \
--warmup-epochs 1.6 \
--warmup-factor 0.3 \
--dropout 0.2 \
--loss lstr-mce \
--transition-objective r2-expected-reward \
--transition-loss-weight 0.2 \
--transition-pos-weight 3 \
--transition-reward-weight 0.1 \
--layer-fusion concat-mlp \
--expected-mode open-stream-replay \
--seed "$seed" \
--device cuda:0
done
~~~
Evaluate all six checkpoints. In addition to the unchanged EgoSpeak activity
metrics, inference writes transition_pred arrays and prints transition AP,
precision, recall, and F1 at threshold 0.5:
~~~bash
for variant in r1 r2
do
for seed in 0 1 2
do
CUDA_VISIBLE_DEVICES=0 python infer_turn_head.py \
--feature-root "$FEATURE_ROOT" \
--target-root "$TARGET_ROOT" \
--checkpoint "checkpoints/easycom-transition-$variant-4ep-seed-$seed.pth" \
--output-dir "results/easycom-transition-$variant-4ep-seed-$seed" \
--expected-mode open-stream-replay \
--batch-size 1024 \
--device cuda:0
done
done
~~~
Compare R1 and R2 against the existing three-seed LSTR-MCE baseline under the
same four-epoch budget. The primary paper outcome remains activity mAP; the
transition metrics diagnose whether an activity improvement is genuinely
associated with better boundary prediction.
## Current Ego4D context-length results
The following single-seed snapshot was recorded on 2026-08-22. Both variants