yogeshhk / Sarvadnya

This repo is a collection of various PoCs (Proof-of-Concepts) to interface custom data using LLMs.
MIT License
51 stars 22 forks source link

Reranking #58

Open yogeshhk opened 9 months ago

yogeshhk commented 9 months ago

Employ a bit advance techniques for segmentation and reranking in 'ask_bharat' bot.

Reference can be https://lightning.ai/lightning-ai/studios/document-search-and-retrieval-using-rag?view=public&section=recent

yogeshhk commented 6 months ago

Instead of from langchain.llms import HuggingFaceHub you may need from langchain_community.llms import HuggingFaceEndpoint Instead of from langchain.chains import LLMChain you may need LCEL way

# Old Code (using LLMChain)
from langchain.chains import LLMChain
from langchain_openai import OpenAI

prompt = "Write a poem about a cat"
llm_chain = LLMChain(prompt=prompt, llm=OpenAI())
result = llm_chain.invoke()

# New Code (using RunnableSequence)
from langchain_openai import OpenAI

prompt = "Write a poem about a cat"
llm = OpenAI()
result = prompt | llm