pub struct RvqDepthDecoder { /* private fields */ }Expand description
The RVQ depth decoder: given the frame’s hidden state and the codes chosen so far, it predicts the next codebook level.
It is a small CAUSAL transformer over a sequence that never exceeds the codebook count — the positional table is 16 rows for 8 levels — with no rotary embedding at all. Attention that forgets the mask here leaks a level’s own answer backwards and the model still samples.
Implementations§
Source§impl RvqDepthDecoder
impl RvqDepthDecoder
pub fn from_cmf(model: &Arc<CmfModel>) -> Result<Self, String>
pub fn codebooks(&self) -> usize
Sourcepub fn project(&self, x: &[f32]) -> Vec<f32>
pub fn project(&self, x: &[f32]) -> Vec<f32>
projection is applied to every element entering the sequence —
the frame hidden, the c0 embedding and each extra embedding.
Sourcepub fn forward_last(&self, seq: &[f32], n: usize) -> Vec<f32>
pub fn forward_last(&self, seq: &[f32], n: usize) -> Vec<f32>
Run the stack over [n, hidden] and return the LAST position’s
normed hidden — the only one the caller reads.
Sourcepub fn forward_last_streams(
&self,
seq: &[f32],
streams: usize,
n: usize,
) -> Vec<f32>
pub fn forward_last_streams( &self, seq: &[f32], streams: usize, n: usize, ) -> Vec<f32>
forward_last over streams independent sequences of n positions
each, [streams, n, hidden] — the CFG pair runs the depth decoder
as one batch, each stream attending only to itself. Returns the last
position’s normed hidden per stream, [streams, hidden].