Skip to content

Yi-sir/RAGDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG Demo

简易的RAG Demo,适合个人/组织部署使用。

特性

  • 支持API调用或本地调用大模型
  • 本地调用大模型支持vllmtransformers
  • 支持多用户访问
  • 测试已支持windows和类ubuntu操作系统,macos未测试因为我没有

更多功能持续开发中,欢迎一起建设!

使用方法

# 注意,默认的配置文件使用api调用llm,使用本地权重调用embedding model。使用前可以根据实际状况修改
pip install -r requirements.txt
streamlit run ./app/st_demo.py

参考配置

配置文件:config.json

{
    "llm_config": {
        "model": "spn3/Qwen2.5-72B-Instruct",
        "backend_type": "Api",
        "path": "",
        "api_url": "https://www.sophnet.com/api/open-apis",
        "api_key": ""
    },
    "doc_config": {
        "embedding_model": "bge",
        "embedding_model_path": "./bge-small-zh",
        "split_method": "FixedLength",
        "chunk_length": 512,
        "overlap": 50,
        "database_method": "Faiss",
        "dimension": 512,
        "topk": 1
    }
}

可选参数列表

参数名称 可选项 含义
model - 模型名称
backend_type "api", "local" llm推理方式,"api"为调用api推理,"local"为本地推理,暂时支持vllmtransformers
path - 本地模型权重文件路径。当backend_typelocal时,与model参数拼接送给推理后端
api_url - Api url。当backend_typeapi时,用于初始化client
api_key - Api key。当backend_typeapi时,用户初始化client。会优先从环境变量中读取RAG_GENERATOR_API_KEY,若读不到则读取配置文件
embedding_model "bge" embedding模型名称
embedding_model_path - embedding模型路径。如果模型路径存在则从本地初始化,否则根据模型名称从云端仓库拉取
split_method "fixedlength" 文档切分逻辑,"fixedlength"指按照固定长度切分
chunk_length - split_methodfixedlength时,切分出每个文本块的长度
overlap - split_methodfixedlength时,切分文本块时,相邻块之间重叠的长度
database_method "faiss" embedding向量搜索的方式
dimension - embedding向量长度
topk - 搜索相关文本块时结果的最大数量

说明

对于本地部署VLLMTGILLM框架,本项目通过API调用推理接口的情况:backend_type设置为apiapi_url设置为http://localhost:port/v1api_key置空即可。

本项目依赖streamlit搭建前端页面,而streamlit对多用户数据实现了隔离,所以理论上可以在云端部署,提供给一定规模的组织使用。

对于windows操作系统,临时文件保存在D:/目录下;对于ubuntu操作系统,临时文件保存在/tmp/目录下。请确保对于此目录有读写权限。

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages