Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

FastEmbed by Qdrant

FastEmbed fromQdrant is a lightweight, fast, Python library built for embedding generation.

  • Quantized model weights
  • ONNX Runtime, no PyTorch dependency
  • CPU-first design
  • Data-parallelism for encoding of large datasets.

Dependencies

To use FastEmbed with LangChain, install thefastembed Python package.

%pip install--upgrade--quiet  fastembed

Imports

from langchain_community.embeddings.fastembedimport FastEmbedEmbeddings
API Reference:FastEmbedEmbeddings

Instantiating FastEmbed

Parameters

  • model_name: str (default: "BAAI/bge-small-en-v1.5")

    Name of the FastEmbedding model to use. You can find the list of supported modelshere.

  • max_length: int (default: 512)

    The maximum number of tokens. Unknown behavior for values > 512.

  • cache_dir: Optional[str] (default: None)

    The path to the cache directory. Defaults tolocal_cache in the parent directory.

  • threads: Optional[int] (default: None)

    The number of threads a single onnxruntime session can use.

  • doc_embed_type: Literal["default", "passage"] (default: "default")

    "default": Uses FastEmbed's default embedding method.

    "passage": Prefixes the text with "passage" before embedding.

  • batch_size: int (default: 256)

    Batch size for encoding. Higher values will use more memory, but be faster.

  • parallel: Optional[int] (default: None)

    If>1, data-parallel encoding will be used, recommended for offline encoding of large datasets.If0, use all available cores.IfNone, don't use data-parallel processing, use default onnxruntime threading instead.

embeddings= FastEmbedEmbeddings()

Usage

Generating document embeddings

document_embeddings= embeddings.embed_documents(
["This is a document","This is some other document"]
)

Generating query embeddings

query_embeddings= embeddings.embed_query("This is a query")

Related


[8]ページ先頭

©2009-2025 Movatter.jp