Skip to content

Introduction

The embedding function in VectorStores is responsible for creating numerical representations of text. This can be configured through Settings.embedFunc.

The embedFunc is a simple async function that takes text input and returns embedding vectors. You can configure it globally via Settings:

import { Settings, TextEmbedFunc } from "@vectorstores/core";
// Define your embedding function
const myEmbedFunc: TextEmbedFunc = async (input) => {
// Your embedding logic here
// Returns Promise<number[][]> - an array of embeddings
};
// Set it globally
Settings.embedFunc = myEmbedFunc;

For OpenAI embeddings, you can use the OpenAI instructions.

For local embeddings, you can use the HuggingFace instructions.