Principle:FlagOpen FlagEmbedding Auto Embedding Model Loading
| Field | Value |
|---|---|
| sources | Paper: BGE Embeddings https://arxiv.org/abs/2309.07597, Repo: FlagOpen/FlagEmbedding https://github.com/FlagOpen/FlagEmbedding |
| domains | NLP, Information_Retrieval |
| last_updated | 2026-02-09 00:00 GMT |
Overview
A factory-based pattern that automatically detects and instantiates the appropriate embedding model class based on the model name or explicit model class specification.
Description
Modern embedding libraries support multiple model architectures (encoder-only, decoder-only, multilingual M3, ICL). The auto-loading pattern uses a model registry (mapping model names to configurations) to select the correct class. This avoids requiring users to know implementation details, and provides a single entry point.
In FlagEmbedding, FlagAutoModel.from_finetuned() maps models to one of:
- BaseEmbedder -- encoder-only models (e.g., BAAI/bge-base-en-v1.5)
- M3Embedder -- multilingual dense+sparse+ColBERT models (e.g., BAAI/bge-m3)
- BaseLLMEmbedder -- decoder-only models (e.g., LLM-based embedders)
- ICLLLMEmbedder -- in-context learning models
Usage
When loading any BGE embedding model for inference or evaluation.
Theoretical Basis
The Factory Method design pattern. A class registry (AUTO_EMBEDDER_MAPPING) maps identifiers to concrete classes. The factory supports both auto-detection (from model name matching against known patterns) and explicit specification (via the model_class parameter). This decouples the client code from the specific embedder implementations, allowing new model architectures to be added to the registry without changing the public API.
Related Pages
Implementation:FlagOpen_FlagEmbedding_FlagAutoModel_From_Finetuned