Spaces:
Running
Running
File size: 1,839 Bytes
d7013e6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | from dataclasses import dataclass, field
@dataclass
class GrassmannConfig:
"""Configuration for the Grassmann Transcription Model."""
# Audio features
n_mels: int = 80
sample_rate: int = 16000
n_fft: int = 400
hop_length: int = 160
# Model architecture
d_model: int = 256
r_reduced: int = 32
n_layers: int = 6
d_ff: int = 1024 # 4 * d_model
dropout: float = 0.1
# Decoder architecture
n_decoder_layers: int = 4
cross_window: int = 8 # encoder positions per side for cross-mixing
# Grassmann-specific
window_offsets: list[int] = field(default_factory=lambda: [1, 2, 4, 8, 12, 16])
plucker_eps: float = 1e-8
two_sided: bool = False # True for CTC/encoder (bidirectional)
# Conformer options
use_conformer: bool = False # True = Conformer blocks, False = plain Grassmann
conv_kernel_size: int = 31 # ConvModule kernel size
conv_channels: int = 256 # Subsampling conv channels
# Ablation: swap Plücker for symmetric products to test if geometry matters
use_ablation: bool = False
# Training
learning_rate: float = 3e-4
weight_decay: float = 1e-2
batch_size: int = 16
epochs: int = 30
max_seq_len: int = 2048 # LibriSpeech clips up to ~30s → ~750 frames after subsampling
# Architecture mode
use_seq2seq: bool = True # True = encoder-decoder, False = CTC-only
# Tokenizer
tokenizer_type: str = "char" # "char" or "bpe"
bpe_vocab_size: int = 1000 # BPE vocab size if tokenizer_type="bpe"
# Vocab (set dynamically by tokenizer)
vocab_size: int = 29 # 26 letters + space + apostrophe + blank
@property
def plucker_dim(self) -> int:
"""Dimension of Plücker coordinate vector: C(r, 2)."""
return self.r_reduced * (self.r_reduced - 1) // 2
|