Retrieval-Augmented Generation
摘要
RAG is a very practical bargain: keep your model small and general, then fetch the facts it needs at query time. In Python, that means three loops wired together cleanly – index, retrieve (then rerank), and compose – with a story for freshness and evaluation. We’ll build the core with sentence-transformers for embeddings, FAISS for indexing (plus notes on ChromaDB, pgvector, and Milvus), add a cross-encoder reranker, and finish with freshness tricks and sharp metrics.