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.41.tar.gz (48.7 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.41-py3-none-any.whl (48.8 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strive_ranker-2.41.tar.gz
  • Upload date:
  • Size: 48.7 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.41.tar.gz
Algorithm Hash digest
SHA256 a1c9ad240fd2ce9d45b171ccbf6f9b30079c087cfd927383b040fbc0f74691b7
MD5 51a9d7d1b9385c0eaa8477e71f7ad059
BLAKE2b-256 c39454d1b4b0beac257898155a587c6eef04a9780825938a4afd4dd4cd8b8f11

See more details on using hashes here.

File details

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

File metadata

  • Download URL: strive_ranker-2.41-py3-none-any.whl
  • Upload date:
  • Size: 48.8 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.41-py3-none-any.whl
Algorithm Hash digest
SHA256 b725e01d5ba27545b65c5e72c4984432b268338be6e6a75546ce76f43b626267
MD5 24c68207f21c4690df3a813e865b16bb
BLAKE2b-256 4f8bce9157fd27284d27883165627049fb61f3ce48238c9a25308bf825fe8b08

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