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 = "danças" # parte de "mudanças"

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

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

print(deduplicated_results)
# [('O mercado financeiro reagiu positivamente às mudanças.', 0.7980238199234009), ('O presidente anunciou novas políticas econômicas.', 0.37016284745050076)]

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-2.34.tar.gz (49.4 MB view details)

Uploaded Source

Built Distribution

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

strive_ranker-2.34-py3-none-any.whl (49.6 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strive_ranker-2.34.tar.gz
  • Upload date:
  • Size: 49.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for strive_ranker-2.34.tar.gz
Algorithm Hash digest
SHA256 94d82b5a58e275d69dbf11f26d387fea2db9a6559dc8ec01695e635850f3ce43
MD5 1c87114880e8230b53c626676d36bb05
BLAKE2b-256 324e504fb5c2f1ccd7665b6f5bf8704fc04277030b781de8750897040984e667

See more details on using hashes here.

File details

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

File metadata

  • Download URL: strive_ranker-2.34-py3-none-any.whl
  • Upload date:
  • Size: 49.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for strive_ranker-2.34-py3-none-any.whl
Algorithm Hash digest
SHA256 9a2d005591571452bc467583231cc88032e64f9789a9d358f76718cddafc52be
MD5 67d61f86d937630079cd02a72ef6324f
BLAKE2b-256 0b9b0bc0db5c2cf3e41c7cb1025892a49150aca684c9c7c75afcbc4489a4687a

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