Linear probing experiments on multimodal MusicCoCa embeddings to test separability of musical concepts from text prompts and MTAT audio clips
This project evaluates whether MusicCoCa embedding space linearly separates:
- Genre and style (core probe)
- Genre-to-instrument semantic alignment (probe weight correlation)
- Additional musical attributes (tempo, timbre, structure, melody, octave, duration, loudness, instrument)
- Text-vs-audio separability gaps using a quick MTAT protocol
It produces reproducible artifacts in outputs/ and markdown summaries in the repository root.
scripts/: data prep, embedding extraction, probing, visualization, and validation scriptsoutputs/: generated artifacts (.npy,.json, and figures)results_summary.md: core genre/style findingsresults_additional_attributes.md: additional text-attribute probe findingsresults_text_vs_audio.md: quick text-vs-audio comparison findings
- Python 3.10+ recommended
- A local clone of
magenta-realtimeavailable as a sibling directory - Dependencies used by this repo:
numpyscikit-learnmatplotlibseabornumap-learn
The scripts import MusicCoCa by adding ../../magenta-realtime to sys.path, so this repository should be placed so that both directories are siblings:
<workspace>/
magenta-realtime/
probing_coca/
Place MTAT under probing_coca/mtat/ with:
annotations_final.csvclip_info_final.csv- clip audio files at the paths referenced by
mp3_path
From this repository root:
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install numpy scikit-learn matplotlib seaborn umap-learnIf your local magenta-realtime setup requires extra dependencies, install them in the same environment before running embedding scripts.
Run from the repository root in this order:
python scripts/generate_prompts.py
python scripts/extract_embeddings.py
python scripts/probe_genre_style.py
python scripts/visualize_umap.py
python scripts/instrument_correlation.py
python scripts/compile_results.py
python scripts/validate_outputs.pypython scripts/probe_additional_attributes.pypython scripts/prepare_mtat_tasks.py \
--mtat-root mtat \
--annotations mtat/annotations_final.csv \
--clip-info mtat/clip_info_final.csv
python scripts/extract_audio_embeddings_mtat.py \
--tasks outputs/mtat_tasks.json \
--mtat-root mtat
python scripts/probe_mtat_audio_tags.py \
--tasks outputs/mtat_tasks.json \
--embeddings outputs/mtat_audio_embeddings.npy \
--metadata outputs/mtat_audio_metadata.json
python scripts/compare_text_vs_audio.py \
--audio-results outputs/mtat_audio_probe_results.json \
--text-results outputs/additional_probe_results.jsonKey artifacts generated in outputs/:
metadata.json: prompt taxonomyembeddings.npy: text embedding matrixprobe_results.json: genre/style probe metricsW_genre.npy,W_style.npy: learned linear probe weight matricespairwise_overlap.npy: genre-vs-style per-class cosine overlapgenre_instrument_similarity.npy: genre probe weights vs instrument text embeddingsadditional_probe_results.json: additional attribute probe metricsmtat_tasks.json: MTAT quick-run task definitionsmtat_audio_embeddings.npy: MTAT audio embedding matrixmtat_audio_probe_results.json: audio probe metricstext_vs_audio_comparison.json: merged text-vs-audio table
Figures are written to outputs/figures/ as .png and/or .pdf.
From current committed summaries:
- Genre probe accuracy:
1.000(10-class) - Style probe accuracy:
0.567(6-class) - Subspace overlap cosine (genre vs style mean directions):
0.000 - Additional text-attribute probes: all listed attributes above chance, with strongest results for instrument/structure/chord-choice
- Quick MTAT comparison: audio can outperform text for some proxies (e.g., loudness), while text remains stronger on others (e.g., instrument in this setup)
See detailed tables in:
results_summary.mdresults_additional_attributes.mdresults_text_vs_audio.md
- Cross-validation is stratified and uses fixed random states where specified in scripts.
- UMAP uses a fixed random seed.
- MTAT quick run enforces artist-disjoint folds via grouped splitting.
- First use of MusicCoCa may trigger model asset downloads.
MIT. See LICENSE.