-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lightonai/docs
update-doc
- Loading branch information
Showing
27 changed files
with
399 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
import time | ||
from nltk import download | ||
from nltk.corpus import stopwords | ||
|
||
from ducksearch import evaluation, search, upload | ||
|
||
download("stopwords") | ||
|
||
stopword = list(stopwords.words("english")) | ||
|
||
dataset_name = "quora" | ||
|
||
documents, queries, qrels = evaluation.load_beir( | ||
dataset_name=dataset_name, split="test" | ||
dataset_name=dataset_name, | ||
split="test", | ||
) | ||
|
||
upload.documents( | ||
database=dataset_name, documents=documents, key="id", fields=["title", "text"] | ||
database=dataset_name, | ||
documents=documents, | ||
key="id", | ||
fields=["title", "text"], | ||
stopwords=stopword, | ||
) | ||
|
||
upload.indexes(database=dataset_name) | ||
|
||
|
||
start = time.time() | ||
|
||
scores = search.documents( | ||
database=dataset_name, | ||
queries=queries, | ||
top_k=10, | ||
top_k_token=10_000, | ||
batch_size=30, | ||
top_k_token=30_000, | ||
batch_size=32, | ||
) | ||
|
||
end = time.time() | ||
|
||
print(f"Search took {end - start:.2f} seconds, QPS: {len(queries) / (end - start):.2f}") | ||
|
||
evaluation_scores = evaluation.evaluate( | ||
scores=scores, | ||
qrels=qrels, | ||
queries=queries, | ||
metrics=["ndcg@10", "hits@1", "hits@2", "hits@3", "hits@4", "hits@5", "hits@10"], | ||
metrics=["ndcg@10", "hits@1", "hits@10", "mrr@10", "map@10", "r-precision"], | ||
) | ||
|
||
print(evaluation_scores) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.