From ada5859d4da1b60cad48a7c42396afa4a167870f Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 18 Feb 2024 12:15:58 -0800 Subject: [PATCH] Updated readme [skip ci] --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8cb8e12..7b791eb 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ await using (var cmd = new NpgsqlCommand("SELECT * FROM items ORDER BY embedding Add an approximate index ```csharp -await using (var cmd = new NpgsqlCommand("CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 100)", conn)) +await using (var cmd = new NpgsqlCommand("CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)", conn)) { await cmd.ExecuteNonQueryAsync(); } @@ -168,9 +168,9 @@ foreach (Item item in items) Add an approximate index ```csharp -conn.Execute("CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 100)"); -// or conn.Execute("CREATE INDEX ON items USING hnsw (embedding vector_l2_ops)"); +// or +conn.Execute("CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 100)"); ``` Use `vector_ip_ops` for inner product and `vector_cosine_ops` for cosine distance @@ -273,16 +273,16 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() .HasIndex(i => i.Embedding) - .HasMethod("ivfflat") + .HasMethod("hnsw") .HasOperators("vector_l2_ops") - .HasStorageParameter("lists", 100); + .HasStorageParameter("m", 16) + .HasStorageParameter("ef_construction", 64); // or modelBuilder.Entity() .HasIndex(i => i.Embedding) - .HasMethod("hnsw") + .HasMethod("ivfflat") .HasOperators("vector_l2_ops") - .HasStorageParameter("m", 16) - .HasStorageParameter("ef_construction", 64); + .HasStorageParameter("lists", 100); } ```