Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
restore efficientcy
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio committed May 27, 2023
1 parent b4b54ec commit 83ee790
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions semantic_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,13 @@ import (
)

func SemanticSearch(query []string, corpus []string, results int, sorted bool) ([][]typings.SearchResult, error) {
var encodedCorpus [][]float64 = make([][]float64, len(corpus))
var err error
for i, v := range corpus {
encodedCorpus[i], err = vectors.Encode(v)
if err != nil {
return [][]typings.SearchResult{}, err
}
encodedCorpus, err := vectors.EncodeMulti(corpus)
if err != nil {
return [][]typings.SearchResult{}, err
}
var encodedQuery [][]float64 = make([][]float64, len(query))
for i, v := range query {
encodedQuery[i], err = vectors.Encode(v)
if err != nil {
return [][]typings.SearchResult{}, err
}
encodedQuery, err := vectors.EncodeMulti(query)
if err != nil {
return [][]typings.SearchResult{}, err
}

// Semantic search
Expand Down

0 comments on commit 83ee790

Please sign in to comment.