pianistprogrammer commited on
Commit
908f281
·
verified ·
1 Parent(s): 9852ecb

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +158 -0
README.md ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: pytorch
4
+ tags:
5
+ - music
6
+ - folk-music
7
+ - irish-traditional-music
8
+ - abc-notation
9
+ - symbolic-music
10
+ - representation-learning
11
+ - self-supervised
12
+ - transformer
13
+ pipeline_tag: feature-extraction
14
+ ---
15
+
16
+ # ABC2Vec: Self-Supervised Representation Learning for Irish Folk Music
17
+
18
+ This is the official pre-trained ABC2Vec model from the paper:
19
+
20
+ **"ABC2Vec: Self-Supervised Representation Learning for Irish Folk Music"**
21
+
22
+ ## Model Description
23
+
24
+ ABC2Vec is a self-supervised Transformer encoder that learns dense, semantically meaningful embeddings from ABC notation (symbolic music format). It is specifically designed for Irish traditional folk music and trained on 211,524 tunes.
25
+
26
+ ### Key Features
27
+
28
+ - 🎵 **Purpose-built for folk music** - Addresses transposition equivalence, modal tonality, and variant detection
29
+ - 🔄 **Transposition Invariance** - Novel TI objective for pitch-invariant representations
30
+ - 📊 **Bar-level Patchification** - 16× sequence length reduction for efficiency
31
+ - 🎯 **Self-supervised** - No text annotations or audio required
32
+ - ⚡ **Efficient** - Trained in 18 hours on Apple M4 Mac
33
+
34
+ ## Model Architecture
35
+
36
+ - **Layers:** 6
37
+ - **Hidden Size (d_model):** 256
38
+ - **Attention Heads:** 8
39
+ - **FFN Size (d_ff):** 1024
40
+ - **Embedding Size:** 128
41
+ - **Vocabulary Size:** 98
42
+ - **Max Bars:** 64
43
+ - **Max Bar Length:** 64
44
+ - **Parameters:** ~5M
45
+
46
+ ## Training Details
47
+
48
+ - **Dataset:** 211,524 Irish traditional tunes (IrishMAN corpus)
49
+ - **Training Objectives:**
50
+ - Masked Music Modeling (MMM)
51
+ - Transposition Invariance (TI) contrastive learning
52
+ - **Training Steps:** 40,000 steps (40 epochs)
53
+ - **Final Validation Loss:** 2.36
54
+ - **Hardware:** Apple M4 Mac (48GB unified memory)
55
+ - **Training Time:** ~18 hours
56
+
57
+ ## Performance
58
+
59
+ | Task | Accuracy | Notes |
60
+ |------|----------|-------|
61
+ | Tune Type Classification | 78.4% ± 1.2% | 6 classes (jig, reel, polka, etc.) |
62
+ | Mode Classification | 78.8% ± 1.6% | 4 classes (major, minor, dorian, mixolydian) |
63
+ | Key Root (Linear Probe) | 62.3% ± 0.9% | 8 most common keys |
64
+ | Tune Length (Linear Probe) | 89.5% ± 0.7% | 3 classes (short, medium, long) |
65
+
66
+ ## Usage
67
+
68
+ ```python
69
+ import torch
70
+ import json
71
+ from pathlib import Path
72
+
73
+ # Load model configuration
74
+ config_path = "model_config.json"
75
+ with open(config_path) as f:
76
+ config_dict = json.load(f)
77
+
78
+ # Initialize model (you'll need the ABC2Vec model code)
79
+ from abc2vec.core.model import ABC2VecModel
80
+ from abc2vec.core.model.encoder import ABC2VecConfig
81
+
82
+ config = ABC2VecConfig(**config_dict)
83
+ model = ABC2VecModel(config)
84
+
85
+ # Load pre-trained weights
86
+ checkpoint = torch.load("best_model.pt", map_location="cpu")
87
+ model.load_state_dict(checkpoint["model_state_dict"])
88
+ model.eval()
89
+
90
+ # Load vocabulary for tokenization
91
+ with open("vocab.json") as f:
92
+ vocab_data = json.load(f)
93
+
94
+ # Extract embeddings for a tune
95
+ from abc2vec.core.tokenizer import ABCVocabulary, BarPatchifier
96
+
97
+ vocab = ABCVocabulary.load("vocab.json")
98
+ patchifier = BarPatchifier(
99
+ vocab=vocab,
100
+ max_bars=config.max_bars,
101
+ max_bar_length=config.max_bar_length
102
+ )
103
+
104
+ # Example ABC tune
105
+ abc_tune = "M:6/8\nK:D\n|:A2A ABc|ded cBA|A2A ABc|ded cAG|"
106
+ patches = patchifier.patchify(abc_tune)
107
+
108
+ # Get embedding
109
+ with torch.no_grad():
110
+ bar_indices = patches["bar_indices"].unsqueeze(0)
111
+ char_mask = patches["char_mask"].unsqueeze(0)
112
+ bar_mask = patches["bar_mask"].unsqueeze(0)
113
+
114
+ embedding = model.get_embedding(bar_indices, char_mask, bar_mask)
115
+ # embedding shape: (1, 128)
116
+ ```
117
+
118
+ ## Code Repository
119
+
120
+ Full training code, evaluation scripts, and usage examples:
121
+ - **GitHub:** https://github.com/pianistprogrammer/ABC2VEC
122
+
123
+ ## Dataset
124
+
125
+ The processed dataset with train/validation/test splits:
126
+ - **HuggingFace:** https://huggingface.co/datasets/pianistprogrammer/abc2vec-irish-folk-dataset
127
+
128
+ ## Citation
129
+
130
+ If you use this model, please cite:
131
+
132
+ ```bibtex
133
+ @article{abc2vec2025,
134
+ title={ABC2Vec: Self-Supervised Representation Learning for Irish Folk Music},
135
+ author={[Your Name]},
136
+ journal={[Journal Name]},
137
+ year={2025},
138
+ note={Model: https://huggingface.co/pianistprogrammer/abc2vec-model}
139
+ }
140
+ ```
141
+
142
+ ## License
143
+
144
+ MIT License
145
+
146
+ ## Acknowledgements
147
+
148
+ We thank The Session community for curating and maintaining the Irish traditional music archive that made this work possible.
149
+
150
+ ## Model Card Authors
151
+
152
+ [Your Name]
153
+
154
+ ## Contact
155
+
156
+ For questions or issues:
157
+ - GitHub: https://github.com/pianistprogrammer/ABC2VEC
158
+ - HuggingFace: https://huggingface.co/pianistprogrammer