Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
| 1 |
-
---
|
| 2 |
-
license:
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- pytorch
|
| 5 |
+
- music-recommendation
|
| 6 |
+
- contrastive-learning
|
| 7 |
+
- embedding
|
| 8 |
+
- attune
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Attune Song Tower v1
|
| 12 |
+
|
| 13 |
+
Contrastive MLP that embeds Spotify tracks into a shared 128-d L2-normalized space for two-tower music retrieval.
|
| 14 |
+
|
| 15 |
+
## Architecture
|
| 16 |
+
|
| 17 |
+
| Layer | Size |
|
| 18 |
+
|-------|------|
|
| 19 |
+
| Input | 26-d (12 key one-hot + 14 audio scalars) |
|
| 20 |
+
| Hidden | 256-d + ReLU + Dropout(0.1) |
|
| 21 |
+
| Output | 128-d + L2-norm |
|
| 22 |
+
|
| 23 |
+
Loss: **InfoNCE** (symmetric) with in-batch negatives (batch 512, τ=0.07).
|
| 24 |
+
Dataset: [`maharshipandya/spotify-tracks-dataset`](https://huggingface.co/datasets/maharshipandya/spotify-tracks-dataset) (~114k tracks).
|
| 25 |
+
|
| 26 |
+
## Files
|
| 27 |
+
|
| 28 |
+
| File | Description |
|
| 29 |
+
|------|-------------|
|
| 30 |
+
| `song_tower_v1.pt` | TorchScript export — use for inference/RunPod |
|
| 31 |
+
| `song_tower_best.pt` | Full training checkpoint — resume training |
|
| 32 |
+
| `song_embeddings_v1.npy` | Pre-computed 128-d embeddings for all tracks |
|
| 33 |
+
| `song_ids_v1.npy` | Parallel Spotify track ID array |
|
| 34 |
+
| `faiss_song_v1.index` | FAISS IndexFlatIP — ANN search index |
|
| 35 |
+
| `config.json` | Model metadata |
|
| 36 |
+
|
| 37 |
+
## Quick start
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
import torch
|
| 41 |
+
import numpy as np
|
| 42 |
+
|
| 43 |
+
model = torch.jit.load("song_tower_v1.pt")
|
| 44 |
+
model.eval()
|
| 45 |
+
|
| 46 |
+
# 26-d feature vector (see config.json for spec)
|
| 47 |
+
x = torch.zeros(1, 26)
|
| 48 |
+
with torch.no_grad():
|
| 49 |
+
emb = model(x) # (1, 128)
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
## Feature vector spec (26-d)
|
| 53 |
+
|
| 54 |
+
```
|
| 55 |
+
[0–11] key one-hot (C=0 … B=11; -1/missing → all zeros)
|
| 56 |
+
[12] danceability
|
| 57 |
+
[13] energy
|
| 58 |
+
[14] speechiness
|
| 59 |
+
[15] acousticness
|
| 60 |
+
[16] instrumentalness
|
| 61 |
+
[17] liveness
|
| 62 |
+
[18] valence
|
| 63 |
+
[19] norm_loudness = clamp((loudness + 60) / 60, 0, 1)
|
| 64 |
+
[20] tempo_norm = clamp(tempo / 240, 0, 1)
|
| 65 |
+
[21] mode (0 or 1)
|
| 66 |
+
[22] explicit (0 or 1)
|
| 67 |
+
[23] popularity_norm = popularity / 100
|
| 68 |
+
[24] duration_norm = min(duration_ms / 330000, 1)
|
| 69 |
+
[25] time_signature_norm = clamp(time_signature / 7, 0, 1)
|
| 70 |
+
```
|