-
Checked other resources
Commit to Help
Example Codefrom vllm import LLM
llm_vllm = LLM(
model="/home/ubuntu/Rag_23ai/Llama-2-7b-chat-hf",
device="cuda", # or "cpu" depending on your setup
)
template = """Answer the question based only on the following context:
{context} Question: {question}
"""
prompt =PromptTemplate.from_template(template)
retriever = knowledge_base.as_retriever()
chain = (
{"context": retriever, "question": RunnablePassthrough()} | prompt | llm_vllm | StrOutputParser()
)
response = chain.invoke(user_question) DescriptionHello, I am using VLLM to use Llama models for RAG purposes. However, I am constantly facing a runnable error. This is my VLLM model initialization: llm_vllm = LLM( When I try to create a chain with: chain = ( I get the following error: TypeError: Expected a Runnable, callable or dict. Instead got an unsupported type: <class 'vllm.entrypoints.llm.LLM'> Similarly, if I use: from langchain.chains.question_answering import load_qa_chain I get an error: llm instance of Runnable expected. System InfoI using an ubuntu machine |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey there, @sadrafh! I'm here to help you out with any issues or questions you have. Let's squash those bugs together! 😊 To resolve the errors and properly integrate VLLM with Langchain for Retrieval-Augmented Generation (RAG) purposes, follow these steps:
By using the |
Beta Was this translation helpful? Give feedback.
Hey there, @sadrafh! I'm here to help you out with any issues or questions you have. Let's squash those bugs together! 😊
To resolve the errors and properly integrate VLLM with Langchain for Retrieval-Augmented Generation (RAG) purposes, follow these steps:
Install the
vllm
package:Ensure that the
vllm
package is installed in your environment:Use the
VLLM
class from LangChain:Instead of directly using the
LLM
class fromvllm
, use theVLLM
class provided by LangChain. Here is an example: