Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,218 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
-
|
10 |
|
|
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
### Model Description
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
-
|
20 |
-
- **Developed by:** [More Information Needed]
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
|
32 |
-
- **Repository:**
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
## Uses
|
37 |
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
### Direct Use
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
### Out-of-Scope Use
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
57 |
|
58 |
## Bias, Risks, and Limitations
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
63 |
|
64 |
### Recommendations
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
## How to Get Started with the Model
|
71 |
-
|
72 |
-
Use the code below to get started with the model.
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
|
76 |
## Training Details
|
77 |
|
78 |
### Training Data
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
83 |
|
84 |
### Training Procedure
|
85 |
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
#### Training Hyperparameters
|
94 |
|
95 |
-
- **Training
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
98 |
|
99 |
-
|
100 |
|
101 |
-
|
|
|
|
|
102 |
|
103 |
## Evaluation
|
104 |
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
### Testing Data, Factors & Metrics
|
108 |
|
109 |
#### Testing Data
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
|
121 |
#### Metrics
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
126 |
|
127 |
### Results
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
-
##
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
|
155 |
### Model Architecture and Objective
|
156 |
|
157 |
-
|
|
|
|
|
|
|
|
|
158 |
|
159 |
### Compute Infrastructure
|
160 |
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
#### Hardware
|
164 |
|
165 |
-
|
|
|
166 |
|
167 |
#### Software
|
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 |
## Model Card Contact
|
198 |
|
199 |
-
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
license: apache-2.0
|
4 |
+
base_model: t5-base
|
5 |
+
tags:
|
6 |
+
- text2text-generation
|
7 |
+
- music
|
8 |
+
- spotify
|
9 |
+
- audio-features
|
10 |
+
- t5
|
11 |
+
language:
|
12 |
+
- en
|
13 |
+
datasets:
|
14 |
+
- custom
|
15 |
+
metrics:
|
16 |
+
- mae
|
17 |
+
- mse
|
18 |
+
- correlation
|
19 |
---
|
20 |
|
21 |
+
# T5 Spotify Features Generator
|
|
|
|
|
|
|
22 |
|
23 |
+
A fine-tuned T5-base model that generates Spotify audio features from natural language music descriptions.
|
24 |
|
25 |
## Model Details
|
26 |
|
27 |
### Model Description
|
28 |
|
29 |
+
This model converts natural language descriptions of music preferences into Spotify audio feature values. For example, "energetic dance music for a party" becomes `"danceability": 0.9, "energy": 0.9, "valence": 0.9`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
- **Developed by:** afsagag
|
32 |
+
- **Model type:** Text-to-Text Generation (T5)
|
33 |
+
- **Language(s):** English
|
34 |
+
- **License:** Apache-2.0
|
35 |
+
- **Finetuned from model:** [t5-base](https://huggingface.co/t5-base)
|
36 |
|
37 |
+
### Model Sources
|
38 |
|
39 |
+
- **Repository:** https://huggingface.co/afsagag/t5-spotify-features-generator
|
|
|
|
|
40 |
|
41 |
## Uses
|
42 |
|
|
|
|
|
43 |
### Direct Use
|
44 |
|
45 |
+
Generate Spotify audio features from music descriptions for:
|
46 |
+
- Music recommendation systems
|
47 |
+
- Playlist generation
|
48 |
+
- Music discovery applications
|
49 |
+
- Audio feature prediction research
|
50 |
+
|
51 |
+
```python
|
52 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
53 |
+
import torch
|
54 |
+
|
55 |
+
# Load model and tokenizer
|
56 |
+
model = T5ForConditionalGeneration.from_pretrained("afsagag/t5-spotify-features-generator")
|
57 |
+
tokenizer = T5Tokenizer.from_pretrained("afsagag/t5-spotify-features-generator")
|
58 |
+
|
59 |
+
def generate_spotify_features(prompt, model, tokenizer):
|
60 |
+
input_text = f"prompt: {prompt}"
|
61 |
+
input_ids = tokenizer(input_text, return_tensors="pt", max_length=256, truncation=True).input_ids
|
62 |
+
|
63 |
+
with torch.no_grad():
|
64 |
+
outputs = model.generate(
|
65 |
+
input_ids,
|
66 |
+
max_length=256,
|
67 |
+
num_beams=4,
|
68 |
+
early_stopping=True,
|
69 |
+
do_sample=False,
|
70 |
+
pad_token_id=tokenizer.pad_token_id,
|
71 |
+
eos_token_id=tokenizer.eos_token_id
|
72 |
+
)
|
73 |
+
|
74 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
75 |
+
return result
|
76 |
+
|
77 |
+
# Example usage
|
78 |
+
prompt = "I need energetic dance music for a party"
|
79 |
+
features = generate_spotify_features(prompt, model, tokenizer)
|
80 |
+
print(features) # Output: "danceability": 0.9, "energy": 0.9, "valence": 0.9
|
81 |
+
```
|
82 |
|
83 |
### Out-of-Scope Use
|
84 |
|
85 |
+
- Generating actual audio or music files
|
86 |
+
- Non-English music descriptions (model trained on English only)
|
87 |
+
- Precise music recommendation without human oversight
|
88 |
+
- Applications requiring guaranteed JSON format output
|
89 |
|
90 |
## Bias, Risks, and Limitations
|
91 |
|
92 |
+
- **Training Data Bias:** Reflects patterns in the training dataset, may not represent all musical styles or cultural contexts
|
93 |
+
- **JSON Format Issues:** May occasionally generate incomplete JSON objects
|
94 |
+
- **Subjective Features:** Audio features like "valence" and "energy" are subjective and may not align with all listeners' perceptions
|
95 |
+
- **Western Music Bias:** Training focused on Western musical concepts and terminology
|
96 |
|
97 |
### Recommendations
|
98 |
|
99 |
+
- Validate generated features against expected ranges
|
100 |
+
- Use as a starting point rather than definitive feature values
|
101 |
+
- Consider cultural and stylistic diversity when applying to diverse music catalogs
|
102 |
+
- Implement post-processing to ensure valid JSON output if required
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
## Training Details
|
105 |
|
106 |
### Training Data
|
107 |
|
108 |
+
Custom dataset of 4,206 examples pairing natural language music descriptions with Spotify audio features:
|
109 |
+
- **Training set:** 3,364 examples
|
110 |
+
- **Validation set:** 421 examples
|
111 |
+
- **Test set:** 421 examples
|
112 |
|
113 |
### Training Procedure
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
#### Training Hyperparameters
|
116 |
|
117 |
+
- **Training epochs:** 5
|
118 |
+
- **Learning rate:** 2e-4
|
119 |
+
- **Batch size:** 32 (train), 16 (eval)
|
120 |
+
- **Gradient accumulation steps:** 2
|
121 |
+
- **LR scheduler:** Cosine with 5% warmup
|
122 |
+
- **Max sequence length:** 256 tokens
|
123 |
+
- **Training regime:** bf16 mixed precision
|
124 |
|
125 |
+
#### Speeds, Sizes, Times
|
126 |
|
127 |
+
- **Training time:** ~58 minutes
|
128 |
+
- **Final training loss:** 0.5579
|
129 |
+
- **Model size:** ~892MB
|
130 |
|
131 |
## Evaluation
|
132 |
|
|
|
|
|
133 |
### Testing Data, Factors & Metrics
|
134 |
|
135 |
#### Testing Data
|
136 |
|
137 |
+
Same distribution as training data: natural language music descriptions paired with Spotify audio features.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
#### Metrics
|
140 |
|
141 |
+
- Mean Absolute Error (MAE) between predicted and actual feature values
|
142 |
+
- Mean Squared Error (MSE) for regression accuracy
|
143 |
+
- Pearson correlation coefficients for individual features
|
144 |
+
- Valid JSON ratio for output format correctness
|
145 |
|
146 |
### Results
|
147 |
|
148 |
+
The model demonstrates strong semantic understanding of musical concepts:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
+
| Prompt | Generated Features |
|
151 |
+
|--------|-------------------|
|
152 |
+
| "I need energetic dance music for a party" | `"danceability": 0.9, "energy": 0.9, "valence": 0.9` |
|
153 |
+
| "Play calm acoustic songs for studying" | `"acousticness": 0.8, "energy": 0.2, "valence": 0.2` |
|
154 |
+
| "Upbeat music for working out" | `"danceability": 0.7, "energy": 0.8, "valence": 0.7` |
|
155 |
+
| "Relaxing instrumental background music" | `"acousticness": 0.3, "energy": 0.2, "instrumentalness": 0.8, "valence": 0.2` |
|
156 |
+
| "Happy pop music for driving" | `"danceability": 0.8, "energy": 0.8, "valence": 0.8` |
|
157 |
|
158 |
+
## Technical Specifications
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
### Model Architecture and Objective
|
161 |
|
162 |
+
- **Base Architecture:** T5 (Text-To-Text Transfer Transformer)
|
163 |
+
- **Model Size:** t5-base (220M parameters)
|
164 |
+
- **Objective:** Sequence-to-sequence generation of audio features from text descriptions
|
165 |
+
- **Input Format:** `"prompt: {natural_language_description}"`
|
166 |
+
- **Output Format:** JSON-style audio feature values
|
167 |
|
168 |
### Compute Infrastructure
|
169 |
|
|
|
|
|
170 |
#### Hardware
|
171 |
|
172 |
+
- GPU with CUDA support
|
173 |
+
- Mixed precision training (bf16)
|
174 |
|
175 |
#### Software
|
176 |
|
177 |
+
- PyTorch with CUDA
|
178 |
+
- Transformers library
|
179 |
+
- Datasets library for data processing
|
180 |
+
|
181 |
+
## Spotify Audio Features Reference
|
182 |
+
|
183 |
+
The model generates these Spotify audio features:
|
184 |
+
|
185 |
+
- **danceability** (0.0-1.0): How suitable a track is for dancing
|
186 |
+
- **energy** (0.0-1.0): Perceptual measure of intensity and power
|
187 |
+
- **valence** (0.0-1.0): Musical positivity (happy vs sad)
|
188 |
+
- **acousticness** (0.0-1.0): Confidence measure of acoustic nature
|
189 |
+
- **instrumentalness** (0.0-1.0): Predicts absence of vocals
|
190 |
+
- **speechiness** (0.0-1.0): Presence of spoken words
|
191 |
+
- **liveness** (0.0-1.0): Presence of live audience
|
192 |
+
- **loudness** (dB): Overall loudness, typically -60 to 0 dB
|
193 |
+
- **tempo** (BPM): Estimated beats per minute
|
194 |
+
- **duration_ms**: Track duration in milliseconds
|
195 |
+
- **key** (0-11): Musical key (C=0, C♯/D♭=1, etc.)
|
196 |
+
- **mode** (0-1): Modality (0=minor, 1=major)
|
197 |
+
- **time_signature** (3-7): Time signature
|
198 |
+
- **popularity** (0-100): Spotify popularity score
|
199 |
+
|
200 |
+
## Citation
|
201 |
+
|
202 |
+
```bibtex
|
203 |
+
@misc{t5-spotify-features-generator,
|
204 |
+
author = {afsagag},
|
205 |
+
title = {T5 Spotify Features Generator: Fine-tuned T5 for Music Feature Prediction from Natural Language},
|
206 |
+
year = {2025},
|
207 |
+
publisher = {Hugging Face},
|
208 |
+
howpublished = {\url{https://huggingface.co/afsagag/t5-spotify-features-generator}}
|
209 |
+
}
|
210 |
+
```
|
211 |
+
|
212 |
+
## Model Card Authors
|
213 |
+
|
214 |
+
afsagag
|
215 |
|
216 |
## Model Card Contact
|
217 |
|
218 |
+
Contact through Hugging Face profile: [@afsagag](https://huggingface.co/afsagag)
|