Skip to content

Instantly share code, notes, and snippets.

View feuyeux's full-sized avatar
♠️

Lu Han feuyeux

♠️
View GitHub Profile
@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"})
@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

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-rsocket</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</exclusion>
<exclusion>
@feuyeux
feuyeux / exclusive_or_self-inverse.java
Last active July 24, 2019 00:01
exclusive_or_self-inverse
// Using exclusive or self-inverse to find the repeated number in an array
// Self-inverse: A ⊕ A = 0
// A XOR B XOR B = A XOR 0 = A
int[] a1 = {1, 2, 3, 3};
int[] a2 = {1, 2, 2, 3};
int x1 = a1[0] ^ a1[1] ^ a1[2] ^ a1[3] ^ 1 ^ 2 ^ 3;
int x2 = a2[0] ^ a2[1] ^ a2[2] ^ a2[3] ^ 1 ^ 2 ^ 3;
System.out.println(x1);
System.out.println(x2);
@feuyeux
feuyeux / test_stream_parallel_forkjoin_threadpool.java
Last active March 12, 2019 12:41
test_stream_parallel_forkjoin_threadpool
@Test
public void test() throws InterruptedException, ExecutionException {
ForkJoinPool customThreadPool = new ForkJoinPool(8);
ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("pool-%d").build();
ThreadPoolExecutor executor = new ThreadPoolExecutor(5, Integer.MAX_VALUE,
1, TimeUnit.MINUTES,
new LinkedBlockingQueue<>(5),
threadFactory,
new ThreadPoolExecutor.AbortPolicy());
╰─○ cat .gitconfig
[user]
name = 六翁
email = lu.hl@***.com
[push]
default = matching
[core]
autocrlf = input
[color]
ui = auto
╰─○ cat .gitconfig
[user]
name = 六翁
email = lu.hl@***.com
[push]
default = matching
[core]
autocrlf = input
[color]
ui = auto
#!/usr/bin/env bash
executingPath=$(pwd)
scriptPath=$(cd $(dirname $0);pwd)
scriptParentPath=$(cd $(dirname $0);cd ..; pwd)
scriptName=$(basename $0)

line=$(printf "%-60s")
echo "${line// /#}"
echo "Executing path : $executingPath"
@feuyeux
feuyeux / jna123.md
Last active September 8, 2016 10:27

jna coding

C

myc.c

#include <stdio.h>
int add(int x, int y)
{
  return x+y;
}

install thrift

brew install thrift

install gvm

zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)