Pgvector 0.1.1
Prefix ReservedSee the version list below for details.
dotnet add package Pgvector --version 0.1.1
NuGet\Install-Package Pgvector -Version 0.1.1
<PackageReference Include="Pgvector" Version="0.1.1" />
paket add Pgvector --version 0.1.1
#r "nuget: Pgvector, 0.1.1"
// Install Pgvector as a Cake Addin #addin nuget:?package=Pgvector&version=0.1.1 // Install Pgvector as a Cake Tool #tool nuget:?package=Pgvector&version=0.1.1
pgvector-dotnet
pgvector support for C#
Supports Npgsql
Getting Started
Run:
dotnet add package Pgvector
And follow the instructions for your database library:
Npgsql
Import the library
using Pgvector.Npgsql;
Create a table
await using (var cmd = new NpgsqlCommand("CREATE TABLE items (embedding vector(3))", conn))
{
await cmd.ExecuteNonQueryAsync();
}
Insert a vector
await using (var cmd = new NpgsqlCommand("INSERT INTO items (embedding) VALUES ($1)", conn))
{
var embedding = new Vector(new float[] { 1, 1, 1 });
cmd.Parameters.AddWithValue(embedding);
await cmd.ExecuteNonQueryAsync();
}
Get the nearest neighbors
await using (var cmd = new NpgsqlCommand("SELECT * FROM items ORDER BY embedding <-> $1 LIMIT 5", conn))
{
var embedding = new Vector(new float[] { 1, 1, 1 });
cmd.Parameters.AddWithValue(embedding);
await using (var reader = await cmd.ExecuteReaderAsync())
{
while (await reader.ReadAsync())
Console.WriteLine((Vector) reader.GetValue(0));
}
}
Add an approximate index
await using (var cmd = new NpgsqlCommand("CREATE INDEX my_index ON items USING ivfflat (embedding vector_l2_ops)", conn))
{
await cmd.ExecuteNonQueryAsync();
}
Use vector_ip_ops
for inner product and vector_cosine_ops
for cosine distance
See a full example
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/pgvector/pgvector-dotnet.git
cd pgvector-dotnet
createdb pgvector_dotnet_test
dotnet test
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Npgsql (>= 7.0.2)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Pgvector:
Package | Downloads |
---|---|
Pgvector.EntityFrameworkCore
pgvector support for Entity Framework Core |
|
Microsoft.KernelMemory.MemoryDb.Postgres
Postgres(with pgvector extension) connector for Microsoft Kernel Memory, to store and search memory using Postgres vector indexing and Postgres features. |
|
Microsoft.SemanticKernel.Connectors.Postgres
Postgres(with pgvector extension) connector for Semantic Kernel plugins and semantic memory |
|
LangChain.Databases.Postgres
Postgres for LangChain. |
|
Pgvector.Dapper
pgvector support for Dapper |
GitHub repositories (5)
Showing the top 5 popular GitHub repositories that depend on Pgvector:
Repository | Stars |
---|---|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
dotnet/eShop
A reference .NET application implementing an eCommerce site
|
|
microsoft/kernel-memory
RAG architecture: index and query any data using LLM and natural language, track sources, show citations, asynchronous memory patterns.
|
|
thangchung/practical-dotnet-aspire
The practical .NET Aspire builds on the coffeeshop app business domain
|
|
Azure-Samples/eShopOnAzure
A variant of https://github.com/dotnet/eShop that uses Azure services
|
Version | Downloads | Last updated |
---|---|---|
0.3.0 | 186,151 | 6/26/2024 |
0.2.0 | 482,656 | 11/24/2023 |
0.2.0-rc.2 | 6,790 | 10/26/2023 |
0.2.0-rc.1 | 748 | 10/14/2023 |
0.1.4 | 97,475 | 9/25/2023 |
0.1.3 | 149,559 | 5/20/2023 |
0.1.2 | 4,620 | 4/25/2023 |
0.1.1 | 68,075 | 3/12/2023 |
0.1.0 | 849 | 3/10/2023 |