In the previous days, we used embeddings, FAISS, LangChain, and LangGraph to build a RAG system that finds useful documents before generating an answer. Today, we will use a similar idea for a new task: recommendation. Instead of asking, “Which documents are relevant to this question?”, we will ask, “Which items are most suitable for this user?” Our system will first use embeddings and vector search to find a small set of candidate items, and then use an LLM to rank those candidates based on the user’s preferences. This retrieve-then-rank setup is also used in research on LLM-based recommender systems.
User Preference
↓
Retrieve Candidates
↓
Rerank Candidates
↓
Recommend Items
Here's the folder structure helping us to build up the system:
day12-recommendation/
│
├── data/
│ └── ml-latest-small/
│ ├── movies.csv
│ ├── ratings.csv
│ ├── tags.csv
│ └── links.csv
│
├── build_index.py
├── recommend.py
├── evaluate.py
└── requirements.txt
Conclustion:
Today, we moved from RAG into recommendation systems by reusing the same building blocks we already learned: embeddings, FAISS, LangChain, and LangGraph. The main difference is the goal. In RAG, we retrieve documents that can help answer a question. In recommendation, we retrieve items that may match a user’s interests.
Our recommendation workflow follows a simple pattern:
User Preference
↓
Embedding
↓
FAISS Candidate Retrieval
↓
Candidate Items
↓
Ranking / Reranking
↓
Top Recommendations
The key takeaway is that recommendation can be understood as a retrieve-then-rank problem. First, we quickly find possible candidates. Then, we rank those candidates using more detailed user information. This gives us a practical bridge from vector search and RAG toward more advanced recommendation and agent-based systems.