Back to Case Studies

Personalised Gift Recommendations from Social Profiles

Embedding Search over Hundreds of Thousands of Products with GPT-4 Pitches

ProductionRetail & E-commerceSep 2023 – Feb 2024NLP, Knowledge Systems & Generative AI
< 0.5 s
Recommendations per user
100Ks
Products in the retail catalogue
1 call
From social profile to ranked gifts
Production
MVP delivered and launched

My Role

Role
Lead; wrote the recommendation service
At CHI Software
Team
Me + 1 engineer + PM
Stage reached
MVP launched in production
Key decisions
  • One API call from profile to pitched products
  • GPT-4 pitches optional and run in parallel
  • Caller-supplied prompt templates, no redeploy needed

Approach at a Glance

Details
  1. 1User Profile Extraction
  2. 2Embeddings
  3. 3Vector Search
  4. 4GPT-4 Pitches
  5. 5Custom Prompts
  6. 6Production Delivery

Executive Summary

The recommendation engine behind a consumer app that suggests gifts for the people in your life. A user connects their social profile, and the app works out what that person cares about from their profile and recent posts, then suggests products from a large retail catalogue, each with a short, personal explanation of why it fits.

One API call does the whole job:

  1. Understand the person: the user's personal info and latest posts are pulled from the database and cleaned up.
  2. Embed: the result is turned into an embedding.
  3. Search: a vector search runs over the embeddings of hundreds of thousands of products.
  4. Pitch: for the best matches, GPT-4 writes a personalised suggestion. This step is optional, and the calls run in parallel.

Recommendations come back in under 0.5 seconds per user. Product teams can also pass their own prompt templates, with placeholders for user and product data, to change the tone or angle of the pitches without a redeploy. I led the project from the RFP to delivery, with one engineer and a PM, and wrote the recommendation service. The MVP was launched in production.


Client Profile

The client was a startup building a gift-ideas app, the first product in a larger vision of personal AI models that understand a person's digital life. For the MVP, the brief was "something working, fast": a working product within a tight timeline, matching people to products from a single large retailer's catalogue.

What made it hard:

  • People aren't search queries: interests have to be inferred from scattered profile details and posts, not typed in.
  • Large, noisy catalogue: hundreds of thousands of product names and descriptions, of uneven quality.
  • Speed: recommendations have to feel instant in a mobile app.
  • Explaining the match: a list of products isn't convincing on its own. Each one needs a reason that refers to the person.

Technical Approach

  1. User Profile Extraction – The API takes an account ID and pulls the user's personal information and their last N posts (10 by default) from the document database, handling missing fields gracefully.

  2. Embeddings – The profile and posts are preprocessed into text and embedded with OpenAI's ada-002 model. Products are embedded the same way from their names, descriptions and categories.

  3. Vector Search – Products are matched by cosine similarity in Azure Cognitive Search, which replaced the first vector store during the project. The top-N products come back with their similarity scores and full product data.

  4. GPT-4 Pitches – For each product, GPT-4 gets the product and the user's posts and writes a short suggestion addressed to that person. Generation is optional and parallelised, so the service stays fast when pitches aren't needed.

  5. Custom Prompts – API clients can send their own system and user prompts with placeholders for user and product data, so the product team can experiment with how recommendations are written.

  6. Production Delivery – Containerised with Docker and deployed on Azure through GitLab CI/CD, with secrets handled in the pipeline and every request and response logged for review.


Business Outcome

The startup got the core of its product: personalised gift ideas generated from a person's social profile, matched against hundreds of thousands of products and returned in under half a second, with a GPT-4 pitch explaining each suggestion. The MVP was delivered and launched in production, and the engagement ended after the MVP phase.

Technologies

OpenAI EmbeddingsGPT-4Vector SearchAzure Cognitive SearchMongoDBPythonDockerGitLab CI/CDAzure

Planning something similar?

Tell me about it on a short call. New projects can start within 2 weeks