Views
No views yet
| Task | Accuracy | Notes |
|---|---|---|
| Tune Type Classification | 78.4% ± 1.2% | 6 classes (jig, reel, polka, etc.) |
| Mode Classification | 78.8% ± 1.6% | 4 classes (major, minor, dorian, mixolydian) |
| Key Root (Linear Probe) | 62.3% ± 0.9% | 8 most common keys |
| Tune Length (Linear Probe) | 89.5% ± 0.7% | 3 classes (short, medium, long) |
1import torch
2import json
3from pathlib import Path
4
5# Load model configuration
6config_path = "model_config.json"
7with open(config_path) as f:
8 config_dict = json.load(f)
9
10# Initialize model (you'll need the ABC2Vec model code)
11from abc2vec.core.model import ABC2VecModel
12from abc2vec.core.model.encoder import ABC2VecConfig
13
14config = ABC2VecConfig(**config_dict)
15model = ABC2VecModel(config)
16
17# Load pre-trained weights
18checkpoint = torch.load("best_model.pt", map_location="cpu")
19model.load_state_dict(checkpoint["model_state_dict"])
20model.eval()
21
22# Load vocabulary for tokenization
23with open("vocab.json") as f:
24 vocab_data = json.load(f)
25
26# Extract embeddings for a tune
27from abc2vec.core.tokenizer import ABCVocabulary, BarPatchifier
28
29vocab = ABCVocabulary.load("vocab.json")
30patchifier = BarPatchifier(
31 vocab=vocab,
32 max_bars=config.max_bars,
33 max_bar_length=config.max_bar_length
34)
35
36# Example ABC tune
37abc_tune = "M:6/8\nK:D\n|:A2A ABc|ded cBA|A2A ABc|ded cAG|"
38patches = patchifier.patchify(abc_tune)
39
40# Get embedding
41with torch.no_grad():
42 bar_indices = patches["bar_indices"].unsqueeze(0)
43 char_mask = patches["char_mask"].unsqueeze(0)
44 bar_mask = patches["bar_mask"].unsqueeze(0)
45
46 embedding = model.get_embedding(bar_indices, char_mask, bar_mask)
47 # embedding shape: (1, 128)1@article{abc2vec2025,
2 title={ABC2Vec: Self-Supervised Representation Learning for Irish Folk Music},
3 author={[Your Name]},
4 journal={[Journal Name]},
5 year={2025},
6 note={Model: https://huggingface.co/pianistprogrammer/abc2vec-model}
7}