CsabaConsulting / ThruThinkCohereWeaviateChat

Cohere and Weaviate powered ThruThink support chat on Streamlit
https://thruthinksupport.streamlit.app/
MIT License
1 stars 3 forks source link

Use cohere re-ranker after we got the reranked list of the fused documents #7

Closed MrCsabaToth closed 9 months ago

MrCsabaToth commented 9 months ago

This could easily be an extra step between the final RAG preparation and the fusion reranking. See https://github.com/pinecone-io/examples/blob/master/learn/generation/better-rag/00-rerankers.ipynb

import cohere

os.environ["COHERE_API_KEY"] = os.getenv("COHERE_API_KEY") or getpass.getpass()
co = cohere.Client(os.environ["COHERE_API_KEY"])
rerank_docs = co.rerank(
    query=query, documents=docs.keys(), top_n=25, model="rerank-english-v2.0"
)
MrCsabaToth commented 9 months ago

We can use the reranker to enhance the augmentation for both the document and the connector RAG queries.