๐Ÿ“–Advanced Usage

Embedding functions are rarely used alone.

Its used in two way

  • In ETL and Vectordb to convert all the raw data extracted by the ETL into embeddings to be stored in the Vectordb. It also helps in converting the query to embeddings.

  • In Retrieval it converts the user query into an embedding to search against the other data in the vectordb index

Usage

Imports:

from genai_stack.etl.langchain import LangchainETL
from genai_stack.stack.stack import Stack
from genai_stack.vectordb.chromadb import ChromaDB
from genai_stack.etl.utils import get_config_from_source_kwargs
from genai_stack.embedding.utils import get_default_embeddings

Configuration:

config = {
    "name": "HuggingFaceEmbeddings",
    "fields": {
        "model_name": "sentence-transformers/all-mpnet-base-v2",
        "model_kwargs": {"device": "cpu"},
        "encode_kwargs": {"normalize_embeddings": False},
    }
}

Using with ETL

Once you have defined your configuration as a Python dictionary, you can use it with the LangchainEmbedding.from_kwargs() method:

Using with retriever

Last updated