Semantic document search
Build semantic search over an application's document collection.
AI Tools · Class
VectorStoreIndex creates a searchable vector index from documents. It chunks documents, embeds the chunks with an embedding model, and stores the embeddings in a vector database.
VectorStoreIndex is imported from the community vectorstores core package and built from documents with fromDocuments. The operation chunks documents, embeds the chunks, and stores the resulting vectors for later similarity retrieval.
VectorStoreIndex.fromDocuments(documents, { embedFunc: vercelEmbedding(embeddingModel) })| Name | Type | Description |
|---|---|---|
documents | Document[] | Documents to index. |
options | { embedFunc: ... } | Options containing the embedding function used to embed document chunks. |
A promise resolving to a vector store index.
import { openai } from '@ai-sdk/openai';
import { vercelEmbedding } from '@vectorstores/vercel';
import { VectorStoreIndex } from '@vectorstores/core';
const documents = [
new Document({ text: 'This is a large document.' }),
];
const index = await VectorStoreIndex.fromDocuments(documents, {
embedFunc: vercelEmbedding(openai.embedding('text-embedding-3-small')),
});Creates an index from documents using a Vercel AI SDK embedding model.
Build semantic search over an application's document collection.
Prepare indexed context for retrieval-augmented generation.
Let an AI agent query a vector database through a retriever tool.
vectorstores providerVectorStoreIndex.fromDocumentsvercelEmbeddingretrieververcelTool