Doing Math with Embeddings for Better AI Ad Targeting (www.ethicalads.io)

🤖 AI Summary
A publisher/ads team updated their content-based ad targeting approach by using deterministic embeddings, domain- and page-level centroids, and Postgres + pgvector with Django to achieve privacy-friendly, scalable contextual targeting. After embedding nearly a million pages they found clear semantic clusters (e.g., Flask vs Django, BeautifulSoup vs Scrapy). Rather than relying on brittle LLM prompts, they average related embeddings to form centroids (mean vectors) that represent pages or domains; new content is classified by measuring cosine distance to those centroids. The stack examples show using Django ORM annotate(Avg("vector")) to build centroids and pgvector.django.CosineDistance to filter domains within a distance threshold (thresholds depend on the embedding model). This matters because it combines the semantic power of embeddings (better than keyword matching) with more deterministic math and explainability that marketers can understand—“we match your ads to domains similar to your landing pages.” It improves campaign scale and performance without tracking users (privacy-preserving), and it naturally scales as more content is embedded, creating a virtuous feedback loop. Key technical takeaways: centroids are effective representations, cosine-distance thresholds control relevance, and Postgres+pgvector+Django is a practical production path for large-scale semantic ad targeting.
Loading comments...
loading comments...