mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Feat: make document parsing and embedding batch sizes configurable via environment variables (#8266)
### Description This PR introduces two new environment variables, `DOC_BULK_SIZE` and `EMBEDDING_BATCH_SIZE`, to allow flexible tuning of batch sizes for document parsing and embedding vectorization in RAGFlow. By making these parameters configurable, users can optimize performance and resource usage according to their hardware capabilities and workload requirements. ### What problem does this PR solve? Previously, the batch sizes for document parsing and embedding were hardcoded, limiting the ability to adjust throughput and memory consumption. This PR enables users to set these values via environment variables (in `.env`, Helm chart, or directly in the deployment environment), improving flexibility and scalability for both small and large deployments. - `DOC_BULK_SIZE`: Controls how many document chunks are processed in a single batch during document parsing (default: 4). - `EMBEDDING_BATCH_SIZE`: Controls how many text chunks are processed in a single batch during embedding vectorization (default: 16). This change updates the codebase, documentation, and configuration files to reflect the new options. ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) - [x] New Feature (non-breaking change which adds functionality) - [x] Documentation Update - [ ] Refactoring - [x] Performance Improvement - [ ] Other (please describe): ### Additional context - Updated `.env`, `helm/values.yaml`, and documentation to describe the new variables. - Modified relevant code paths to use the environment variables instead of hardcoded values. - Users can now tune these parameters to achieve better throughput or reduce memory usage as needed. Before: Default value: <img width="643" alt="image" src="https://github.com/user-attachments/assets/086e1173-18f3-419d-a0f5-68394f63866a" /> After: 10x: <img width="777" alt="image" src="https://github.com/user-attachments/assets/5722bbc0-0bcb-4536-b928-077031e550f1" />
This commit is contained in:
@ -115,6 +115,16 @@ The [.env](./.env) file contains important environment variables for Docker.
|
||||
- `MAX_CONTENT_LENGTH`
|
||||
The maximum file size for each uploaded file, in bytes. You can uncomment this line if you wish to change the 128M file size limit. After making the change, ensure you update `client_max_body_size` in nginx/nginx.conf correspondingly.
|
||||
|
||||
### Doc bulk size
|
||||
|
||||
- `DOC_BULK_SIZE`
|
||||
The number of document chunks processed in a single batch during document parsing. Defaults to `4`.
|
||||
|
||||
### Embedding batch size
|
||||
|
||||
- `EMBEDDING_BATCH_SIZE`
|
||||
The number of text chunks processed in a single batch during embedding vectorization. Defaults to `16`.
|
||||
|
||||
## 🐋 Service configuration
|
||||
|
||||
[service_conf.yaml](./service_conf.yaml) specifies the system-level configuration for RAGFlow and is used by its API server and task executor. In a dockerized setup, this file is automatically created based on the [service_conf.yaml.template](./service_conf.yaml.template) file (replacing all environment variables by their values).
|
||||
|
||||
Reference in New Issue
Block a user