← Вернуться к списку

Лучшие практики RAG

Общая архитектура

  1. Вычисление векторов документов и запросов с помощью openai/text-embedding-3-large
  2. Получить Топ-К из векторного магазина (FAISS/Milvus/pgvector)
  3. Повысить рейтинг с cohere/rerank-english-v3
  4. Вставьте фрагменты Top-N в подсказку и позвольте cohere/command-r-plus или Claude сгенерировать окончательный ответ

Встраивание

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]

Шаблон запроса

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}