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