yogeshhk / Sarvadnya

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

Reranking #58

Open yogeshhk opened 7 months ago

yogeshhk commented 7 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 4 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