Skip to content

@anvia/fastembed ​

FastEmbed provides local dense and sparse embedding models for Anvia retrieval workflows. Use it when embeddings should run in your own process instead of crossing a provider API, or when hybrid retrieval needs SPLADE++ sparse vectors.

SupportFirst-party
Version0.3.0
RuntimeESM, Node.js with FastEmbed native runtime support
Peer@anvia/core >=0.7.1 <1.0.0

Install ​

bash
pnpm add @anvia/fastembed @anvia/core

fastembed is already a runtime dependency of the adapter. Model files are downloaded and cached by FastEmbed when first initialized.

Create local embeddings ​

ts
import { createFastEmbedEmbeddingModel } from '@anvia/fastembed'

const embeddings = await createFastEmbedEmbeddingModel()
const vectors = await embeddings.embedTexts([
  'Password reset links expire after 30 minutes.',
  'Enterprise customers receive priority support.',
])

console.log(vectors[0].vector)

Capabilities ​

CapabilityFactoryDefault model
Dense embeddingscreateFastEmbedEmbeddingModel()fast-bge-small-en-v1.5
Sparse passage embeddingscreateFastEmbedSparseEmbeddingModel()prithivida/Splade_PP_en_v1
Sparse query embeddingsFastEmbedSparseEmbeddingModel.embedQuery()Same sparse model
Remote provider callNoRuns locally

Sparse passage and query encoders are intentionally separate methods. Use them with a hybrid-capable store such as Qdrant; do not substitute passage encoding for query encoding.

Common patterns ​

Choose another dense model ​

ts
const embeddings = await createFastEmbedEmbeddingModel({
  model: 'fast-bge-base-en-v1.5',
  maxBatchSize: 32,
  initOptions: {
    cacheDir: './.cache/fastembed',
    showDownloadProgress: false,
  },
})
ts
import { createFastEmbedSparseEmbeddingModel } from '@anvia/fastembed'

const sparse = await createFastEmbedSparseEmbeddingModel()
const [passage] = await sparse.embedTexts(['A document to index'])
const query = await sparse.embedQuery('What should I retrieve?')

Use the same dense model, sparse model, and preprocessing rules for ingestion and retrieval. Changing models can change vector dimensions or meaning and usually requires reindexing.

Compatibility ​

@anvia/fastembed wraps the fastembed package and exposes small runtime interfaces for dependency injection and testing. Availability of native execution providers depends on the target operating system and FastEmbed runtime. This adapter is intended for Node.js/server workloads rather than browser delivery.

Continue ​

Built for Anvia.