Skip to main content

No project description provided

Project description

STRIVE: Semantic Tokenized Ranking via Vectorization & Embeddings

from strive.reranker import Reranker, EmbeddingType, deduplicate_results

textual_reranker = Reranker(embedding_type=EmbeddingType.textual)
semantic_reranker = Reranker(embedding_type=EmbeddingType.semantic)

# Supports English and Portuguese
corpus = [
    "O presidente anunciou novas políticas econômicas.",
    "Houve exonerações no governo recentemente.",
    "Os nomes dos exonerados ainda não foram divulgados.",
    "O mercado financeiro reagiu positivamente às mudanças.",
    "O congresso discutirá reformas tributárias esta semana."
]

query = "Houveram exonerações? Se sim, cite os nomes."

# Build the index with the given corpus
textual_results = textual_reranker.rerank_documents(query, corpus, top_k=50)
semantic_results = semantic_reranker.rerank_documents(query, corpus, top_k=50)
merged_results = textual_results + semantic_results

# Deduplicate the results
deduplicated_results = deduplicate_results(merged_results, top_k=2)

print(deduplicated_results)
# [('Os nomes dos exonerados ainda não foram divulgados.', 0.30326954502292763), ('Houve exonerações no governo recentemente.', 0.30326954502292763)]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strive_ranker-1.2.tar.gz (784.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strive_ranker-1.2-py3-none-any.whl (782.3 kB view details)

Uploaded Python 3

File details

Details for the file strive_ranker-1.2.tar.gz.

File metadata

  • Download URL: strive_ranker-1.2.tar.gz
  • Upload date:
  • Size: 784.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for strive_ranker-1.2.tar.gz
Algorithm Hash digest
SHA256 64004614a0afdd5b60d73c292c721f0dbb2863eaac2ef0e8e1d57a004c204517
MD5 357879a113b93cba581cdff7e31e16fb
BLAKE2b-256 a8504906fbba69e65e16ff87f45556e26a7705db637fdb4dd43ed5ac6d74cb51

See more details on using hashes here.

File details

Details for the file strive_ranker-1.2-py3-none-any.whl.

File metadata

  • Download URL: strive_ranker-1.2-py3-none-any.whl
  • Upload date:
  • Size: 782.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for strive_ranker-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5f7c1e77363057982768dd99ac68cf58eac4c5109e6ca9b23bea4119b55cc564
MD5 0045d71a4daca9742187b1cd66dde6c0
BLAKE2b-256 796133e6d63b1d0f60ac9d2dad0fcbe02906801b8c0ab45a28b9ecff844d01d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page