Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use QueryEmbedding in benchmark
Doesn't affect the benchmark much because the previously mocked embedding function
already just returned the vector.
  • Loading branch information
philippgille committed Mar 17, 2024
commit fa24a8a6d352fb90013feb38d97ef2b2da370462
11 changes: 4 additions & 7 deletions collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,13 @@ func benchmarkCollection_Query(b *testing.B, n int, withContent bool) {
}
// Most embeddings are normalized, so we normalize this one too
qv = normalizeVector(qv)
embeddingFunc := func(_ context.Context, text string) ([]float32, error) {
if text != "foo" {
return nil, errors.New("embedding func not expected to be called")
}
return qv, nil
}

// Create collection
db := NewDB()
name := "test"
embeddingFunc := func(_ context.Context, text string) ([]float32, error) {
return nil, errors.New("embedding func not expected to be called")
}
c, err := db.CreateCollection(name, nil, embeddingFunc)
if err != nil {
b.Fatal("expected no error, got", err)
Expand Down Expand Up @@ -524,7 +521,7 @@ func benchmarkCollection_Query(b *testing.B, n int, withContent bool) {
// Query
var res []Result
for i := 0; i < b.N; i++ {
res, err = c.Query(ctx, "foo", 10, nil, nil)
res, err = c.QueryEmbedding(ctx, qv, 10, nil, nil)
}
if err != nil {
b.Fatal("expected nil, got", err)
Expand Down