animal2vec workshop · MPIABDay 1 · 09:15–10:35
animal2vec
without math
A conceptual walkthrough.
Julian C. Schäfer-Zimmermann
Max Planck Institute of Animal Behavior
Department for the Ecology of Animal Societies
Communication and Collective Movement (CoCoMo) Group
animal2vec workshop · MPIABDay 1 · 09:15–10:35

The difficult part is not an isolated clean call

Paper Fig. 1a, cropped: alarm calls amid scratching, bumping, and digging.
Paper Fig. 1a, cropped: alarm calls amid scratching, bumping, and digging.

Find the vocalization.

Ignore the noise.

Learn the concept.

There is a lot of information in this example, not all of it is useful.

animal2vec workshop · MPIABDay 1 · 09:15–10:35

Rare can mean few events—or little time

Paper Fig. 2, cropped. Event counts and durations are different imbalances.
Paper Fig. 2, cropped. Event counts and durations are different imbalances.
MeerKAT
1,068 h

184 h with complete event labels

Short-note calls are numerous but have a median duration of 37 ms.

Lead calls are long, but almost never happen

animal2vec workshop · MPIABDay 1 · 09:15–10:35

A neural network is a chain of learned transformations

Numbers inSamples from a microphone
Many adjustable stepsFilters and transformations
Numbers outRepresentations or scores

Before training

The adjustable values do not yet solve the task.

After training

The values have been changed using a training objective.

animal2vec workshop · MPIABanimal2vec without math

From waveform to prediction

1. Input waveform
A raw recording: amplitude changing over time.
2. Frontend
Learns local acoustic features from short neighborhoods.
3. Transformer
Builds contextual representations: each moment can depend on other moments.
4. Classification head
Turns representations into scores or probabilities for the task.
Current stage
Press Run animation to step through the pipeline.
animal2vec workshop · MPIABDay 1 · 09:15–10:35

A model frame is not a waveform sample

80,000 samples10 seconds at 8 kHz
Convolutional frontendStride reduces sequence length
About 2,000 framesOne learned vector per position
MeerKAT baseline: a nominal 5 ms frame hop. Always use the returned timestamps.
animal2vec workshop · MPIABDay 1 · 09:15–10:35

What does a convolutional layer do?

Core idea

  • Take a small window of neighboring values.
  • Ask whether that window looks like a pattern the model has learned to detect.
  • Slide the same detector across the whole signal.
  • Write down a new output value at each position.

Why this is useful for audio

  • Short acoustic motifs can occur anywhere in time.
  • The same learned detector can respond wherever that motif appears.
  • Early layers learn local patterns; later layers combine them into richer structure.
You do not need the equations to understand the role: a convolutional layer is a reusable local pattern detector.
animal2vec workshop · MPIABanimal2vec without math

A short animation: one detector sliding across the signal

Input sequence
Detector (kernel)
Output feature map

Current step

Press Run animation.

What to notice

  • The detector always has the same shape.
  • Only its position changes.
  • High output means: "this local region looks like the learned pattern."
animal2vec workshop · MPIABDay 1 · 09:15–10:35

Local evidence becomes contextual evidence

Local question

What pattern is present around this position?

Contextual question

How does that pattern relate to the rest of this segment?

Local feature sequenceOne vector at each position
Transformer layersExchange information across positions
Contextual embeddingsA representation at each position
animal2vec workshop · MPIABDay 1 · 09:15–10:35

Attention: which other positions matter here?

Interactive example requires JavaScript.

Move the selected frame. Which parts of the segment could change its interpretation?

animal2vec workshop · MPIABDay 1 · 09:15–10:35

From embedding to prediction

The embedding describes a moment in context. The head asks which labels apply.

1. Contextualized embedding One vector for each model frame 2. Classification head A learned linear mapping 3. Per-label probabilities A separate sigmoid for each score LEARNED FEATURES Colours are values, not call labels. FEATURES RAW SCORES Weights and offsets learned in fine-tuning. Several labels may be high at once.
READY
Context is already in the embedding. Watch the head turn each frame into label probabilities.
Inspect frame
animal2vec workshop · MPIABDay 1 · 09:15–10:35

Learn, specialize, apply

PretrainUnlabelled audio
Learn useful representations
Fine-tuneAnnotated audio
Learn the target labels
InferNew audio
Apply fixed weights
Only the first two stages change the learned model.
animal2vec workshop · MPIABanimal2vec without math

One pretraining step: student and teacher

Predict the teacher’s representations of hidden moments—not call labels.

Unlabelled audio Shared frontend weights Local feature sequence Same audio for both paths TEACHER PATH All frames Teacher Transformer No gradient update weights Average selected layers + normalize Contextual targets Target embeddings STOP GRADIENT No labels · No classification head EMA of encoder weights Only after the student update STUDENT PATH Choose hidden frames Student Transformer Visible frames only weights Decoder Restore slots + predict weights Predictions Compare Masked frames only Mismatch / loss Gradients · student path only
READY
One recording, two views. The student predicts what the teacher represents at hidden time positions.
animal2vec workshop · MPIABanimal2vec without math

Fine-tuning: specialize what the model has learned

Load pretrained weights → train the new head → unfreeze → optimize together.

Pretraining checkpoint · student encoder Reuse learned audio features and contextual representations New task, new classification head No teacher or pretraining decoder in this training loop load weights load weights initialize weights Audio waveform Human labels Local frontend Sinc / convolution filters FROZEN Contextual encoder Projection + Transformer FROZEN Classification head Your label vocabulary NEW WEIGHTS Predictions vs labels Prediction Label A1 B0 Supervised focal loss Learning signal: only trainable weights change Frozen ≠ switched off. Audio still flows through the encoder.
TRAINING SCHEDULE Not started Learning rate = step size Local frontend: frozen throughout Warm-up ends: 2,000 Learning rate decays; it does not restart at unfreezing Head only Contextual encoder + head
READY
Reuse the pretrained encoder. Learn a new label mapping, then adapt the contextual representations to the supervised task.
animal2vec workshop · MPIABanimal2vec without math

Inference: from a recording to timed events

Each chunk yields embeddings and probabilities. Post-processing turns frame scores into timed events.

Fine-tuned checkpoint: frontend + Transformer + trained classification head InferenceRunner eval mode · no weight updates Audio waveform prepare · segment Frontend local audio features Transformer context at each frame Mean of K outputs keep the time axis Trained head linear → sigmoid one score per label Frame probabilities result.probabilities [T, C] result.embeddings [T, D] One vector per frame, before classification or pooling Select / average channels; resample. 10 s chunks by default; normalize each. Both arrays share result.timestamps. Join segment outputs; trim padded frames; then fuse.
One label: alarm call raw 100 ms mean threshold 0.175 Binary 1 0 Events

Prediction is not training

READYFollow one recording

Play the complete path, or select a stage. The controls below change post-processing—not model weights or embeddings.

Try “No pooling”.
animal2vec workshop · MPIABDay 1 · 09:15–10:35

What did the original study demonstrate?

Paper Fig. 4, cropped: precision–recall curves on MeerKAT.
Paper Fig. 4, cropped: precision–recall curves on MeerKAT.

1% of fine-tuning labels

Micro-average AP: 0.83

100% of fine-tuning labels

Micro-average AP: 0.91

Pretraining

Pretraining used the full 1,068 h.

animal2vec workshop · MPIABDay 1 · 09:15–10:35

Paper, workshop package, and “modern” recipe

Name Meaning in these slides
animal2vec, original paper Scientific method and reported experiments
a2v2 Python package The supplied native-PyTorch workshop implementation
configs/MeerKAT/ Animal2Vec 1.0 reproduction-oriented configurations
configs/modern/ A different, opt-in architecture/checkpoint family
animal2vec workshop · MPIABDay 1 · 09:15–10:35

Explain the pipeline to a colleague

A new WAV file enters a fixed checkpoint.
What happens next?

Explain

Samples → local features → contextual embeddings → scores → intervals.

Distinguish

Learning weights, selecting a threshold, and interpreting a prediction.

Two minutes in pairs. Identify one remaining uncertainty.

animal2vec workshop · MPIABDay 1 · 09:15–10:35

Next: make a prediction you can inspect

SelectCompatible frame checkpoint + WAV
RunRead the CLI arguments
InspectAudio + predicted intervals
Keep the checkpoint, settings, source filename, and output together.

After the break: prepared CoCoMo environment → CLI tour → first inference.