More on our AI future: building course recommendations and a new data platform

29 May 2023

Problem

Stack Overflow wanted to show developers online courses as native ads, matched to the questions they read. The catalog was a couple of thousand courses, the content was 23 million questions, and there were no click labels to train a ranking model on. The data platform was being built at the same time. Each question page and each user needed a course to show, including users who had not opted in to targeted ads.

Example from the article: a user who viewed ten posts gets one profile, the element-wise average of those ten post embeddings.

Solution in brief

Embed questions and courses with a pre-trained sentence model and match them by cosine distance. A user profile is the element-wise mean of the embeddings of the posts the user viewed. Recommendations are pre-computed in batch and written to a SQL database. The ad server picks user-based, then post-based, then a top-courses fallback.

Questions this case answers
  • How to recommend catalog items from text similarity when no click labels exist yet and the catalog is small
  • How to build a personalized recommendation from a user's reading history while keeping a non-personalized fallback for users without history or consent
  • How to recommend external content, such as online courses, to visitors based on the posts they read?
  • How to personalize recommendations from a user's viewing history without training a model on clicks?

Tools and methods

  • Sentence Transformers (BERT) — embeddings of questions and courses
  • Nearest-neighbor search (brute force) — match courses to posts and to user profiles
  • Mean pooling — one embedding per user from the posts they viewed
  • Databricks, PySpark, feature store, MLflow Model Registry, Delta tables — embedding jobs, storage, model versioning
  • Azure SQL Server — low-latency store the ad server reads from
  • dbx and GitHub Actions — parametrized workflows and builds
Continue reading — it's free

Google or a one-time email code. No password.