---
title: "Building a Playlist Generator with Sentence Transformers"
description: "A playlist generator embeds song lyrics with Sentence Transformers and runs semantic search against a text prompt, wrapped in a multi-step Gradio Blocks app on Hugging Face Spaces."
url: "https://swe.quest/articles/building-a-playlist-generator-with-sentence-transformers-68c1a8d1b6166405"
canonical: "https://huggingface.co/blog/playlist-generator"
source: "Hugging Face"
published: "2022-07-13"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["search","machine-learning","python"]
---

# Building a Playlist Generator with Sentence Transformers

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-07-13, 8 min read, How-to. Original: [https://huggingface.co/blog/playlist-generator](https://huggingface.co/blog/playlist-generator)

## Summary

A playlist generator embeds song lyrics with Sentence Transformers and runs semantic search against a text prompt, wrapped in a multi-step Gradio Blocks app on Hugging Face Spaces. Because msmarco-MiniLM-L-6-v3 truncates input at 512 word pieces, songs are split into verses and each verse is embedded and pickled. Searching with top\_k=20 and dropping duplicate songs almost always yields at least 9 distinct songs. In the Gradio app, a button click event runs the search and returns gr.Radio.update() to fill the song choices, so users can then pick a song and read its lyrics.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Python basics ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- sentence embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- pandas

## Keywords

Sentence Transformers, Gradio, Gradio Blocks, Hugging Face Spaces, msmarco-MiniLM-L-6-v3, Hugging Face Hub

## Related posts

- [The 5 Most Under-Rated Tools on Hugging Face](https://swe.quest/articles/the-5-most-under-rated-tools-on-hugging-face-d4091b1b4c6dbb61.md): Hugging Face · 2024-08-22 · Medium · 16 min read · ML platforms, Search, Data pipelines, Python
  Five overlooked Hugging Face Hub features (ZeroGPU, multi-process Docker Spaces, the Gradio API client, Hub webhooks and Nomic Atlas) can be combined into a free, automatically updating semantic search pipeline, demonstrated over a subreddit data source.
- [Image search with 🤗 datasets](https://swe.quest/articles/image-search-with-datasets-7a6fd7ae6c6c63ce.md): Hugging Face · 2022-03-16 · Medium · 12 min read · Vector search, Computer vision, Python, Search
  A text-to-image search over 10,000 British Library book embellishments can be built by loading the images with the 🤗 datasets ImageFolder loader and embedding them with the CLIP ViT-B/32 model via sentence\_transformers.
- [Build a Speech-to-Text App with AssemblyAI on Replit](https://swe.quest/articles/build-a-speech-to-text-app-with-assemblyai-on-replit-b259386c71ff4ae2.md): Replit · 2022-03-29 · Medium · 9 min read · Speech & audio, React, JavaScript, API design
  A Next.js app on Replit transcribes uploaded audio files with AssemblyAI's speech-to-text API.
- [Getting Started With Embeddings](https://swe.quest/articles/getting-started-with-embeddings-f83c278b13779a68.md): Hugging Face · 2022-06-23 · Medium · 11 min read · Search, Machine learning, Python, Vector search
  Embeddings turn text or images into fixed-length vectors that capture meaning, so semantic similarity becomes a distance calculation.
- [Promptim: an experimental library for prompt optimization](https://swe.quest/articles/promptim-an-experimental-library-for-prompt-optimization-2ac32ec5daa6c443.md): LangChain · 2026-11-09 · Easy · 4 min read · LLMs, Evaluation, Developer tools, Open source
  Promptim is an open-source, experimental library that automates prompt engineering: given an initial prompt, a LangSmith dataset and custom evaluators, it runs an optimization loop where a metaprompt proposes edits based on scored train-set results, and keeps a new prompt only if it improves dev-split metrics, repeated N times.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
