Skip to content

🔍 Tiny python library for sparse/dense search

License

Notifications You must be signed in to change notification settings

altescy/tinysearch

Repository files navigation

TinySearch

Actions Status GitHub release (latest by date) License

import tinysearch

documents = [
    {"id": "0", "text": "hello there good man !"},
    {"id": "1", "text": "how is the weather today ?"},
    {"id": "2", "text": "it is quite windy in yokohama"},
]

searcher = tinysearch.bm25(documents)
# searcher = tinysearch.tfidf(documents)
# searcher = tinysearch.sif(documents, embeddings="path/to/embeddings.txt")
# searcher = tinysearch.transformer(documents, model_name="bert-base-uncased")

results = searcher.search("weather windy yokohama")
print(results)
# [{'id': '2', 'text': 'it is quite windy in yokohama'},
#  {'id': '1', 'text': 'how is the weather today ?'}]

searcher.save("tinysearch.bin")
searcher = tinyserach.load("tinysearch.bin")