YAML Metadata Warning: The pipeline tag "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other

T5-Base Fine-tuned for Spotify Features Prediction

T5-Base fine-tuned to convert natural language prompts into Spotify audio feature JSON

Model Details

  • Base Model: t5-base
  • Model Type: Text-to-JSON generation
  • Language: English
  • Task: Convert natural language music preferences into Spotify audio feature JSON objects
  • Fine-tuning Dataset: Custom dataset of prompts to Spotify audio features

Known Issues

IMPORTANT: This model version may have JSON formatting issues where it doesn't generate proper curly braces. The output might need post-processing to create valid JSON.

Usage

from transformers import T5ForConditionalGeneration, T5Tokenizer
import json

# Load model and tokenizer
model = T5ForConditionalGeneration.from_pretrained("synyyy/t5-spotify-features-v2")
tokenizer = T5Tokenizer.from_pretrained("synyyy/t5-spotify-features-v2")

def generate_spotify_features(prompt):
    # Format input
    input_text = f"prompt: {prompt}"
    
    # Tokenize and generate
    input_ids = tokenizer(input_text, return_tensors="pt", max_length=256, truncation=True).input_ids
    outputs = model.generate(
        input_ids, 
        max_length=256, 
        num_beams=4, 
        early_stopping=True,
        do_sample=False
    )
    
    # Decode result
    result = tokenizer.decode(outputs[0], skip_special_tokens=True)
    
    # Post-process if needed (add curly braces if missing)
    if not result.strip().startswith('{') and not result.strip().endswith('}'):
        result = "{" + result + "}"
    
    try:
        return json.loads(result)
    except json.JSONDecodeError as e:
        print(f"JSON parsing failed: {e}")
        print(f"Raw output: {result}")
        return None

# Example usage
prompt = "I want energetic dance music for a party"
features = generate_spotify_features(prompt)
print(features)

Expected Output Format

{
  "danceability": 0.85,
  "energy": 0.90,
  "valence": 0.75,
  "acousticness": 0.15,
  "instrumentalness": 0.05,
  "speechiness": 0.08
}

Training Configuration

  • Epochs: 7
  • Learning Rate: 1e-4
  • Batch Size: 8 (per device)
  • Gradient Accumulation Steps: 2
  • Scheduler: Cosine with warmup
  • Max Length: 256 tokens

Limitations

  • May generate incomplete JSON that requires post-processing
  • Performance depends on similarity to training data
  • Trained on specific prompt format starting with "prompt: "

Model Files

This repository contains:

  • config.json: Model configuration
  • pytorch_model.bin: Model weights
  • tokenizer.json: Tokenizer vocabulary
  • tokenizer_config.json: Tokenizer configuration
  • special_tokens_map.json: Special token mappings

Citation

If you use this model, please cite:

@misc{t5-spotify-features-v1,
  author = {afsagag, synyyy},
  title = {T5-Base Fine-tuned for Spotify Features Prediction},
  year = {2025},
  publisher = {Hugging Face},
  url = {https://huggingface.co/synyyy/t5-spotify-features-v2}
}
Downloads last month
24
Safetensors
Model size
223M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for synyyy/t5-spotify-features-v2

Base model

google-t5/t5-base
Finetuned
(633)
this model