AGENT SKILL

lightrag

Use LightRAG as a graph-based RAG framework: embedded Python APIs, document ingestion, storage backends, LLM/provider wiring, FastAPI/WebUI operation, and troubleshooting.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
lightrag
license
MIT
metadata
{ "disco-role": "operating" }
description
Use LightRAG as a graph-based RAG framework: embedded Python APIs, document ingestion, storage backends, LLM/provider wiring, FastAPI/WebUI operation, and troubleshooting.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

LightRAG Repo Skill

Use this skill for tasks involving LightRAG, the lightrag-hku Python package, its graph-based RAG APIs, document parsing pipeline, storage backends, model/provider bindings, REST API server, or WebUI.

Start Here

  • Install the base package for embedded Python work: pip install lightrag-hku.
  • Install API/upload/parser support for server work: pip install "lightrag-hku[api]".
  • Use the offline/storage/provider extras only when the task needs those optional backends: offline-storage, offline-llm, offline, evaluation, or observability.
  • Verify the installed package without model calls or services: python scripts/check_lightrag_install.py from this skill directory.
  • Read repo provenance before deciding whether this skill is stale for a current checkout.
  • Read troubleshooting for cross-cutting install/import, initialization, optional dependency, credential, storage, parser, and server failures.

Route By Task

  • Embedded Python LightRAG construction, QueryParam, async lifecycle, text/custom-KG insertion, querying, embeddings, cache, and rerank knobs: use core-rag.
  • File/text ingestion internals, parser routing, filename hints, process options, chunk strategies, sidecars, doc status, and pipeline concurrency/refusal semantics: use document-pipeline.
  • KV/vector/graph/doc-status storage class selection, external storage services, workspace isolation, migrations, vector rebuilds, cache cleanup, and destructive storage preconditions: use storage-backends.
  • LLM, embedding, VLM, role-specific model routing, provider bindings, asymmetric embeddings, rerank provider setup, credentials, service URLs, and model-cache behavior: use llm-providers.
  • lightrag-server, lightrag-gunicorn, REST/Ollama-compatible routes, auth/JWT, .env configuration, setup wizard outputs, Docker/offline deployment, and React WebUI operations: use api-server.

Core Decision Points

  • Choose embedded Python when integrating LightRAG inside an application, notebook, worker, or test harness.
  • Choose the API server/WebUI route when the user needs uploads, REST routes, browser UI, auth, or Ollama-compatible endpoints.
  • Choose document-pipeline guidance when the problem names parser engines, LIGHTRAG_PARSER, process_options, chunking selectors F/R/V/P, parsed sidecars, scan/upload/delete conflicts, or doc-status rows.
  • Choose storage-backends guidance when the problem names JsonKVStorage, PGVectorStorage, Neo4JStorage, Qdrant, Redis, MongoDB, OpenSearch, workspace isolation, vector dimensions, or rebuild/cache tools.
  • Choose llm-providers guidance when the problem names OpenAI, Ollama, Azure OpenAI, Gemini, Bedrock, Anthropic, VoyageAI, Zhipu, VLM, rerank, role-specific LLMs, or embedding prefixes.

Minimal Embedded Pattern

import asyncio
from lightrag import LightRAG, QueryParam

async def main():
    rag = LightRAG(
        working_dir="./rag_storage",
        llm_model_func=your_llm_func,
        embedding_func=your_embedding_func,
    )
    await rag.initialize_storages()
    try:
        await rag.ainsert("LightRAG builds a graph from documents.")
        result = await rag.aquery("What does LightRAG build?", param=QueryParam(mode="mix"))
        print(result)
    finally:
        await rag.finalize_storages()

asyncio.run(main())

Non-Negotiables

  • Always initialize storages before ainsert, aquery, graph, delete, or cache operations; always finalize storages during cleanup.
  • Do not call synchronous wrappers from an already running event loop; use async methods in async apps.
  • Keep embedding model, embedding dimension, and existing vector storage aligned; changing embeddings requires rebuilding or clearing vector data.
  • Treat optional provider/storage/parser services as explicit dependencies; do not assume API keys, databases, parser services, or local model servers exist.
  • Do not run destructive storage tools, document clear/delete operations, or graph mutations while ingestion or another writer is active for the same workspace.
  • Keep public examples free of secrets, machine-specific paths, local environment names, and original source-checkout dependencies.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351