Skip to Content
RAG埋め込みCohereでテキストを埋め込む

Cohereでテキストを埋め込む

他の埋め込みプロバイダーを利用する場合、選択したモデルの仕様に合ったベクトルを生成する方法が必要です。embedメソッドは複数のプロバイダーをサポートしており、さまざまな埋め込みサービスを切り替えて利用できます。この例では、Cohereの埋め込みモデルを使って埋め込みを生成する方法を示します。

import { cohere } from "@ai-sdk/cohere"; import { MDocument } from "@mastra/rag"; import { embedMany } from "ai"; const doc = MDocument.fromText("Your text content..."); const chunks = await doc.chunk(); const { embeddings } = await embedMany({ model: cohere.embedding("embed-english-v3.0"), values: chunks.map((chunk) => chunk.text), });





GitHubで例を見る