Views
No views yet
[batch, 1, 1024, 128]16 x 161import torch
2from transformers import AutoModel
3
4model = AutoModel.from_pretrained(
5 "lrauch/BAT-vit-b16-pretrainedAS2M",
6 trust_remote_code=True,
7).eval()
8
9# Already-preprocessed BAT log-mel features:
10# [batch, channel, time, mel]
11features = torch.randn(2, 1, 1024, 128)
12
13with torch.no_grad():
14 outputs = model(input_features=features)
15
16print(outputs.last_hidden_state.shape) # [2, 513, 768]
17print(outputs.pooler_output.shape) # [2, 768]
18print(outputs.patch_tokens.shape) # [2, 768, 64, 8]1import sys
2import torch
3from huggingface_hub import snapshot_download
4
5local_dir = snapshot_download("lrauch/BAT-vit-b16-pretrainedAS2M")
6sys.path.insert(0, local_dir)
7
8from load_model import load_pretrained_encoder
9
10model = load_pretrained_encoder(device="cuda")
11
12fbank = torch.randn(2, 1, 1024, 128, device="cuda")
13
14with torch.no_grad():
15 features = model.forward_encoder(fbank)
16
17print(features.shape) # [2, 513, 768]1import sys
2import torch
3from huggingface_hub import snapshot_download
4
5local_dir = snapshot_download("lrauch/BAT-vit-b16-pretrainedAS2M")
6sys.path.insert(0, local_dir)
7
8from load_model import load_audio_processor, load_pretrained_encoder
9
10processor = load_audio_processor(device="cuda")
11model = load_pretrained_encoder(device="cuda")
12
13waveform = torch.randn(2, 16000 * 10, device="cuda")
14
15input_features = processor(waveform)
16
17with torch.no_grad():
18 outputs = model(input_features=input_features)
19
20print(input_features.shape) # [2, 1, 1024, 128]
21print(outputs.last_hidden_state.shape) # [2, 513, 768][batch, 1, time, mel].transformers, download the raw model.safetensors file:1from huggingface_hub import hf_hub_download
2from safetensors.torch import load_file
3
4weights_path = hf_hub_download(
5 repo_id="lrauch/BAT-vit-b16-pretrainedAS2M",
6 filename="model.safetensors",
7)
8
9state_dict = load_file(weights_path, device="cpu")
10print(state_dict.keys())1cls_token
2pos_embed
3patch_embed.proj.weight
4patch_embed.proj.bias
5pre_norm.weight
6pre_norm.bias
7blocks.0.attn.qkv.weight
8blocks.0.attn.qkv.bias
9blocks.0.attn.proj.weight
10blocks.0.attn.gate.weight
11...model.safetensors: pretrained BAT encoder weightsconfig.json: architecture and audio preprocessing configurationconfiguration_bat.py: custom Transformers configmodeling_bat.py: vendored BAT encoder architectureprocessing_bat.py: optional waveform-to-feature processorload_model.py: convenience loadertorch, transformers, safetensors, huggingface_hub. The raw waveform processor also requires torchaudio.1@inproceedings{ghaffari2026batbetteraudiotransformer,
2 title={BAT: Better Audio Transformer Guided by Convex Gated Probing},
3 author={Houtan Ghaffari and Lukas Rauch and Christoph Scholz and Paul Devos},
4 year={2026},
5 booktitle={International Conference on Machine Learning (ICML)}
6}