Skip to content

Add customizable metadata field to MemoryRecord and memory retrieval with embeddings is optional#425

Merged
adrianwyatt merged 39 commits intomicrosoft:mainfrom
awharrison-28:semantic_memory_improvements
Apr 13, 2023
Merged

Add customizable metadata field to MemoryRecord and memory retrieval with embeddings is optional#425
adrianwyatt merged 39 commits intomicrosoft:mainfrom
awharrison-28:semantic_memory_improvements

Conversation

@awharrison-28
Copy link
Contributor

@awharrison-28 awharrison-28 commented Apr 12, 2023

Motivation and Context

This PR addresses 3 issues.

  1. MemoryRecord now has a ValueString field - this is to support customizable metadata from the user. It is up to the user to serialize and deserialize this information. Closes MemoryRecord struct is not public visible. This blocks extending the storage system #202
  2. Retrieving the embedding from an IMemoryStore is optional and defaults to false. In the vast majority of cases, it is unnecessary and wasteful to pass the vector around the application, especially over a network. It is primarily used for similarity comparison which performed server-side for vector optimized data stores (ex: Qdrant). Closes MemoryRecord struct is not public visible. This blocks extending the storage system #202
  3. Refactored SqliteMemoryStore so that connections are disposed better. There were multiple cases of residual connections causing intermittent, unexpected unit test behavior. Closes Typo in ConnectAsync (Connectors.Memory.Sqlite/Database.cs) #379, Closes Bad SQLite database name Assignees: kbeaugrand Labels:  #430

Description

  • IMemoryStore Get and GetNearest calls have a new boolean parameter called withEmbedding. This indicates whether or not the response should include the vector associated with the memory. For all existing memory connectors, this defaults to false. This boolean is propagated to ISemanticTextMemory Get and Search calls as well.
  • MemoryRecord has an optional field called valueString to allow the user to supply a custom metadata string. This is field is added to ISemanticTextMemory record creation as well.
  • Connectors.Sqlite.Memory Database is no longer a static class. The connection is supplied by the SqliteMemoryStore which also ensures its proper disposal.
  • Fixed a string interpolation bug in SqliteMemoryStore called out in multiple issues referenced above.
  • Added a few missing XML docs where necessary.
  • Added tests for valueString and withEmbeddings.
  • Some files not included in this PR got picked up with dotnet format and codecleanup

Contribution Checklist

@awharrison-28 awharrison-28 added bug Something isn't working enhancement PR: ready for review All feedback addressed, ready for reviews .NET Issue or Pull requests regarding .NET code labels Apr 12, 2023
shawncal
shawncal previously approved these changes Apr 12, 2023
@shawncal shawncal force-pushed the semantic_memory_improvements branch from 72d7d77 to 8551328 Compare April 12, 2023 21:43
@shawncal shawncal self-requested a review April 12, 2023 21:56
@shawncal shawncal added PR: feedback to address Waiting for PR owner to address comments/questions and removed PR: ready for review All feedback addressed, ready for reviews labels Apr 12, 2023
@adrianwyatt adrianwyatt merged commit fcf986c into microsoft:main Apr 13, 2023
dehoward pushed a commit to lemillermicrosoft/semantic-kernel that referenced this pull request Jun 1, 2023
…with embeddings is optional (microsoft#425)

### Motivation and Context
This PR addresses 3 issues. 

1. MemoryRecord now has a ValueString field - this is to support
customizable metadata from the user. It is up to the user to serialize
and deserialize this information. Closes
microsoft#202
2. Retrieving the embedding from an IMemoryStore is optional and
defaults to false. In the vast majority of cases, it is unnecessary and
wasteful to pass the vector around the application, especially over a
network. It is primarily used for similarity comparison which performed
server-side for vector optimized data stores (ex: Qdrant). Closes
microsoft#202
3. Refactored SqliteMemoryStore so that connections are disposed better.
There were multiple cases of residual connections causing intermittent,
unexpected unit test behavior. Closes
microsoft#379, Closes
microsoft#430

### Description
- `IMemoryStore` `Get` and `GetNearest` calls have a new boolean
parameter called `withEmbedding`. This indicates whether or not the
response should include the vector associated with the memory. For all
existing memory connectors, this defaults to false. This boolean is
propagated to `ISemanticTextMemory` `Get` and `Search` calls as well.
- `MemoryRecord` has an optional field called `valueString` to allow the
user to supply a custom metadata string. This is field is added to
`ISemanticTextMemory` record creation as well.
- Connectors.Sqlite.Memory `Database` is no longer a static class. The
connection is supplied by the `SqliteMemoryStore` which also ensures its
proper disposal.
- Fixed a string interpolation bug in `SqliteMemoryStore` called out in
multiple issues referenced above.
- Added a few missing XML docs where necessary. 
- Added tests for `valueString` and `withEmbeddings`.
- Some files not included in this PR got picked up with `dotnet format`
and `codecleanup`
golden-aries pushed a commit to golden-aries/semantic-kernel that referenced this pull request Oct 10, 2023
…with embeddings is optional (microsoft#425)

### Motivation and Context
This PR addresses 3 issues. 

1. MemoryRecord now has a ValueString field - this is to support
customizable metadata from the user. It is up to the user to serialize
and deserialize this information. Closes
microsoft#202
2. Retrieving the embedding from an IMemoryStore is optional and
defaults to false. In the vast majority of cases, it is unnecessary and
wasteful to pass the vector around the application, especially over a
network. It is primarily used for similarity comparison which performed
server-side for vector optimized data stores (ex: Qdrant). Closes
microsoft#202
3. Refactored SqliteMemoryStore so that connections are disposed better.
There were multiple cases of residual connections causing intermittent,
unexpected unit test behavior. Closes
microsoft#379, Closes
microsoft#430

### Description
- `IMemoryStore` `Get` and `GetNearest` calls have a new boolean
parameter called `withEmbedding`. This indicates whether or not the
response should include the vector associated with the memory. For all
existing memory connectors, this defaults to false. This boolean is
propagated to `ISemanticTextMemory` `Get` and `Search` calls as well.
- `MemoryRecord` has an optional field called `valueString` to allow the
user to supply a custom metadata string. This is field is added to
`ISemanticTextMemory` record creation as well.
- Connectors.Sqlite.Memory `Database` is no longer a static class. The
connection is supplied by the `SqliteMemoryStore` which also ensures its
proper disposal.
- Fixed a string interpolation bug in `SqliteMemoryStore` called out in
multiple issues referenced above.
- Added a few missing XML docs where necessary. 
- Added tests for `valueString` and `withEmbeddings`.
- Some files not included in this PR got picked up with `dotnet format`
and `codecleanup`
golden-aries pushed a commit to golden-aries/semantic-kernel that referenced this pull request Oct 24, 2023
### Motivation and Context

Fix for issue microsoft#425 

The older API version was no longer working. It allows for deploying a
new Azure OpenAI resource.

### Description

Updates the API version and SKU of the Azure OpenAI 

### Contribution Checklist

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [Contribution
Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

---------

Co-authored-by: Gil LaHaye <gillahaye@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working .NET Issue or Pull requests regarding .NET code PR: feedback to address Waiting for PR owner to address comments/questions

Projects

None yet

4 participants