RAGLink是一个开源的Retrieval-Augmented Generation框架,旨在通过结合检索和大模型生成技术,提升自然语言处理任务的性能和效率。为用户提供了一个强大、灵活且易于扩展的开发环境。
Project description
RAGLink
RAGLink是一个开源的Retrieval-Augmented Generation框架,旨在通过结合检索和大模型生成技术,提升自然语言处理任务的性能和效率。为用户提供了一个强大、灵活且易于扩展的开发环境。
🔑核心特性
- 检索增强:通过检索技术,框架能够快速从大量数据中检索相关信息,为生成任务提供上下文支持。
- 生成能力:集成了多种生成大模型,能够根据检索到的信息生成流畅、准确的文本。
- 模块化设计:采用模块化设计,便于开发者根据需求定制和扩展功能。
🗺️集成
向量数据库
- Milvus
- Qdrant
Embeddings模型
- ModelScopeEmbedding
- OpenAIEmbedding
- MiniMaxEmbedding
- DouBaoEmbedding
- HuggingFaceEmbedding
Reranker模型
- bce-embedding-base_v1
📚使用文档
安装说明
可以直接从终端中的pip命令安装RAGLink:
pip install raglink
基本用法
配置 RAGLink
from raglink import RAGLink
# 配置RAGLink
config = {
"vector_store": ……,
"test_splitter": ……,
"embedder": ……,
}
rag = RAGLink.from_config(config)
config 配置
1. 向量数据库配置
milvus:Milvus向量数据库;qdrant:Qdrant向量数据库
config = {
……
"vector_store": {
"provider": "milvus",
"config": {
"collection_name": "……",
"vector_size": 1536,
"host": "localhost",
"port": 6333
}
}
……
}
向量维度 如:doubao embedding 2048;minimax embedding 1536;openai text-embedding-3-small 512
Milvus向量数据库
可设置参数:
provider : "milvus" 数据库名称
config :
- collection_name 集合名称
- vector_size 向量维度
- partition_name 分区名称
- connections_name 连接名称 默认:default
- host 连接地址 默认:None;本地:localhost
- port 连接端口 默认:None; 本地:6333
- uri 连接Zilliz服务器地址
- api_key 连接Zilliz服务器token
Qdrant向量数据库
……
2. 向量模型配置
config = {
……
"embedder": {
"provider": "minimax",
"config": {
"api_key": ……,
"group_id": ……
}
}
……
}
ModelScope modelscope-embedding模型
provider: "modelscope"
config :
- model_name modelscope embedding model name
MiniMax Embeddings模型
provider: "minimax"
config :
- api_key minimax api key
- group_id minimax group id
Doubao doubao-embedding模型
provider: "doubao"
config :
- api_key doubao api key
- model doubao embedding model name
OpenAI Embeddings模型
……
HuggingFace Embeddings模型
……
3. 文档切分配置
支持文档类型:txt、md、xlsx、pdf、docx、csv
character:固定大小分块; separator:分隔符分块;recursive_character:递归字符分割
config = {
……
"test_splitter": {
"provider": "character",
"config": {
"chunk_size": 300,
"chunk_overlap": 20
}
}
……
}
separator:分隔符分块
provider: "separator"
config :
- separator 指定文本分割(分隔符)的依据。 默认:\n\n
character:固定大小分块
provider: "character"
config :
- chunk_size 每个分块的最大字符数。
- chunk_overlap 分块之间的重叠字符数。
- separator 指定文本分割(分隔符)的依据。 默认:\n\n
- is_separator_regex 是否将分隔符视为正则表达式。默认:False
recursive_character:递归字符分割
provider: "recursive_character"
config :
- chunk_size 每个分块的最大字符数。
- chunk_overlap 分块之间的重叠字符数。
- separator 指定文本分割(分隔符)的依据。 默认:\n\n
- is_separator_regex 是否将分隔符视为正则表达式。默认:False
RAGLink 开发用法
文档向量化并存储向量数据库
# 输入单文档进行向量化
rag.execute_store(file_path="./XXX/XXX.txt")
# 输入多文档地址进行向量化
rag.execute_store_files(directory="./XXX")
向量数据管理
# 插入向量数据
# docs list结构 需要包含ID 、source、content数据
rag.execute_insert(docs=docs)
# 修改向量数据
# docs list结构 需要包含ID 、source、content数据
# is_embeddings 是否使用向量模型 True:使用 False:不使用(传入数据需定义向量数据)
rag.execute_update(docs=docs, is_embeddings=True)
# 执行删除向量数据
# ids list结构 只包含数据ID
rag.execute_delete(ids=ids)
检索获取上下文
# 输入查询语句进行检索获取上下文
result = rag.get_context(question=question, limit=limit)
版本更新
v0.1.0
新增 ModelScope Embedding
v0.0.9
新增 DouBao Embedding
v0.0.7
新增Milvus向量数据库,数据插入
v0.0.6
新增Milvus向量数据库,数据修改、删除等功能
v0.0.3
新增HuggingFaceEmbedding
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file raglink-0.1.3.tar.gz.
File metadata
- Download URL: raglink-0.1.3.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0b419e95a345b6ed86fe3786d3c0f040f5f7b4e171342d15eba6a2c8c6474ba
|
|
| MD5 |
3bad630a956ddca03a0d333ec3cb0b94
|
|
| BLAKE2b-256 |
0e2f617fb2a296215a51e860c294ffcfeeafdf8ee7b66dbea65d601231fdb394
|
File details
Details for the file raglink-0.1.3-py3-none-any.whl.
File metadata
- Download URL: raglink-0.1.3-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6df91e6f27ee9412f7b09c482840a6d7d22e508d29316a71915609b98371a492
|
|
| MD5 |
3a07c841a775560823634dbf85a2c368
|
|
| BLAKE2b-256 |
6f166371347e5d247efc398327eddb3197ea1f70fb2b0609c418b8ee497ddd28
|