iT邦幫忙

2026 iThome 鐵人賽

DAY 9
0

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.


上一篇
Day 11: Building a Stateful AI Workflow with LangGraph
下一篇
Day 13 — How Recommendation Systems Work: From User Preferences to Personalized Results
系列文
從 LLM 到 AI Agent:30 天打造 vLLM × RAG × LangChain 智慧推薦系統15
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言