语义保护AI 是 AI Skill Hub 本期精选AI工具之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
语义保护AI 是一款基于 Python 开发的开源工具,专注于 ai、deep-learning、causal-reasoning 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
语义保护AI 是一款基于 Python 开发的开源工具,专注于 ai、deep-learning、causal-reasoning 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:pip 安装(推荐)
pip install vortexrag
# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install vortexrag
# 方式三:从源码安装(获取最新功能)
git clone https://github.com/vignesh2027/VORTEXRAG
cd VORTEXRAG
pip install -e .
# 验证安装
python -c "import vortexrag; print('安装成功')"
# 命令行使用
vortexrag --help
# 基本用法
vortexrag input_file -o output_file
# Python 代码中调用
import vortexrag
# 示例
result = vortexrag.process("input")
print(result)
# vortexrag 配置文件示例(config.yml) app: name: "vortexrag" debug: false log_level: "INFO" # 运行时指定配置文件 vortexrag --config config.yml # 或通过环境变量配置 export VORTEXRAG_API_KEY="your-key" export VORTEXRAG_OUTPUT_DIR="./output"
Paper · Live Demo · Quickstart · Benchmarks · API Reference
</div>
---
Most RAG systems have two problems that nobody talks about enough.
The first is semantic drift — your retriever pulls in chunks that look relevant (high cosine score) but don't actually answer the question causally. Ask "Why did Lehman Brothers collapse?" and you'll get back chunks about the 2008 housing crisis — same vocabulary, but those are the consequences, not the cause. Cosine similarity can't tell the difference.
The second is context poisoning — even if each individual chunk is okay, a window full of semi-relevant chunks confuses the LLM. It attends to all of them, averages them out, and hallucinates.
VORTEXRAG fixes both. It's a 7-layer pipeline I built specifically around these two failure modes. Each layer has a specific job:
| Layer | Name | What it does |
|---|---|---|
| 1 | TVE — Tri-Vector Encoder | Encodes every chunk as three separate vectors: semantic meaning, syntactic structure, and causal dependency. One-dimensional cosine similarity misses the causal signal entirely. |
| 2 | VRC — Vortex Retrieval Cone | Retrieves candidates using a spiral topology — chunks in the same directional quadrant as your query score higher; off-axis chunks can actually score *negative* and get suppressed. |
| 3 | SDC — Semantic Drift Corrector | Filters chunks by causal alignment using a drift vector. If a chunk is causally adjacent to the query but not causally *relevant*, it gets rejected. Tuned per domain. |
| 4 | CPG — Context Poison Guard | Computes an Effective Signal Ratio for the whole context window. Iteratively removes the weakest chunk until the window is clean. |
| 5 | RFG — Rank Fusion Gate | Merges the TVE score, SDC score, and ESR contribution into a single Φ-score using multiplicative fusion. One weak dimension tanks the whole score. |
| 6 | CCB — Causal Context Builder | Orders the final chunks by causal depth — root causes appear first, effects appear after. This directly combats the "lost in the middle" LLM attention problem. |
| 7 | FV — Faithfulness Verifier | After generation, scores the answer via ROUGE-L × NLI entailment. If it fails the threshold, re-ranks and regenerates (up to 3 times). |
---
python -m spacy download en_core_web_sm
python -c "from sentence_transformers import CrossEncoder; CrossEncoder('cross-encoder/nli-deberta-v3-small')" ```
Requirements:
| Package | Version | Required | Purpose |
|---|---|---|---|
| numpy | ≥1.24 | **Yes** | All vector math |
| sentence-transformers | ≥2.2 | Recommended | SBERT semantic arm + NLI CrossEncoder |
| spacy | ≥3.5 | Recommended | Syntactic arm (POS, deps, parse tree) |
| faiss-cpu | ≥1.7 | Optional | Fast ANN retrieval for large corpora |
| torch | ≥2.0 | Optional | GPU acceleration |
---
VORTEXRAG requires Python 3.10 or higher. Python 3.11 and 3.12 are fully supported and recommended for best performance. Python 3.9 and below are not supported due to use of match statements and modern type hint syntax.
python --version # must be 3.10+
pip install "vortexrag[dev]"
After installing the full extras, download required models:
bash
python -m spacy download en_core_web_sm
| Package | Version | Required for | Notes |
|---|---|---|---|
numpy | ≥1.24 | All modules | Core vector math |
sentence-transformers | ≥2.2 | TVE semantic arm, FV NLI | Includes torch |
spacy | ≥3.5 | TVE syntactic arm | Requires language model download |
faiss-cpu | ≥1.7 | VRC retrieval | Swap for faiss-gpu on CUDA machines |
torch | ≥2.0 | GPU acceleration | Optional but recommended |
scikit-learn | ≥1.2 | Clustering utilities | Optional |
transformers | ≥4.35 | Advanced NLI models | Optional |
pytest | ≥7.0 | Running tests | Dev dependency |
black | ≥23.0 | Code formatting | Dev dependency |
ruff | ≥0.1 | Linting | Dev dependency |
Ordered slot injection:
$$W^* = \text{sort\_by}(\tilde{\Phi}) \cap \text{causal\_dependency\_graph}(q)$$
Slot position formula:
$$\text{pos}(c_i) = \text{rank}(\tilde{\Phi}(c_i)) \times \text{causal\_depth}(c_i)$$
Causal depth assignment algorithm:
Deduplication (MMR-style):
$$\text{sim\_dedup}(c_i, c_j) = \cos(v_{\text{sem}}(c_i),\, v_{\text{sem}}(c_j))$$
Chunks with $\text{sim\_dedup} \geq 0.92$ are deduplicated before ordering — the lower-$\tilde{\Phi}$ chunk is removed.
Why this formula? The product balances two objectives: (1) high-$\tilde{\Phi}$ chunks should appear early; (2) root causes should appear before effects. A highly relevant root cause (rank=2, depth=0) gets pos=0 — placed first. A slightly less relevant downstream effect (rank=1, depth=3) gets pos=3 — placed after the root cause, even though its $\tilde{\Phi}$ rank is higher.
"Lost in the Middle" fix (Liu et al., 2023): LLMs attend strongest to content at the beginning and end of context windows. By placing causal depth=0 chunks first (pos formula sends them to position 0), VORTEXRAG ensures root causes receive maximum LLM attention. This is mathematically equivalent to solving the positional bias problem by design.
---
```bash
pip install vortexrag
pip install "vortexrag[full]"
class CCBBuilder:
def build(self, chunks: list[Candidate], query_vec: TVEVector) -> list[OrderedContextSlot]: ...
def deduplicate(self, chunks: list[Candidate]) -> list[Candidate]: ...
def to_structured_context(self, slots: list[OrderedContextSlot]) -> list[dict]: ...
def explain_ordering(self, slots: list[OrderedContextSlot]) -> str: ...
def causal_chain_summary(self, slots: list[OrderedContextSlot]) -> dict: ...
def token_budget_usage(self, slots: list[OrderedContextSlot], budget: int = 4096) -> dict: ...
```bash
pip install vortexrag
pip install "vortexrag[sbert]"
pip install "vortexrag[full]"
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
conda install -c pytorch faiss-gpu
pip install "vortexrag[full]" python -m spacy download en_core_web_sm ```
A pre-built Docker image is available. It bundles all models and dependencies so no internet access is needed at runtime.
```bash
docker run -p 8000:8000 \ -v $(pwd)/my_docs:/data \ -e VORTEXRAG_CORPUS=/data \ -e VORTEXRAG_DOMAIN=general \ vigneshwar234/vortexrag:latest serve
**Docker Compose** for a full stack (API + corpus volume):
yaml
version: "3.9" services: vortexrag: image: vigneshwar234/vortexrag:latest ports: - "8000:8000" volumes: - ./corpus:/data/corpus - ./index_cache:/data/index environment: - VORTEXRAG_CORPUS=/data/corpus - VORTEXRAG_INDEX_CACHE=/data/index - VORTEXRAG_DOMAIN=general - VORTEXRAG_LOG_LEVEL=INFO command: serve --host 0.0.0.0 --port 8000 restart: unless-stopped ```
```bash git clone https://github.com/vignesh2027/VORTEXRAG.git cd VORTEXRAG pip install -e ".[dev]"
pytest tests/ -v ```
```python import vortexrag print(vortexrag.version)
retriever.build_index(chunk_vecs) # list[TVEVector]
from vortexrag import VortexRAG
rag = VortexRAG(corpus="your_docs/")
rag.index()
answer = rag.query("What caused the 2008 financial crisis?")
print(answer.answer)
print(f"ESR: {answer.esr:.3f} | ΔR: {answer.delta_r:.4f} | Latency: {answer.latency_ms:.1f}ms")
With custom LLM (OpenAI):
from vortexrag import VortexRAG, VortexRAGConfig
from openai import OpenAI
client = OpenAI()
def llm_fn(context: str, query: str) -> str:
resp = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": f"Answer using only this context:\n\n{context}"},
{"role": "user", "content": query},
]
)
return resp.choices[0].message.content
config = VortexRAGConfig(domain="legal")
rag = VortexRAG(corpus="case_files/", config=config, llm_fn=llm_fn)
rag.index()
result = rag.query("Did Brown v. Board apply to public universities before 1964?")
print(result.answer)
print(f"Faithfulness: {result.grounding:.4f} | Iterations: {result.fv_iterations}")
Domain-specific medical configuration:
from vortexrag import VortexRAG, VortexRAGConfig
from core.sdc import SDCConfig
from core.cpg import CPGConfig
from core.rfg import RFGConfig
config = VortexRAGConfig(domain="medical")
config.sdc = SDCConfig(domain="medical") # tau=0.35 automatically
config.cpg = CPGConfig(theta_cpg=5.0) # very clean context
config.rfg = RFGConfig(top_m=6, domain="medical") # more context chunks
rag = VortexRAG(corpus="pubmed_abstracts/", config=config)
rag.index()
result = rag.query("What is the mechanistic difference between mRNA and viral vector vaccines?")
---
| Parameter | Type | Default | Description |
|---|---|---|---|
domain | str | "general" | Domain preset — sets all sub-configs automatically |
corpus_pool_size | int | 200 | Number of candidates VRC returns |
top_m | int | 8 | Final context window size |
| Parameter | Type | Default | Description |
|---|---|---|---|
alpha | float | 0.50 | Weight for semantic arm ∈ [0, 1] |
beta | float | 0.25 | Weight for syntactic arm ∈ [0, 1] |
gamma | float | 0.25 | Weight for causal arm ∈ [0, 1] |
model_name | str | "all-mpnet-base-v2" | SBERT model name |
semantic_dim | int | 768 | Semantic embedding dimension |
syntactic_dim | int | 64 | Syntactic projection dimension |
causal_dim | int | 32 | Causal projection dimension |
domain | str | "general" | Domain preset (overrides α/β/γ if set) |
| Parameter | Type | Default | Description |
|---|---|---|---|
lambda_decay | float | 0.5 | Radial decay rate λ |
n_spiral | int | 2 | Spiral tightness n ∈ {1, 2, 3} |
pool_size | int | 200 | Number of candidates to return |
adaptive_lambda | bool | False | Auto-tune λ based on corpus size |
| Parameter | Type | Default | Description |
|---|---|---|---|
tau | float | 0.80 | Drift temperature τ (domain-tuned) |
delta_sdc | float | 0.72 | SDS acceptance threshold |
domain | str | "general" | Domain preset (overrides τ) |
strict_mode | bool | False | Reject borderline chunks (SDS < δ + 0.05) |
| Parameter | Type | Default | Description |
|---|---|---|---|
theta_cpg | float | 3.5 | ESR clean threshold |
max_purge_rounds | int | 30 | Maximum purge iterations |
min_window_size | int | 2 | Minimum chunks to retain |
| Parameter | Type | Default | Description |
|---|---|---|---|
alpha | float | 0.40 | Φ exponent for TVE score |
beta | float | 0.35 | Φ exponent for SDS score |
gamma | float | 0.25 | Φ exponent for ESR contribution |
top_m | int | 8 | Number of chunks to select |
diversity_weight | float | 0.0 | MMR diversity weight λ ∈ [0, 1] |
domain | str | "general" | Domain preset (overrides α/β/γ) |
| Parameter | Type | Default | Description |
|---|---|---|---|
max_slots | int | 8 | Maximum context slots |
dedup_threshold | float | 0.92 | Cosine similarity threshold for dedup |
enable_dedup | bool | True | Enable MMR-style deduplication |
causal_depth_bonus | int | 2 | Depth reduction for causal verb–dense chunks |
| Parameter | Type | Default | Description |
|---|---|---|---|
delta_fv | float | 0.15 | ΔR acceptance threshold |
max_iterations | int | 3 | Maximum regeneration attempts |
nli_model | str | "cross-encoder/nli-deberta-v3-small" | CrossEncoder NLI model |
use_nli | bool | False | Enable NLI (requires sentence-transformers) |
---
```bash
conda create -n vortexrag python=3.11 conda activate vortexrag
from vortexrag.diagnostics import feature_check feature_check()
Query → TVE (encode) → VRC (retrieve) → SDC (drift filter) → CPG (poison purge)
→ RFG (rank fusion) → CCB (causal order) → LLM → FV (faithfulness check)
---
comparison = retriever.compare_with_flat_topk(q_vec, k=10) print(f"VRC retrieves {comparison['additional_relevant']} extra relevant chunks " f"that flat top-k misses")
高质量的语义保护AI工具
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,语义保护AI 在AI工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | VORTEXRAG |
| 原始描述 | 开源AI工具:7-layer RAG framework that eliminates semantic drift + context poisoning. Faithf。⭐6 · Python |
| Topics | aideep-learningcausal-reasoning |
| GitHub | https://github.com/vignesh2027/VORTEXRAG |
| License | MIT |
| 语言 | Python |
收录时间:2026-06-24 · 更新时间:2026-06-24 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。