VolatileMemoryStore Class
A volatile memory store that stores data in memory.
Note: This class is marked as 'experimental' and may change in the future.
Initializes a new instance of the VolatileMemoryStore class.
Constructor
VolatileMemoryStore()
Methods
| compute_similarity_scores |
Computes the cosine similarity scores between a query embedding and a group of embeddings. |
| create_collection |
Creates a new collection if it does not exist. |
| delete_collection |
Deletes a collection. |
| does_collection_exist |
Checks if a collection exists. |
| get |
Gets a record. |
| get_batch |
Gets a batch of records. |
| get_collections |
Gets the list of collections. |
| get_nearest_match |
Gets the nearest match to an embedding using cosine similarity. |
| get_nearest_matches |
Gets the nearest matches to an embedding using cosine similarity. |
| remove |
Removes a record. |
| remove_batch |
Removes a batch of records. |
| upsert |
Upserts a record. |
| upsert_batch |
Upserts a batch of records. |
compute_similarity_scores
Computes the cosine similarity scores between a query embedding and a group of embeddings.
compute_similarity_scores(embedding: ndarray, embedding_array: ndarray) -> ndarray
Parameters
| Name | Description |
|---|---|
|
embedding
Required
|
<xref:semantic_kernel.memory.ndarray>
The query embedding. |
|
embedding_array
Required
|
<xref:semantic_kernel.memory.ndarray>
The group of embeddings. |
Returns
| Type | Description |
|---|---|
|
<xref:ndarray>
|
The cosine similarity scores. |
create_collection
Creates a new collection if it does not exist.
async create_collection(collection_name: str) -> None
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
The name of the collection to create. |
Returns
| Type | Description |
|---|---|
|
None |
delete_collection
Deletes a collection.
async delete_collection(collection_name: str) -> None
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
The name of the collection to delete. |
Returns
| Type | Description |
|---|---|
|
None |
does_collection_exist
get
Gets a record.
async get(collection_name: str, key: str, with_embedding: bool = False) -> MemoryRecord
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
The name of the collection to get the record from. |
|
key
Required
|
The unique database key of the record. |
|
with_embedding
|
Whether to include the embedding in the result. (default: {False}) Default value: False
|
Returns
| Type | Description |
|---|---|
|
The record. |
get_batch
Gets a batch of records.
async get_batch(collection_name: str, keys: list[str], with_embeddings: bool = False) -> list[MemoryRecord]
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
The name of the collection to get the records from. |
|
keys
Required
|
<xref:List>[str]
The unique database keys of the records. |
|
with_embeddings
|
Whether to include the embeddings in the results. (default: {False}) Default value: False
|
Returns
| Type | Description |
|---|---|
|
The records. |
get_collections
get_nearest_match
Gets the nearest match to an embedding using cosine similarity.
async get_nearest_match(collection_name: str, embedding: ndarray, min_relevance_score: float = 0.0, with_embedding: bool = False) -> tuple[MemoryRecord, float]
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
The name of the collection to get the nearest match from. |
|
embedding
Required
|
<xref:semantic_kernel.memory.ndarray>
The embedding to find the nearest match to. |
|
min_relevance_score
|
The minimum relevance score of the match. (default: {0.0}) Default value: 0.0
|
|
with_embedding
|
Whether to include the embedding in the result. (default: {False}) Default value: False
|
Returns
| Type | Description |
|---|---|
|
The record and the relevance score. |
get_nearest_matches
Gets the nearest matches to an embedding using cosine similarity.
async get_nearest_matches(collection_name: str, embedding: ndarray, limit: int, min_relevance_score: float = 0.0, with_embeddings: bool = False) -> list[tuple[MemoryRecord, float]]
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
The name of the collection to get the nearest matches from. |
|
embedding
Required
|
<xref:semantic_kernel.memory.ndarray>
The embedding to find the nearest matches to. |
|
limit
Required
|
The maximum number of matches to return. |
|
min_relevance_score
|
The minimum relevance score of the matches. (default: {0.0}) Default value: 0.0
|
|
with_embeddings
|
Whether to include the embeddings in the results. (default: {False}) Default value: False
|
Returns
| Type | Description |
|---|---|
|
The records and their relevance scores. |
remove
remove_batch
Removes a batch of records.
async remove_batch(collection_name: str, keys: list[str]) -> None
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
The name of the collection to remove the records from. |
|
keys
Required
|
<xref:List>[str]
The unique database keys of the records to remove. |
Returns
| Type | Description |
|---|---|
|
None |
upsert
Upserts a record.
async upsert(collection_name: str, record: MemoryRecord) -> str
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
The name of the collection to upsert the record into. |
|
record
Required
|
<xref:semantic_kernel.memory.MemoryRecord>
The record to upsert. |
Returns
| Type | Description |
|---|---|
|
The unique database key of the record. |
upsert_batch
Upserts a batch of records.
async upsert_batch(collection_name: str, records: list[MemoryRecord]) -> list[str]
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
The name of the collection to upsert the records into. |
|
records
Required
|
<xref:List>[<xref:MemoryRecord>]
The records to upsert. |
Returns
| Type | Description |
|---|---|
|
The unique database keys of the records. |
Attributes
is_experimental
is_experimental = True
stage_status
stage_status = 'experimental'