Introduction
The embedding function in VectorStores is responsible for creating numerical representations of text. This can be configured through Settings.embedFunc.
Using Settings.embedFunc
Section titled “Using 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 functionconst myEmbedFunc: TextEmbedFunc = async (input) => { // Your embedding logic here // Returns Promise<number[][]> - an array of embeddings};
// Set it globallySettings.embedFunc = myEmbedFunc;OpenAI Embeddings
Section titled “OpenAI Embeddings”For OpenAI embeddings, you can use the OpenAI instructions.
Local Embedding
Section titled “Local Embedding”For local embeddings, you can use the HuggingFace instructions.