FastEmbed
Public exports from @anvia/fastembed.
Import from @anvia/fastembed.
DEFAULT_FASTEMBED_EMBEDDING_MODEL
const DEFAULT_FASTEMBED_EMBEDDING_MODEL = "fast-bge-small-en-v1.5";Purpose: default FastEmbed model id used by FastEmbedEmbeddingModel.create(...).
Return behavior: constant string.
Notable errors: none directly.
FastEmbed Types
type FastEmbedEmbeddingModelName =
| "fast-all-MiniLM-L6-v2"
| "fast-bge-base-en"
| "fast-bge-base-en-v1.5"
| "fast-bge-small-en"
| "fast-bge-small-en-v1.5"
| "fast-bge-small-zh-v1.5"
| "fast-multilingual-e5-large";
type FastEmbedRuntime = {
embed(texts: string[], batchSize?: number): AsyncIterable<number[][]>;
};
type FastEmbedEmbeddingModelOptions = {
model?: FastEmbedEmbeddingModelName;
maxBatchSize?: number;
initOptions?: {
executionProviders?: ExecutionProvider[];
maxLength?: number;
cacheDir?: string;
showDownloadProgress?: boolean;
modelName?: string;
};
};Purpose: local FastEmbed model configuration and runtime contract.
Return behavior: consumed by the embedding model.
Notable errors: invalid runtime output causes embedding calls to throw.
FastEmbedEmbeddingModel
class FastEmbedEmbeddingModel implements EmbeddingModel {
readonly model: string;
readonly maxBatchSize: number;
constructor(runtime: FastEmbedRuntime, options?: FastEmbedEmbeddingModelOptions);
static create(options?: FastEmbedEmbeddingModelOptions): Promise<FastEmbedEmbeddingModel>;
embedTexts(texts: string[]): Promise<Embedding[]>;
}Purpose: local FastEmbed adapter for Anvia embeddings.
Return behavior: create(...) initializes FastEmbed; embedTexts(...) returns one embedding per text.
Notable errors: rejects if model loading fails, runtime output shape is invalid, or the embedding count does not match input length.
createFastEmbedEmbeddingModel
function createFastEmbedEmbeddingModel(
options?: FastEmbedEmbeddingModelOptions,
): Promise<FastEmbedEmbeddingModel>;Purpose: convenience wrapper around FastEmbedEmbeddingModel.create(...).
Return behavior: resolves a ready embedding model.
Notable errors: same as FastEmbedEmbeddingModel.create(...).
