Cohereを使用したリランキング
RAGのためにドキュメントを取得する際、初期のベクトル類似性検索では重要なセマンティックマッチを見逃す可能性があります。
Cohereのリランキングサービスは、複数のスコアリング要因を使用してドキュメントを並べ替えることで、結果の関連性を向上させます。
import { rerank } from "@mastra/rag";
const results = rerank(
searchResults,
"deployment configuration",
cohere("rerank-v3.5"),
{
topK: 5,
weights: {
semantic: 0.4,
vector: 0.4,
position: 0.2
}
}
);