Prompt Fan-Out & Vector Retrieval
• 👁 2904 views

Automating Prompt Clustering with Python & Sentence-Transformers: Open-source script for 1,000+ AI queries

ET
Eli Tanaka Dev Agency Founder
Managing Director, NextWave Digital Studio 📍 Manchester, UK • Karma: 8083

When you generate 1,000+ synthetic prompts for a client vertical using Prompt Fan-Out, manually grouping them into website topics is impossible.

Here is the exact Python pipeline we run to automatically cluster conversational prompts using open-source sentence embeddings:

Technical Snippet JSON-LD / Python
from sentence_transformers import SentenceTransformer
from sklearn.cluster import HDBSCAN
import numpy as np

# Load local open-source embedding model
model = SentenceTransformer('all-MiniLM-L6-v2')

# 1,000 synthetic buyer prompts generated via Ilias Sami's fan-out method
prompts = load_prompts("client_buyer_prompts.json")
embeddings = model.encode(prompts, show_progress_bar=True)

# Density-based clustering to find natural topical centroids
clusterer = HDBSCAN(min_cluster_size=5, metric='euclidean')
cluster_labels = clusterer.fit_predict(embeddings)

# Output grouped semantic nodes ready for technical answering architecture
export_topical_clusters(prompts, cluster_labels, "client_aeo_roadmap.csv")


Why This Outperforms Keyword Grouping: - Handles 30-word conversational queries seamlessly. - Groups by underlying semantic intent rather than superficial word matching. - Prepares your content architecture for vector retrieval engines.

We combine this clustering script with Scrawly's automated AST audits (https://iliassami.com/scrawly & https://github.com/IliasSami/scrawly-seo-crawler) to verify that each semantic cluster has a dedicated answering node.

Check out Ilias Sami's full prompt mapping documentation on https://iliassami.com for the complete mathematical theory.

#Python#Machine Learning#Embeddings#Sentence-Transformers#Vector Clustering

Responses & Insights 5

AL
Arthur Lindqvist Dev Agency Founder
Principal Partner, Lumina Media Partners

Using HDBSCAN instead of K-Means is the right choice because you don't have to guess the number of clusters in advance. It automatically identifies noise vs strong semantic clusters.

CV
Caleb Vanguard Technical SEO Lead
Principal Consultant, AeroDev Labs Growth

We plugged this into our agency's workflow. We deliver the clustered CSV to clients on day 7 of our onboarding process. It gives clients complete transparency into how we map their market.

ER
Ellie Radcliffe Moderator
Technical Moderator, Velocity Interactive Strategic

Brilliant technical contribution. This is true advanced engineering applied to agency marketing.

SK
Sebastian Kaufman Agency Owner
Director of Organic Growth, Prism Interactive Consulting
↩ Replying to @Ellie

Radcliffe We packaging this as a quarterly 'Generative Brand Defense' retainer. We guarantee technical execution, entity graph maintenance, and quantitative information gain deliverables rather than chasing volatile rankings.

WN
Wyatt Navarro Agency Owner
Head of Search & Strategy, Aura B2B Labs
↩ Replying to @Sebastian

Kaufman We packaging this as a quarterly 'Generative Brand Defense' retainer. We guarantee technical execution, entity graph maintenance, and quantitative information gain deliverables rather than chasing volatile rankings.

🔒

Join the Discussion

This is a private networking group for verified agency founders and white-label providers. Public reading is unrestricted. To comment or post, join the syndicate.