← Quay lại danh sách

RAG thực tiễn tốt nhất

Kiến trúc tổng thể

  1. Tính toán các vectơ tài liệu và truy vấn vớiopenai/text-embedding-3-large
  2. Truy xuất Top-K từ kho vector (FAISS / Milvus / pgvector)
  3. Xếp hạng lại vớicohere/rerank-english-v3
  4. Gắn các đoạn Top-N vào dấu nhắc và đểcohere/command-r-plushoặc Claude tạo ra câu trả lời cuối cùng

Nhúng

python
resp = client.embeddings.create(
    model="openai/text-embedding-3-large",
    input=[chunk.text for chunk in chunks],
)
vectors = [d.embedding for d in resp.data]

Mẫu lời nhắc

text
You are an expert assistant. Answer based ONLY on context.
If the answer is not in the context, say "I don't know".

[Context]
{retrieved_chunks}

[Question]
{user_question}