Skip to content

Commit

Permalink
Updated readme [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Feb 18, 2024
1 parent c9c7fed commit ada5859
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -273,16 +273,16 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Item>()
.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<Item>()
.HasIndex(i => i.Embedding)
.HasMethod("hnsw")
.HasMethod("ivfflat")
.HasOperators("vector_l2_ops")
.HasStorageParameter("m", 16)
.HasStorageParameter("ef_construction", 64);
.HasStorageParameter("lists", 100);
}
```

Expand Down

0 comments on commit ada5859

Please sign in to comment.