1. 安装python 虚拟环境
安装 Miniconda3
Step 1: 下载
$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
Step2: 运行脚本
$ sh Miniconda3-latest-Linux-x86_64.sh
Step3: 设置环境变量
vi /etc/profile
export PATH="/data/apps/miniconda3/bin:$PATH"
source /etc/profile
Step 4: 卸载
$ rm -rf /data/apps/miniconda3/
创建虚拟环境
//创建
conda create -n test python=3.10
退出shell 重新登录 才生效
//激活
conda activate test
//销毁
conda deactivate test
//查看
conda info --env
2. Vanna 借助 OpenAI, Marqo 生成 MySql SQL语句
2.1. Vanna
三个主要基础设施
- Database,即需要进行查询的关系型数据库
- VectorDB,即需要存放RAG“模型”的向量库
- LLM,即需要使用的大语言模型,用来执行
Text2SQL
任务
2.2. 下载向量数据库marqo
docker pull docker.rainbond.cc/marqoai/marqo:latest
docker run --name marqo -it -p 8882:8882 docker.rainbond.cc/marqoai/marqo:latest
需要服务器翻墙才能从hf上下载下来
open_clip/ViT-B-32/laion2b_s34b_b79k
hf/e5-base-v2
安装marqo客户端
(test) root@ubuntu:/data/scripts# pip install marqo
测试marqo client
(test) root@ubuntu:/data/scripts# cat marqo_test.py
import marqo
mq = marqo.Client(url='http://10.0.2.15:8882')
mq.delete_index("my-first-index")
mq.create_index("my-first-index", model="hf/e5-base-v2")
mq.index("my-first-index").add_documents([
{
"Title": "The Travels of Marco Polo",
"Description": "A 13th-century travelogue describing Polo's travels"
},
{
"Title": "Extravehicular Mobility Unit (EMU)",
"Description": "The EMU is a spacesuit that provides environmental protection, "
"mobility, life support, and communications for astronauts",
"_id": "article_591"
}],
tensor_fields=["Description"]
)
results = mq.index("my-first-index").search(
q="What is the best outfit to wear on the moon?"
)
print(results)
(test) root@ubuntu:/data/scripts#