Upload audact-stage_b_ctc8
Browse filesFiles changed (5)
- README.md+11-8
- audact/audio_encoder.py+38-2
- audact/voice_model.py+12-5
- config.json+2-2
- model.safetensors+1-1
25 unmodified lines2627282930313224 unmodified lines57585960616263646566676 unmodified lines74757677787980818283848525 unmodified lines## How it works```audio (16 kHz) -> FastConformer (NVIDIA, top 4 of 16 layers fine-tuned) -> frames, about 13 per secondframes -> linear adapter (256 -> 512) -> take the place of the text query in Needle's input[audio vectors] [<tools>] [tool list as compact JSON] -> Needle encoder (Cactus, fine-tuned)Needle decoder -> <tool_call> [{"name": ..., "arguments": {...}}] or [] (no call)24 unmodified lines| | This model | NeuDecide (reference) ||---|---|---|| Synthetic val, unseen tools, TTS voices (908 clips): right tool / exact | **84.5% / 52.2%** | 69.4% / 26.4% || Synthetic val: false triggers (256 no-call clips) | **17%** | 79% || SLURP val, real voices (1,507 clips): right tool / exact | 48.9% / **26.8%** | **55.9%** / 18.4% || SLURP val: false triggers (152 no-call clips) | **29%** | 97% || SLURP val, scenarios held out of our training (alarm, social): right tool | 15.2% | **55.0%** || Pure noise or silence, no speech (350 clips): false triggers | **0%** | not measured |NeuDecide scores the same on alarm and social as on other scenarios, which suggests those were in its6 unmodified linestends to pick a familiar-looking tool.- Argument values are written as spoken ("next tuesday"); arithmetic and relative values belong inthe calling app.- Exact match on real voices is low (27%), mostly from choosing which optional arguments to fill.## Training- Audio encoder: NVIDIA `stt_en_fastconformer_hybrid_medium_streaming_80ms`, frozen in stage A, top 4layers fine-tuned in stage B. Text side: Cactus `Needle` (26M), ported from JAX to PyTorch.- Data: SLURP real recordings (scenarios alarm, social, transport, cooking, takeaway, audio andrecommendation held out), with LLM-written versions of its tools; synthetic spoken commands(tools and commands from Glaive, ToolACE, xLAM and LLM-written ones) voiced by Kokoro and Piper25 unmodified lines2627282930313224 unmodified lines57585960616263646566676 unmodified lines74757677787980818283848586878825 unmodified lines## How it works```audio (16 kHz) -> FastConformer (NVIDIA, top 8 of 16 layers fine-tuned) -> frames, about 13 per secondframes -> linear adapter (256 -> 512) -> take the place of the text query in Needle's input[audio vectors] [<tools>] [tool list as compact JSON] -> Needle encoder (Cactus, fine-tuned)Needle decoder -> <tool_call> [{"name": ..., "arguments": {...}}] or [] (no call)24 unmodified lines| | This model | NeuDecide (reference) ||---|---|---|| Synthetic val, unseen tools, TTS voices (908 clips): right tool / exact | **85.7% / 53.3%** | 69.4% / 26.4% || Synthetic val: false triggers (256 no-call clips) | **17%** | 79% || SLURP val, real voices (1,507 clips): right tool / exact | 50.0% / **28.3%** | **55.9%** / 18.4% || SLURP val: false triggers (152 no-call clips) | **31%** | 97% || SLURP val, scenarios held out of our training (alarm, social): right tool | 16.2% | **55.0%** || Pure noise or silence, no speech (350 clips): false triggers | **0%** | not measured |NeuDecide scores the same on alarm and social as on other scenarios, which suggests those were in its6 unmodified linestends to pick a familiar-looking tool.- Argument values are written as spoken ("next tuesday"); arithmetic and relative values belong inthe calling app.- Exact match on real voices is low (28%): mishearing names, places and times, and choosing whichoptional arguments to fill.## Training- Audio encoder: NVIDIA `stt_en_fastconformer_hybrid_medium_streaming_80ms`, frozen in stage A, top 8layers fine-tuned in stage B, with a transcription side task (FastConformer's own speech-to-text headtrained on our transcripts at weight 0.1; the head is for training only and isn't included). Its worderror rate on SLURP val fell from 44% to 31%. Text side: Cactus `Needle` (26M), ported from JAX to PyTorch.- Data: SLURP real recordings (scenarios alarm, social, transport, cooking, takeaway, audio andrecommendation held out), with LLM-written versions of its tools; synthetic spoken commands(tools and commands from Glaive, ToolACE, xLAM and LLM-written ones) voiced by Kokoro and Piper
18 unmodified lines19202122232412 unmodified lines37383940414212 unmodified lines555657585960611 unmodified line6364656618 unmodified linesFRAME_DIM = 256 # FastConformer medium's output widthclass AudioEncoder(nn.Module):"""FastConformer's preprocessor + encoder; the ASR decoders (RNNT, CTC) are dropped."""12 unmodified linesfor layer in self.encoder.layers[len(self.encoder.layers) - k:] if k else []:for p in layer.parameters():p.requires_grad = Trueself.train(self.training)def train(self, mode: bool = True) -> AudioEncoder:12 unmodified linesreturn frames.transpose(1, 2), frame_lengths # (B, T, 256), (B,)@classmethoddef from_pretrained(cls, device: str = "cpu") -> AudioEncoder:import nemo.collections.asr as nemo_asrfrom huggingface_hub import hf_hub_download1 unmodified lineasr = nemo_asr.models.ASRModel.restore_from(path, map_location=device)asr.preprocessor.featurizer.dither = 0.0 # no random noise in the features: same audio, same framesasr.preprocessor.featurizer.pad_to = 0return cls(asr.preprocessor, asr.encoder).eval()18 unmodified lines1920212223242526272829303132333435363738394041424344454647484912 unmodified lines626364656667686970717212 unmodified lines8586878889909192931 unmodified line959697989910010110218 unmodified linesFRAME_DIM = 256 # FastConformer medium's output widthdef _checkpoint_forward(layer: nn.Module) -> None:"""Gradient checkpointing for one learning layer: its intermediate results aren't kept for backward butrecomputed then (same math; dropout replays the same random numbers). With 8 learning layers a heavybatch needed more than 6.4 GB in backward (stage_b_ctc8, 2026-11-27)."""if getattr(layer, "_checkpointed", False):returnfrom torch.utils.checkpoint import checkpointplain = layer.forwarddef forward(*args, **kwargs):if not (torch.is_grad_enabled() and layer.training):return plain(*args, **kwargs)# checkpoint saves and replays the GPU's random numbers (dropout) only for devices of tensors passed# by position, and NeMo passes everything by name (x=..., att_mask=...): without this the recomputed# pass drew new dropout masks and gave wrong gradients (checked 2026-11-27).if not args and "x" in kwargs:x = kwargs.pop("x")return checkpoint(lambda x, **kw: plain(x=x, **kw), x, use_reentrant=False, **kwargs)return checkpoint(plain, *args, use_reentrant=False, **kwargs)layer.forward = forwardlayer._checkpointed = Trueclass AudioEncoder(nn.Module):"""FastConformer's preprocessor + encoder; the ASR decoders (RNNT, CTC) are dropped."""12 unmodified linesfor layer in self.encoder.layers[len(self.encoder.layers) - k:] if k else []:for p in layer.parameters():p.requires_grad = Trueif getattr(self, "ctc_head", None) is not None: # the transcription side task trains it toofor p in self.ctc_head.parameters():p.requires_grad = Truefor layer in self.encoder.layers[len(self.encoder.layers) - k:] if k else []:_checkpoint_forward(layer)self.train(self.training)def train(self, mode: bool = True) -> AudioEncoder:12 unmodified linesreturn frames.transpose(1, 2), frame_lengths # (B, T, 256), (B,)@classmethoddef from_pretrained(cls, device: str = "cpu", with_ctc: bool = False) -> AudioEncoder:"""with_ctc: also keep FastConformer's CTC speech-to-text head and its tokenizer, for thetranscription side task in Stage B (2026-11-26). Inference never uses them."""import nemo.collections.asr as nemo_asrfrom huggingface_hub import hf_hub_download1 unmodified lineasr = nemo_asr.models.ASRModel.restore_from(path, map_location=device)asr.preprocessor.featurizer.dither = 0.0 # no random noise in the features: same audio, same framesasr.preprocessor.featurizer.pad_to = 0enc = cls(asr.preprocessor, asr.encoder)if with_ctc:enc.ctc_head = asr.ctc_decoder # frames (B, 256, T) -> log-probs (B, T, 1025), blank = 1024enc.ctc_tokenizer = asr.tokenizer # lowercase SentencePiece, 1,024 piecesreturn enc.eval()
224 unmodified lines22522622722822923023123223323432 unmodified lines267268269270271272224 unmodified linesreturn self.encode(self.batch_frames(batch), batch.prefix_lengths, batch.tool_ids, batch.tool_lengths)return self.encode_text(batch.prefix, batch.prefix_lengths, batch.tool_ids, batch.tool_lengths)def forward_batch(self, batch) -> torch.Tensor:"""A src.train_data.Batch (audio or text rows) -> logits (B, T_d, 8192)."""memory, memory_mask = self.encode_batch(batch)return self.needle.decode(batch.decoder_in, memory, memory_mask)def frames_from_audio(self, waveform: torch.Tensor, lengths: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:"""waveform (B, samples), lengths (B,) -> frames (B, T_a, 256), frame_lengths (B,)."""32 unmodified linesmodel.needle.load_state_dict(ck["needle"])if "audio_encoder" in ck:from .audio_encoder import AudioEncodermodel.audio_encoder = AudioEncoder.from_pretrained(device=device)model.audio_encoder.load_state_dict(ck["audio_encoder"])return model.to(device)224 unmodified lines22522622722822923023123223323423523623723823924032 unmodified lines273274275276277278279224 unmodified linesreturn self.encode(self.batch_frames(batch), batch.prefix_lengths, batch.tool_ids, batch.tool_lengths)return self.encode_text(batch.prefix, batch.prefix_lengths, batch.tool_ids, batch.tool_lengths)def forward_batch(self, batch, return_frames: bool = False):"""A src.train_data.Batch (audio or text rows) -> logits (B, T_d, 8192); with return_frames also theaudio frames (B, T_a, 256) it used (for the CTC side task), None for text rows."""frames = self.batch_frames(batch) if batch.kind == "audio" else Noneif frames is not None:memory, memory_mask = self.encode(frames, batch.prefix_lengths, batch.tool_ids, batch.tool_lengths)else:memory, memory_mask = self.encode_text(batch.prefix, batch.prefix_lengths, batch.tool_ids, batch.tool_lengths)logits = self.needle.decode(batch.decoder_in, memory, memory_mask)return (logits, frames) if return_frames else logitsdef frames_from_audio(self, waveform: torch.Tensor, lengths: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:"""waveform (B, samples), lengths (B,) -> frames (B, T_a, 256), frame_lengths (B,)."""32 unmodified linesmodel.needle.load_state_dict(ck["needle"])if "audio_encoder" in ck:from .audio_encoder import AudioEncoderwith_ctc = any(k.startswith("ctc_head.") for k in ck["audio_encoder"]) # side-task runs saved the headmodel.audio_encoder = AudioEncoder.from_pretrained(device=device, with_ctc=with_ctc)model.audio_encoder.load_state_dict(ck["audio_encoder"])return model.to(device)
16 unmodified lines171819202122233 unmodified lines2728293031323316 unmodified lines"audio_encoder": {"base": "nvidia/stt_en_fastconformer_hybrid_medium_streaming_80ms","revision": "4207369a33","trained_layers": 4},"tokenizer": {"file": "tokenizer.model",3 unmodified lines"max_input_positions": 1024,"decoding": "whole-name scoring, then greedy arguments","trained_from": {"checkpoint": "runs/stage_a/stage_b_aug2/model_step4898.pt","update": 4898},"parameters": 5255913216 unmodified lines171819202122233 unmodified lines2728293031323316 unmodified lines"audio_encoder": {"base": "nvidia/stt_en_fastconformer_hybrid_medium_streaming_80ms","revision": "4207369a33","trained_layers": 8},"tokenizer": {"file": "tokenizer.model",3 unmodified lines"max_input_positions": 1024,"decoding": "whole-name scoring, then greedy arguments","trained_from": {"checkpoint": "runs/stage_a/stage_b_ctc8/model_step4898.pt","update": 4898},"parameters": 52559132
123version https://git-lfs.github.com/spec/v1oid sha256:26a7462d3b33c1f699075a2350c5ab0ec9c9e223d148fded8c1bdfc0fcb03f55size 210423928123version https://git-lfs.github.com/spec/v1oid sha256:c92099ea32dae23a27d468503b71040420033c28b29566d0e4f72dd6ad0a0845size 210423928
README.md+11-8
audact/audio_encoder.py+38-2
audact/voice_model.py+12-5
config.json+2-2
model.safetensors+1-1