SAP HANA Cloud Vector Engine is a vector store fully integrated into the SAP HANA Cloud
database.
langchain-hana
external integration package, as well as the other packages used throughout this notebook.
HanaDB
vector store, you need a database connection and an embedding instance. SAP HANA Cloud Vector Engine supports both external and internal embeddings.
VECTOR_EMBEDDING()
function. To enable this, create an instance of HanaInternalEmbeddings
with your internal model ID and pass it to HanaDB
. Note that the HanaInternalEmbeddings
instance is specifically designed for use with HanaDB
and is not intended for use with other vector store implementations. For more information about internal embedding, see the SAP HANA VECTOR_EMBEDDING Function.
Caution: Ensure NLP is enabled in your SAP HANA Cloud instance.
HanaDB
along with a table name for storing vectors:
Maximal marginal relevance
optimizes for similarity to query AND diversity among selected documents. The first 20 (fetch_k) items will be retrieved from the DB. The MMR algorithm will then find the best 2 (k) matches.
create_hnsw_index
function.
For more information about creating an index at the database level, please refer to the official documentation.
L2
distance), you need to specify it when initializing the HanaDB
instance.create_hnsw_index
function, if the user does not provide custom values for parameters like m
, ef_construction
, or ef_search
, the default values (e.g., m=64
, ef_construction=128
, ef_search=200
) will be used automatically. These values ensure the index is created with reasonable performance without requiring user intervention.Operator | Semantic |
---|---|
$eq | Equality (==) |
$ne | Inequality (!=) |
$lt | Less than (<) |
$lte | Less than or equal (<=) |
$gt | Greater than (>) |
$gte | Greater than or equal (>=) |
$in | Contained in a set of given values (in) |
$nin | Not contained in a set of given values (not in) |
$between | Between the range of two boundary values |
$like | Text equality based on the “LIKE” semantics in SQL (using ”%” as wildcard) |
$contains | Filters documents containing a specific keyword |
$and | Logical “and”, supporting 2 or more operands |
$or | Logical “or”, supporting 2 or more operands |
$ne
, $gt
, $gte
, $lt
, $lte
$between
, $in
, $nin
$like
$contains
$and
, $or
VEC_TEXT
, which contains the text of the DocumentVEC_META
, which contains the metadata of the DocumentVEC_VECTOR
, which contains the embeddings-vector of the Document’s textNCLOB
or NVARCHAR
for the text/context of the embeddingsNCLOB
or NVARCHAR
for the metadataREAL_VECTOR
for the embedding vector