langchain-modular-beta
基于 LangChain 的模块化 RAG 检索组件(Beta)。
ModularRAG 把一条完整的检索链路拆成可开关的独立模块,按 config 字典组合:
| 阶段 | 模块 | 说明 |
|---|---|---|
| 检索前 | normalize_query |
归一化查询词 |
| 检索前 | rewrite_query |
用 LLM 改写为独立检索式 |
| 检索前 | generate_hyde |
生成假设性答案用于语义检索 |
| 检索中 | vector_search |
Chroma 向量召回 |
| 检索中 | bm25_search |
jieba + BM25 稀疏召回 |
| 检索中 | rrf_fusion |
RRF 融合稠密/稀疏结果 |
| 检索后 | deduplicate |
按内容去重 |
| 检索后 | rerank_documents |
DashScope Rerank 重排 |
| 检索后 | similarity_filter |
余弦相似度阈值过滤 |
| 检索后 | compress_context |
LLMChainExtractor 压缩上下文 |
| 检索后 | reorder_documents |
LongContextReorder 重排位置 |
安装
pip install langchain-modular-beta
快速开始
from langchain_modular_beta import ModularRAG
rag = ModularRAG({
"persist_directory": "./chroma_db",
"collection_name": "study",
"embedding_model": "text-embedding-v4",
"top_k": 5,
"pre_retrieval": {"enabled": True, "rewrite_query": True},
"hybrid_retrieval": {"enabled": True, "weights": [0.5, 0.5]},
"post_retrieval": {"enabled": True, "deduplicate": True, "rerank": True},
})
docs = rag.search("公司打卡时间?")
for doc in docs:
print(doc.metadata["retrieval_rank"], doc.page_content[:80])
环境变量
DASHSCOPE_API_KEY=sk-xxx
License
MIT
Metadata
Release files for langchain-modular-beta 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_modular_beta-0.0.1.tar.gz | 5.4 kB | Without provenance | Details for langchain_modular_beta-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_modular_beta-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for langchain_modular_beta-0.0.1-py3-none-any.whl |
Total release size: 11.0 kB
Release files / langchain_modular_beta-0.0.1.tar.gz
| Download URL | langchain_modular_beta-0.0.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1989ca2470faa1ac54713d53efca3611c3feffd36e067cf97dad2e48a6ec16cf
|
|
BLAKE2b-256 checksum How to use checksums |
c9979781bc73680f6b13717190ff0c10f055b86e4ee3fb7df219825c48235da1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Release files / langchain_modular_beta-0.0.1-py3-none-any.whl
| Download URL | langchain_modular_beta-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa7c8dfc7cebf275fc0906ac8d39d12fa3da2856c0fc319203962cc91392070e
|
|
BLAKE2b-256 checksum How to use checksums |
8b1ce4f7357b7505b3836db1c28d799175f8d058b57b8a0fb390326f0498c346
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Security for langchain-modular-beta 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.