Skip to main content

agrag.embedding.base.EmbeddingCache

Bases: ABC

A content-addressed cache for embedding vectors.

normalize is part of the cache key alongside text and model because it changes the vector an embedder produces for the same text and model. Without it, embedders sharing one cache but configured with opposite EmbeddingSettings.normalize values read back the wrong output mode. Any future embedder configuration value that changes output values must join this key in the same way.

Functions:

  • get – Return the cached vector for (text, model, normalize).
  • set – Store vector under (text, model, normalize).

get​

get(*, text:str, model:str, normalize:bool) -> list[float] | None

Return the cached vector for (text, model, normalize).

Returns:

  • list[float] | None – The cached vector, or None on a miss.

set​

set(*, text:str, model:str, normalize:bool, vector:list[float]) -> None

Store vector under (text, model, normalize).