haive.core.engine.embedding.providers.HuggingFaceEmbeddingConfig¶

HuggingFace embedding configuration.

Classes¶

HuggingFaceEmbeddingConfig

Configuration for HuggingFace embeddings.

Module Contents¶

class haive.core.engine.embedding.providers.HuggingFaceEmbeddingConfig.HuggingFaceEmbeddingConfig[source]¶

Bases: haive.core.engine.embedding.base.BaseEmbeddingConfig

Configuration for HuggingFace embeddings.

This configuration provides access to HuggingFace embedding models including sentence transformers and other transformer-based embedding models.

Examples

Basic usage:

config = HuggingFaceEmbeddingConfig(
    name="hf_embeddings",
    model="sentence-transformers/all-MiniLM-L6-v2"
)

embeddings = config.instantiate()

With GPU support:

config = HuggingFaceEmbeddingConfig(
    name="hf_embeddings",
    model="sentence-transformers/all-mpnet-base-v2",
    model_kwargs={"device": "cuda"},
    encode_kwargs={"normalize_embeddings": True}
)

With caching:

config = HuggingFaceEmbeddingConfig(
    name="hf_embeddings",
    model="sentence-transformers/all-MiniLM-L6-v2",
    use_cache=True,
    cache_folder="./embedding_cache"
)
embedding_type¶

Always EmbeddingType.HUGGINGFACE

model¶

HuggingFace model name or path

model_kwargs¶

Additional arguments for model initialization

encode_kwargs¶

Additional arguments for encoding

use_cache¶

Whether to use embedding caching

cache_folder¶

Directory for caching embeddings

get_default_model()[source]¶

Get the default model for HuggingFace embeddings.

Return type:

str

get_model_info()[source]¶

Get information about the configured model.

Return type:

dict

get_supported_models()[source]¶

Get list of popular HuggingFace embedding models.

Return type:

list[str]

instantiate()[source]¶

Create a HuggingFace embeddings instance.

Returns:

HuggingFaceEmbeddings instance configured with the provided parameters

Raises:
  • ImportError – If required packages are not installed

  • ValueError – If configuration is invalid

Return type:

Any

classmethod validate_cache_folder(v, values)[source]¶

Set default cache folder if not specified.

Return type:

Any

validate_configuration()[source]¶

Validate the configuration before instantiation.

Return type:

None

classmethod validate_model(v)[source]¶

Validate the HuggingFace model name.

Return type:

Any

classmethod validate_model_kwargs(v)[source]¶

Validate and set default model kwargs.

Return type:

Any