Skip to main content

Command Palette

Search for a command to run...

Design Instagram Feed using Generative AI

System design interview

Updated
2 min read
Design Instagram Feed using Generative AI

At PrincipleAI, we stay one step ahead on all things AI, so you don’t have to worry. We bring you handpicked AI-related news and technical deep dives. Our most popular series is about system design. In this post, we are going to design an Instagram-like feed using generative AI.

Introduction

The real world AI deployments are complex. We have done a video teaching the basics of such deployment here. But these days interviewers ask questions to get a sense of your knowledge about generative AI.

We need to design an Instagram-like feed using generative AI. In this task, a user should see posts ranked in a way that encourages more engagement. The user follows their friends on the platform, so we need to include all relevant posts from them. We also need to mix in trending posts from across the platform that align with the user's personal interests. We determine these interests based on the user's actions within the app.

Solution

The solution has two parts. First, we need to store the user's potential posts in the database, which we keep in a vector database. We also store trending posts in the same database. When it's time to generate the feed, we query the vector database to get a list of posts.

The second part of the solution is ranking. This is done by the model. Since we use a large language model, we treat the model's logic as a black box. We can use multi-shot prompting to explain to the LLM the types of posts the user has interacted with and ask the model to rank the given set of posts based on that information.

Video