LeNEPA encoder (CauKer2M, encoder-only)
This repository contains an encoder-only LeNEPA checkpoint exported to safetensors for minimal inference.
What is included:
lenepa_encoder.safetensors- encoder weights only (no projector, no training/probe state)inference.py- minimal end-to-end inference (no Hydra, no W&B, no repo dependency)lenepa_encoder_config.json- fixed IO + architecture contractprovenance.json- original.ptcheckpoint path + W&B URL
IO contract
Inputs:
x_waveform:torch.float32with shape[B, 1, 5000]- sampling frequency:
1 - channels:
["c0"]
Tokenizer:
- causal
conv_patch_embedwithpatch_size=8 - per-patch normalization inside the tokenizer
- MSSE scalar embeddings for patch mean and patch std
Outputs:
patch_tokens:[B, 625, 256](post-final-norm tokens)embedding:[B, 256](mean pooled over tokens)
Preparing inputs
The exported inference.py expects x_waveform.shape == [B, 1, 5000] and does not resample internally.
Two common options:
- No resampling
Use this when your waveform is already length 5000 or you just if it works better without resampling:
from pathlib import Path
import torch
from inference import encode_lenepa, load_lenepa_encoder
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = load_lenepa_encoder(weights_path=Path("lenepa_encoder.safetensors"), device=device)
x = torch.randn(2, 1, 5000, device=device, dtype=torch.float32) # [B, C, L=5000]
out = encode_lenepa(model=model, x_waveform=x)
print(out.patch_tokens.shape)
- Interpolate to
5000
Validation on UCR shows, that resampling samples that have different length to 5000 generates noticably better classification quality:
from pathlib import Path
import torch
from torch.nn import functional as F
from inference import encode_lenepa, load_lenepa_encoder
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = load_lenepa_encoder(weights_path=Path("lenepa_encoder.safetensors"), device=device)
x_raw = torch.randn(2, 1, 137, device=device, dtype=torch.float32) # [B, C, L_raw]
x = F.interpolate(x_raw, size=5000, mode="linear", align_corners=False) # [B, C, 5000]
out = encode_lenepa(model=model, x_waveform=x)
print(out.embedding.shape)
Usage
Smoke test (loads lenepa_encoder.safetensors from the current directory and prints output shapes):
python inference.py
Programmatic usage:
from pathlib import Path
import torch
from torch.nn import functional as F
from inference import encode_lenepa, load_lenepa_encoder
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = load_lenepa_encoder(weights_path=Path("lenepa_encoder.safetensors"), device=device)
x_raw = torch.randn(2, 1, 137, device=device, dtype=torch.float32) # [B, C, L_raw]
x = F.interpolate(x_raw, size=5000, mode="linear", align_corners=False) # [B, C, 5000]
out = encode_lenepa(model=model, x_waveform=x)
print(out.embedding.shape)
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support