diff --git a/docker-compose-full.yml b/docker-compose-full.yml index 21fb4c29c7..e9cc5ee96c 100644 --- a/docker-compose-full.yml +++ b/docker-compose-full.yml @@ -2,8 +2,18 @@ # This Sample File requires NVIDIA GPU for Milvus and VLLM services. # Copy `env.docker-compose-full` to `.env` before starting this compose file. # You can customize your setup using the Setup Wizard; for detailed instructions, please refer to docs/InteractiveSetup.md +x-lightrag-no-proxy: &lightrag_no_proxy "localhost,127.0.0.1,::1,0.0.0.0,host.docker.internal,postgres,neo4j,milvus,milvus-etcd,milvus-minio,vllm-embed,vllm-rerank,mineru-api,LightRAG-postgres,LightRAG-neo4j,LightRAG-milvus,LightRAG-milvus-etcd,LightRAG-milvus-minio,LightRAG-vllm-embed,LightRAG-vllm-rerank,LightRAG-mineru-api,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,sefo.cc,registry.cn-shanghai.aliyuncs.com" +x-lightrag-disable-proxy: &lightrag_disable_proxy + HTTP_PROXY: "" + HTTPS_PROXY: "" + ALL_PROXY: "" + http_proxy: "" + https_proxy: "" + all_proxy: "" + services: lightrag: + container_name: LightRAG-servforce image: ghcr.io/hkuds/lightrag:latest build: context: . @@ -25,10 +35,23 @@ services: extra_hosts: - "host.docker.internal:host-gateway" environment: + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy HOST: "0.0.0.0" PORT: "9621" + WORKSPACE: "servforce" EMBEDDING_BINDING_HOST: "http://vllm-embed:8001/v1" RERANK_BINDING_HOST: "http://vllm-rerank:8000/rerank" + LIGHTRAG_PARSER: "pdf:mineru(local_parse_method=ocr)-iteP,*:native-iteP,*:legacy-R" + MINERU_API_MODE: "local" + MINERU_LOCAL_ENDPOINT: "http://mineru-api:8000" + MINERU_LOCAL_BACKEND: "pipeline" + MINERU_LOCAL_PARSE_METHOD: "ocr" + MINERU_LOCAL_IMAGE_ANALYSIS: "false" + MINERU_LANGUAGE: "ch" + MINERU_ENABLE_TABLE: "true" + MINERU_ENABLE_FORMULA: "true" + MAX_PARALLEL_PARSE_MINERU: "1" POSTGRES_HOST: "postgres" POSTGRES_PORT: "5432" NEO4J_URI: "neo4j://neo4j:7687" @@ -52,9 +75,80 @@ services: condition: service_healthy milvus: condition: service_healthy + mineru-api: + condition: service_healthy + required: false + + lightrag-sales: + container_name: LightRAG-sales + image: ghcr.io/hkuds/lightrag:latest + build: + context: . + dockerfile: Dockerfile + tags: + - ghcr.io/hkuds/lightrag:latest + ports: + - "${HOST:-0.0.0.0}:${SALES_PORT:-9622}:9621" + volumes: + - ./data/rag_storage:/app/data/rag_storage + - ./data/inputs:/app/data/inputs + - ./config.ini:/app/config.ini + - ./data/prompts:/app/data/prompts + - ./.env:/app/.env + deploy: + restart_policy: + condition: on-failure + max_attempts: 10 + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy + HOST: "0.0.0.0" + PORT: "9621" + WORKSPACE: "sales" + EMBEDDING_BINDING_HOST: "http://vllm-embed:8001/v1" + RERANK_BINDING_HOST: "http://vllm-rerank:8000/rerank" + LIGHTRAG_PARSER: "pdf:mineru(local_parse_method=ocr)-iteP,*:native-iteP,*:legacy-R" + MINERU_API_MODE: "local" + MINERU_LOCAL_ENDPOINT: "http://mineru-api:8000" + MINERU_LOCAL_BACKEND: "pipeline" + MINERU_LOCAL_PARSE_METHOD: "ocr" + MINERU_LOCAL_IMAGE_ANALYSIS: "false" + MINERU_LANGUAGE: "ch" + MINERU_ENABLE_TABLE: "true" + MINERU_ENABLE_FORMULA: "true" + MAX_PARALLEL_PARSE_MINERU: "1" + POSTGRES_HOST: "postgres" + POSTGRES_PORT: "5432" + NEO4J_URI: "neo4j://neo4j:7687" + WORKING_DIR: "/app/data/rag_storage" + MILVUS_URI: "http://milvus:19530" + INPUT_DIR: "/app/data/inputs" + PROMPT_DIR: "/app/data/prompts" + MEMGRAPH_URI: "bolt://host.docker.internal:7687" + REDIS_URI: "redis://host.docker.internal:6379" + QDRANT_URL: "http://host.docker.internal:6333" + OPENSEARCH_HOSTS: "host.docker.internal:9200" + MONGO_URI: "mongodb://root:root@host.docker.internal:27017/" + depends_on: + vllm-embed: + condition: service_healthy + vllm-rerank: + condition: service_healthy + postgres: + condition: service_healthy + neo4j: + condition: service_healthy + milvus: + condition: service_healthy + mineru-api: + condition: service_healthy + required: false vllm-embed: - image: vllm/vllm-openai:latest + container_name: LightRAG-vllm-embed + image: ${VLLM_IMAGE:-vllm/vllm-openai:v0.7.3} runtime: nvidia command: > --model ${VLLM_EMBED_MODEL:-BAAI/bge-m3} @@ -63,6 +157,8 @@ services: --api-key ${VLLM_EMBED_API_KEY} ${VLLM_EMBED_EXTRA_ARGS:-} environment: + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy NVIDIA_VISIBLE_DEVICES: ${NVIDIA_VISIBLE_DEVICES:-all} NVIDIA_DRIVER_CAPABILITIES: ${NVIDIA_DRIVER_CAPABILITIES:-compute,utility} ports: @@ -88,7 +184,8 @@ services: restart: unless-stopped vllm-rerank: - image: vllm/vllm-openai:latest + container_name: LightRAG-vllm-rerank + image: ${VLLM_IMAGE:-vllm/vllm-openai:v0.7.3} runtime: nvidia command: > --model ${VLLM_RERANK_MODEL:-BAAI/bge-reranker-v2-m3} @@ -97,6 +194,8 @@ services: --api-key ${VLLM_RERANK_API_KEY} ${VLLM_RERANK_EXTRA_ARGS:-} environment: + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy NVIDIA_VISIBLE_DEVICES: ${NVIDIA_VISIBLE_DEVICES:-all} NVIDIA_DRIVER_CAPABILITIES: ${NVIDIA_DRIVER_CAPABILITIES:-compute,utility} ports: @@ -121,11 +220,40 @@ services: capabilities: [gpu] restart: unless-stopped + mineru-api: + container_name: LightRAG-mineru-api + image: ${MINERU_IMAGE:-mineru:latest} + pull_policy: ${MINERU_PULL_POLICY:-never} + entrypoint: mineru-api + command: > + --host 0.0.0.0 + --port 8000 + ports: + - "${MINERU_HOST_PORT:-8000}:8000" + environment: + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy + MINERU_MODEL_SOURCE: ${MINERU_MODEL_SOURCE:-local} + volumes: + - mineru_cache:/root/.cache + ipc: host + ulimits: + memlock: -1 + stack: 67108864 + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8000/health || exit 1"] + interval: 10s + timeout: 5s + retries: 60 + start_period: 30s + restart: unless-stopped + postgres: + container_name: LightRAG-postgres # this image does not support PGGraphStorage image: pgvector/pgvector:pg18 - # ports: - # - "5432:5432" + ports: + - "${POSTGRES_HOST_PORT:-15432}:5432" volumes: - postgres_data:/var/lib/postgresql healthcheck: @@ -138,11 +266,14 @@ services: start_period: 10s restart: unless-stopped environment: + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy POSTGRES_USER: "rag" POSTGRES_PASSWORD: "rag" POSTGRES_DB: "rag" neo4j: + container_name: LightRAG-neo4j image: neo4j:5-community # ports: # - "7474:7474" @@ -159,15 +290,21 @@ services: start_period: 10s restart: unless-stopped environment: + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy NEO4J_AUTH: ${NEO4J_USERNAME:?missing}/${NEO4J_PASSWORD:?missing} NEO4J_dbms_default__database: "neo4j" milvus: + container_name: LightRAG-milvus image: milvusdb/milvus:v2.6.11-gpu command: ["milvus", "run", "standalone"] security_opt: - seccomp:unconfined environment: + <<: *lightrag_disable_proxy + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy ETCD_ENDPOINTS: milvus-etcd:2379 MINIO_ADDRESS: milvus-minio:9000 MINIO_ACCESS_KEY_ID: "${MINIO_ACCESS_KEY_ID:?missing}" @@ -199,8 +336,11 @@ services: restart: unless-stopped milvus-etcd: + container_name: LightRAG-milvus-etcd image: quay.io/coreos/etcd:v3.5.25 environment: + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy ETCD_AUTO_COMPACTION_MODE: revision ETCD_AUTO_COMPACTION_RETENTION: "1000" ETCD_QUOTA_BACKEND_BYTES: "4294967296" @@ -220,13 +360,19 @@ services: restart: unless-stopped milvus-minio: + container_name: LightRAG-milvus-minio image: minio/minio:RELEASE.2025-09-07T16-13-09Z environment: + NO_PROXY: *lightrag_no_proxy + no_proxy: *lightrag_no_proxy MINIO_ROOT_USER: "${MINIO_ACCESS_KEY_ID:?missing}" MINIO_ROOT_PASSWORD: "${MINIO_SECRET_ACCESS_KEY:?missing}" volumes: - milvus-minio_data:/minio_data command: minio server /minio_data --console-address ":9001" + ports: + - "${MINIO_HOST_PORT:-19000}:9000" + - "${MINIO_CONSOLE_HOST_PORT:-19001}:9001" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 30s @@ -237,6 +383,7 @@ services: volumes: vllm_embed_cache: vllm_rerank_cache: + mineru_cache: postgres_data: neo4j_data: milvus_data: diff --git a/lightrag/kg/milvus_impl.py b/lightrag/kg/milvus_impl.py index 02262a076c..35f1d86ca9 100644 --- a/lightrag/kg/milvus_impl.py +++ b/lightrag/kg/milvus_impl.py @@ -2333,13 +2333,13 @@ async def query( # Build search params from index config search_params_base = self.index_config.build_search_params() - # Merge with metric type and radius threshold + # Do not pass the threshold as Milvus `radius`: on some Milvus index / + # execution backends this switches the request to range search, which + # can fail with "RangeSearch not implemented". Keep Milvus on normal + # top-k search and apply the threshold consistently in LightRAG. search_params = { "metric_type": self.index_config.metric_type, - "params": { - **search_params_base.get("params", {}), - "radius": self.cosine_better_than_threshold, - }, + "params": search_params_base.get("params", {}), } results = self._client.search( @@ -2349,6 +2349,21 @@ async def query( output_fields=output_fields, search_params=search_params, ) + + metric_type = str(self.index_config.metric_type).upper() + if metric_type == "L2": + filtered_results = [ + dp + for dp in results[0] + if dp["distance"] <= self.cosine_better_than_threshold + ] + else: + filtered_results = [ + dp + for dp in results[0] + if dp["distance"] >= self.cosine_better_than_threshold + ] + return [ { **dp["entity"], @@ -2356,7 +2371,7 @@ async def query( "distance": dp["distance"], "created_at": dp.get("created_at"), } - for dp in results[0] + for dp in filtered_results ] @staticmethod