FastChat icon indicating copy to clipboard operation
FastChat copied to clipboard

Vicuna & langchain ??

Open Chetan8000 opened this issue 2 years ago • 8 comments

Is there any possibility of integrating Vicuna with Lanchain. Both Vicuna and Lanchain, I believe that integrating these two powerful tools would greatly enhance their capabilities and provide users with a seamless and efficient experience

Chetan8000 avatar Apr 12 '23 07:04 Chetan8000

You can integrate to the Langchain Agent API yourself through a Custom LLM Agent, plus some custom inference code to get the right behavior. I've just implemented it here as an example: https://github.com/paolorechia/learn-langchain/tree/main

I don't think there are currently any endpoints out there exposing to retrieve Vicuna's embeddings to integrate with other use cases though.

paolorechia avatar Apr 18 '23 21:04 paolorechia

Thanks to the openai API, it's quite easy to integrate with langchain. A little difference is langchain could use mulit str as 'stop' param, while in fschat it's a single str. langchain would use a 2element list stop in some ReAct task, it's broken in fschat.

stop string or array Optional Defaults to null Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

llama-assistant avatar Apr 19 '23 05:04 llama-assistant

@oreo-yum You are absolutely correct. Which is why I had to implement a custom inference code, so I could process the stop tokens appropriately.

It was basically forked from the fschat streaming endpoint - maybe a solution is to add a new endpoint to the fschat API, that is compatible with the langchain ReAct agent framework?

paolorechia avatar Apr 19 '23 05:04 paolorechia

We add an experimental OpenAI compatible API - https://github.com/lm-sys/FastChat#openai-compatible-restful-apis--sdk. Would this be helpful?

suquark avatar Apr 19 '23 07:04 suquark

I tried a project lanchain-ChatGLM,its emmbedding is text2vec. Using both text2vec & LLM(chatglm), the chatbot can answer user's question according to the text materials uploaded by users. So I think maybe it can also use vicuna as LLM, and it will make greater effect

zp2459 avatar Apr 26 '23 06:04 zp2459

I did something similar here, but using a sentence transformer for the embeddings:

https://github.com/paolorechia/learn-langchain/blob/main/langchain_app/agents/answer_about_germany.py

Unfortunately I have not yet added installation instructions, but I’ll do eventually, so anyone can try it.

I tried using Vicuna embeddings directly, but they didn’t perform well (at least not with my code), so I’d recommend using a different model for the embeddings part for now.

paolorechia avatar Apr 26 '23 07:04 paolorechia

@paolorechia That's great! We could select embeddings based on https://huggingface.co/spaces/mteb/leaderboard. As the OpenAI model text-embedding-ada-002 is also listed, we could find some open source models with similar performance, by ranking by specified metric. By retrieval task might be a good choice for RetrievalQA in langchian.

llama-assistant avatar Apr 27 '23 04:04 llama-assistant

https://github.com/AlenVelocity/langchain-llama

shubham8550 avatar Apr 29 '23 02:04 shubham8550

An example for integrating vicuna with llama-index[0.6.6] and langchain by using OpenAI-Compatible RESTful APIs & SDK.

https://github.com/yjcyxky/chat-publications/blob/main/chatbot_vicuna.py

yjcyxky avatar May 14 '23 15:05 yjcyxky

An example for integrating vicuna with llama-index[0.6.6] and langchain by using OpenAI-Compatible RESTful APIs & SDK.

https://github.com/yjcyxky/chat-publications/blob/main/chatbot_vicuna.py

404?

cliu701 avatar May 14 '23 22:05 cliu701

see https://github.com/lm-sys/FastChat/pull/1246

merrymercy avatar May 15 '23 00:05 merrymercy

An example for integrating vicuna with llama-index[0.6.6] and langchain by using OpenAI-Compatible RESTful APIs & SDK.↳ https://github.com/yjcyxky/chat-publications/blob/main/chatbot_vicuna.py

404?

Sorry, I forgot that it's private repo. I have changed it to public.

yjcyxky avatar May 15 '23 03:05 yjcyxky

You can use vicuna/wizardlm etc. in h2oGPT that has LangChain support: https://github.com/h2oai/h2ogpt

pseudotensor avatar May 19 '23 21:05 pseudotensor

closed by #1246

merrymercy avatar May 20 '23 14:05 merrymercy