# AGIDemo **Repository Path**: pang_da_hai/agidemo ## Basic Information - **Project Name**: AGIDemo - **Description**: 在大模型学习过程中积累的代码片段 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: https://blog.biubiu123.online/search?term=*&sortBy=2&showHighlights=false - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-08-23 - **Last Updated**: 2024-10-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: AGI, prompt, RAG, LlamaIndex, langchain ## README # AGIDemo #### 介绍 在大模型学习过程中积累的代码片段 #### 安装教程 我测试的Python环境是 3.11.9 **First** 创建 Python 3.11.9 的环境 ```shell conda create -n python3119 python=3.11.9 conda activate python3119 ``` **Second** 下载代码,并安装python库 ```shell git clone git@gitee.com:pang_da_hai/agidemo.git cd agidemo pip install -r requirements.txt ``` **环境变量的使用** 使用了 load_dotenv(find_dotenv()) 加载环境变量,.env 文件放在项目根目录即可。 目前.env文件设置的参数项如下: ``` # OPENAI 的API KEY,可以直接是官网的,也可以是三方API转发平台的 OPENAI_API_KEY=********** # 我这里用的 [devcto](https://devcto.com/) 的三方API转发平台的地址,如果是官网地址自行替换 OPENAI_BASE_URL=https://api.fe8.cn/v1 # 在用 llamaIndex 的时候需要用到此配置,同上逻辑 OPENAI_API_BASE=https://api.fe8.cn/v1 # 百度千帆的APPID、API_KEY、SECRET_KEY BAIDU_APPID=999999999 QIANFAN_AK=**************** QIANFAN_SK=*************** # 用 LLAMA_CLOUD 的时候,会用到的API_KEY的配置, 自行去 [llama cloud](https://cloud.llamaindex.ai/landing) 申请 LLAMA_CLOUD_API_KEY=**************** ``` **模型下载** 如果要在国内下载Hugging Face上的模型会比较慢,可以用国内的模型镜像。如:[modelscope](https://modelscope.cn/home) ```shell pip install modelscope modelscope download --model Xorbits/bge-base-en-v1.5 --local_dir ./models/Xorbits/bge-base-en-v1.5 ``` 通过 llamaIndex 直接下载 ```shell pip install llama-index-embeddings-huggingface ``` 在代码中如下,程序会自动下载,默认路径:~/cache/ ```python from llama_index.embeddings.huggingface import HuggingFaceEmbedding embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-base-en-v1.5") ``` 通过 HuggingFace cli 直接下载 ```shell pip install -U huggingface_hub # 基本用法 huggingface-cli download --resume-download BAAI/bge-base-en-v1.5 --local-dir ./models/BAAI/bge-base-en-v1.5 # 下载数据 huggingface-cli download --resume-download --repo-type dataset lavita/medical-qa-shared-task-v1-toy ``` #### 使用说明 1. Demo 代码均放在code目录 2. 下载模型放在models目录,但是因为模型太大,就不再这里上传了 3. 演示数据集放在data目录 #### 参与贡献 期待您的加入 #### 特技 1. You can use [README](https://gitee.com/pang_da_hai/agidemo/blob/master/README.en.md) to support different languages. 2. 官方博客 [blog.biubiu123.online](https://blog.biubiu123.online/search?term=*&sortBy=2&showHighlights=false)