Skip to content

Instantly share code, notes, and snippets.

View feuyeux's full-sized avatar
♠️

Lu Han feuyeux

♠️
View GitHub Profile
@feuyeux
feuyeux / rag_sample_using_langchain_N_ray.md
Last active February 22, 2024 15:54
RAG sample using Langchain and Ray

https://github.com/ray-project/langchain-ray这个仓库展示了3个ray和langchain结合的示例,包括源代码、视频讲解、博客文档,对快速认知这两个工具及如何结合使用,非常有帮助。(但不知道出于什么原因,仅不到一年,这个仓库的状态已经是Public archive了。)

让我很有印象的是RAG应用示例。

首先是特征向量化过程(Embedding/Vector Store)。Ray Data提供了并行处理数据能力,将原始PDF文件向量化后存储/索引到FAISS。这个过程如果单纯使用langchain实现,这个过程是小时级的;而引入ray data后这个过程是分钟级的。

embedding-why-do-I-need-to-parallelize-this

embedded-stages-of-our-pipeline

@feuyeux
feuyeux / Hello ReAct.md
Created February 28, 2024 03:55
ReAct Sample
prompt = hub.pull("hwchase17/react")
llm = OpenAI()
tools = load_tools(["serpapi", "llm-math"], llm=llm)

agent = create_react_agent(llm, tools, prompt)

agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
agent_executor.invoke({"input": "How many seconds are in 1:23:45"})