Implementing an Enterprise Recommendation System

AJ Gadgil4 May 2022

Problem

The newsfeed of a high-traffic global website needed personalized recommendations. The API had to answer in under 500 milliseconds, hit a 99.9% availability SLA (at most 1.44 minutes of downtime per day) and keep hosting cost low. The data was thin: about 6800 press releases and 700 featured articles, no shared tags across data sets, and no visitor history or feedback. Visitors were not logged in.

Example from the article: each press release or featured article needed its most similar items from the same corpus, returned through a REST API for the newsfeed.

Solution in brief

Represent each document with TF-IDF, precompute cosine similarity between all documents and keep only the top three neighbours per document. Re-rank them by popularity and freshness, drop items the visitor has seen (tracked in a cookie), and serve the result from a key-value lookup behind a serverless function.

Questions this case answers
  • How to build and serve a content-similarity recommender for a small item catalog when there is no interaction history and no labels, under a tight latency limit and low hosting cost
  • How to monitor the health of an unsupervised similarity model in production when ground-truth labels are unavailable
  • How to ship related-content recommendations for a website newsfeed when there is no user history and no labeled data?
  • How to choose between TF-IDF and neural text embeddings for a small corpus without ground-truth labels?

Tools and methods

  • TF-IDF with cosine similarity — document vectors and pairwise similarity, chosen over SentenceBERT, Doc2Vec and FastText
  • Popularity and freshness re-ranking — pageviews from Google Analytics and document age, normalized and weighted
  • Browser cookie — recently viewed item IDs
  • Amazon DynamoDB — lookup table: content ID to its top three content IDs
  • AWS Lambda — serverless API, pay per call, scales automatically
  • Python scripts on EC2 — scheduled hourly build that refreshes the table
Continue reading — it's free

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