Skip to main content

LangChain integration for ZeroEntropy zerank rerankers

Project description

langchain-zeroentropy

LangChain document compressor that reranks retrieved results using ZeroEntropy zerank models.

Installation

pip install langchain-zeroentropy

Usage

from langchain_zeroentropy import ZeroEntropyRerank
from langchain.retrievers import ContextualCompressionRetriever

compressor = ZeroEntropyRerank(model="zerank-1-small", top_n=3)

compression_retriever = ContextualCompressionRetriever(
    base_compressor=compressor,
    base_retriever=your_retriever,
)

docs = compression_retriever.invoke("what is the rebate on electronics?")

Set your API key via the ZEROENTROPY_API_KEY environment variable, or pass it directly:

compressor = ZeroEntropyRerank(api_key="ze-...", model="zerank-1-small", top_n=3)

Supported models

Model Notes
zerank-1-small Fast, Apache-2.0 licensed
zerank-1 Higher accuracy

See the ZeroEntropy docs for the full model list and free-tier limits.

Parameters

Parameter Default Description
model zerank-1-small ZeroEntropy reranker model
top_n 3 Number of top documents to return
api_key None API key (falls back to ZEROENTROPY_API_KEY env var)

License

MIT

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

langchain_zerank-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

langchain_zerank-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file langchain_zerank-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_zerank-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for langchain_zerank-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fdd043006debbedcf7b5993679e382fa2393495ab732fcae3ffcbf8ce2fb0ef3
MD5 702693e7b4d4e8fe7898e085bb7952f2
BLAKE2b-256 361a82ed98549288764b76739961000504e9a3b493b3f22e10f8ed662ada5c78

See more details on using hashes here.

File details

Details for the file langchain_zerank-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_zerank-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 840e29ff0949c91007af95bc3f1874502400ee4357a933762773d952d2e25a02
MD5 bf78ffe7608f4e50a3ca5de710e636cd
BLAKE2b-256 a9647e6788955baf356350594bcf158779073fee6a3cef91dd765fced5da4885

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