File size: 9,535 Bytes
171001f
 
 
441b1d6
 
171001f
441b1d6
171001f
 
 
 
 
 
 
b1a21fa
 
 
e90ece6
 
 
b1a21fa
 
 
171001f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e90ece6
 
 
 
171001f
e90ece6
171001f
 
 
 
 
e90ece6
171001f
e90ece6
171001f
 
 
e90ece6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171001f
 
441b1d6
 
e90ece6
 
 
 
171001f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e90ece6
171001f
e90ece6
171001f
e90ece6
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
---
license: cc-by-4.0
task_categories:
# - music-information-retrieval
# - symbolic-music
- audio-classification
- audio-to-audio
tags:
- midi
- music
- audio-features
- million-song-dataset
- data-vault
configs:
  - config_name: mart_artist_profile_sample
    data_files:
      - "gold_lakh_midi/mart_artist_profile_sample.parquet"
  - config_name: mart_track_analytics_sample
    data_files:
      - "gold_lakh_midi/mart_track_analytics_sample.parquet"
  - config_name: mart_musical_features_sample
    data_files:
      - "gold_lakh_midi/mart_musical_features_sample.parquet"
  - config_name: hub_artist
    data_files:
      - "silver_lakh_midi/hub_artist.parquet"
  - config_name: hub_key_signature
    data_files:
      - "silver_lakh_midi/hub_key_signature.parquet"
  - config_name: hub_midi_file
    data_files:
      - "silver_lakh_midi/hub_midi_file.parquet"
  - config_name: hub_midi_source
    data_files:
      - "silver_lakh_midi/hub_midi_source.parquet"
  - config_name: hub_mode
    data_files:
      - "silver_lakh_midi/hub_mode.parquet"
  - config_name: hub_release
    data_files:
      - "silver_lakh_midi/hub_release.parquet"
  - config_name: hub_track
    data_files:
      - "silver_lakh_midi/hub_track.parquet"
  - config_name: link_artist_similar
    data_files:
      - "silver_lakh_midi/link_artist_similar.parquet"
  - config_name: link_midi_source
    data_files:
      - "silver_lakh_midi/link_midi_source.parquet"
  - config_name: link_track_artist
    data_files:
      - "silver_lakh_midi/link_track_artist.parquet"
  - config_name: link_track_midi
    data_files:
      - "silver_lakh_midi/link_track_midi.parquet"
  - config_name: link_track_release
    data_files:
      - "silver_lakh_midi/link_track_release.parquet"
  - config_name: sat_artist
    data_files:
      - "silver_lakh_midi/sat_artist.parquet"
  - config_name: sat_artist_mbtags
    data_files:
      - "silver_lakh_midi/sat_artist_mbtags.parquet"
  - config_name: sat_artist_similarity
    data_files:
      - "silver_lakh_midi/sat_artist_similarity.parquet"
  - config_name: sat_artist_terms
    data_files:
      - "silver_lakh_midi/sat_artist_terms.parquet"
  - config_name: sat_key_signature
    data_files:
      - "silver_lakh_midi/sat_key_signature.parquet"
  - config_name: sat_match_scores
    data_files:
      - "silver_lakh_midi/sat_match_scores.parquet"
  - config_name: sat_midi_file
    data_files:
      - "silver_lakh_midi/sat_midi_file/**/*.parquet"
  - config_name: sat_mode
    data_files:
      - "silver_lakh_midi/sat_mode.parquet"
  - config_name: sat_release
    data_files:
      - "silver_lakh_midi/sat_release.parquet"
  - config_name: sat_track
    data_files:
      - "silver_lakh_midi/sat_track/**/*.parquet"
size_categories:
- 100K<n<1M
---

# NTRC Lakh MIDI Dataset

> [!NOTE]  
> Check out the tables prefixed with `mart_*` to get started for some easy to understand and interesting data

This dataset contains an opionated, structured and lightly cleaned release of the [Lakh MIDI Dataset](https://colinraffel.com/projects/lmd/) by Colin Raffel, transformed using modern data engineering practices into a Data Vault 2.0 model.

## Dataset Description

The original Lakh MIDI Dataset is a collection of 176,581 unique MIDI files, 45,129 of which have been matched and aligned to entries in the Million Song Dataset. This processed version transforms the raw data into a structured format suitable for music information retrieval research and analysis.

**Key ideas in this release:**
- **Structured Data Vault 2.0 model** with hubs, links, and satellites
- **Bronze layer** with raw extracted data in Parquet format (not part of this distribution, see https://github.com/Nintorac/lakh_midi_dataset to build it)
- **Silver layer** with cleaned, deduplicated, and structured data
- **Gold layer** with clean derormalized views ready for ML pipelines and other downstream usecases

## Usage Examples

### Connecting to the Remote Database

You can attach to the remote Lakh MIDI database using DuckDB and query the processed data directly:

```sql
-- Attach the remote database
ATTACH 'hf://datasets/nintorac/ntrc_lakh_midi/lakh_remote.duckdb' AS lakh_remote;

-- Sample the artist profile mart table
CREATE TABLE my_artist_sample AS 
SELECT * FROM lakh_remote.mart_artist_profile 
WHERE artist_profile_tier = 'High Profile' 
LIMIT 100;


-- Query the sample
SELECT 
    artist_name,
    total_tracks,
    avg_tempo,
    most_common_key,
    top_terms[1:3] as top_3_terms
FROM my_artist_sample
ORDER BY total_tracks DESC;
```

This approach allows you to fetch data from the gold layer, without having to manage the full silver layer locally. It's pretty slow though so it would be best to follow the above pattern to save a table locally before running analysis.

## Data Structure

To understand the schema of the silver layer check out the [schema_silver.dbml](https://github.com/Nintorac/lakh_midi_dataset/blob/main/schema_silver.dbml) - load it in [dbdiagram.io](https://dbdiagram.io/d) for an interactive view.

Below is a high level overview of how the tables fit together.

![high level silver schema diagram](assets/ntrc_lakh_schema_silver.png)

### Silver Layer (`silver_lakh_midi/`)
Structured using Data Vault 2.0 methodology:

#### Hubs (Business Entities)
- **`hub_track.parquet`** - MusicBrainz tracks
- **`hub_artist.parquet`** - Artists (including similar artists)
- **`hub_release.parquet`** - 7digital releases  
- **`hub_midi_file.parquet`** - MIDI files by MD5 hash
- **`hub_midi_source.parquet`** - Source file paths
- **`hub_key_signature.parquet`** - Musical key signatures (0-11)
- **`hub_mode.parquet`** - Musical modes (0=minor, 1=major)

#### Links (Relationships)
- **`link_track_midi.parquet`** - Track-to-MIDI matches
- **`link_track_artist.parquet`** - Track-to-artist relationships
- **`link_track_release.parquet`** - Track-to-release relationships
- **`link_artist_similar.parquet`** - Artist similarity relationships
- **`link_midi_source.parquet`** - MIDI-to-source path mappings

#### Satellites (Descriptive Data)
- **`sat_track/`** - Track details, audio analysis, and time-series arrays (partitioned)
- **`sat_artist.parquet`** - Artist metadata and location info
- **`sat_release.parquet`** - Release information
- **`sat_midi_file/`** - MIDI file content and size (partitioned)
- **`sat_match_scores.parquet`** - Match quality scores
- **`sat_artist_similarity.parquet`** - Similarity rankings
- **`sat_artist_terms.parquet`** - Echo Nest artist terms
- **`sat_artist_mbtags.parquet`** - MusicBrainz tags
- **`sat_key_signature.parquet`** - Human-readable key signature names
- **`sat_mode.parquet`** - Human-readable mode names

## Data Quality Features

- **Deduplication**: Consistent handling of duplicate entities
- **Referential Integrity**: All foreign keys reference valid parents
- **Partitioned Storage**: Large tables partitioned by hash key prefix for scalable processing
- **Comprehensive Testing**: Data quality tests ensure consistency and completeness

## Technical Details

- **Format**: Apache Parquet with snappy compression
- **Schema**: Data Vault 2.0 with hash keys for scalable joins
- **Processing**: Built with dlt, dbt, and DuckDB
- **Partitioning**: Large tables partitioned by first character of hash keys (0-9, a-f)

## Original Dataset Information

This processed dataset is based on the Lakh MIDI Dataset, which contains:
- **176,581 unique MIDI files** from LMD-full
- **45,129 matched files** aligned to Million Song Dataset entries
- **Audio analysis features** from Echo Nest
- **Artist metadata** including MusicBrainz tags and similarity data

## Citations & License

### License
This dataset is distributed under the [CC-BY 4.0](http://creativecommons.org/licenses/by/4.0/) license, following the original Lakh MIDI Dataset license.

### Required Citations

If you use this dataset, please cite the original Lakh MIDI Dataset:

```bibtex
@phdthesis{raffel2016learning,
  title={Learning-Based Methods for Comparing Sequences, with Applications to Audio-to-MIDI Alignment and Matching},
  author={Raffel, Colin},
  year={2016},
  school={Columbia University}
}
```

For the Million Song Dataset metadata, please also cite:

```bibtex
@inproceedings{bertin2011million,
  title={The Million Song Dataset},
  author={Bertin-Mahieux, Thierry and Ellis, Daniel PW and Whitman, Brian and Lamere, Paul},
  booktitle={Proceedings of the 12th International Society for Music Information Retrieval Conference},
  pages={591--596},
  year={2011}
}
```

### Attribution Note

The original MIDI files were scraped from publicly-available sources on the internet and de-duplicated by Colin Raffel. While MIDI files have a built-in mechanism for attribution (the Copyright meta-event), it is not used consistently, so attributing each individual MIDI file to a particular author is not feasible.

## Processing Pipeline

This dataset was processed using:
- **dlt** for data extraction from unstructured files
- **dbt** for data transformation and testing
- **DuckDB** as the analytics database engine
- **Data Vault 2.0 methodology** for scalable data modeling

For more information about the processing pipeline, see the [project repository](https://github.com/nintorac/lakh_midi_dataset).

## Resources

- [Colin Raffel's project page](https://colinraffel.com/projects/lmd/).
- [Million Song Dataset](http://millionsongdataset.com/)
- [Echo Nest Schema](https://developer.spotify.com/documentation/web-api/reference/get-audio-analysis)