Replies: 1 comment
-
|
To handle long-document parsing and summarization in Dify when your model supports 128k context but only 8k per input, you’ll need to split large documents into smaller chunks before sending them to the LLM. Dify doesn’t provide a built-in node for automatic chunking, so you should add a Code step (or custom node) after the Document Extractor to break the extracted text into segments that fit your input limit (e.g., 8k tokens each) reference. Your workflow would look like: Start → List operation (for multiple docs) → Document Extractor → Code step (chunking) → LLM (process each chunk) → Aggregate results → Reply. For each chunk, prompt the LLM to summarize or extract information, then combine the outputs in a final aggregation step. Be mindful of Dify’s array size limits (e.g., Code steps returning more than 30 items may fail) and strict enforcement of context/token limits—Dify will error if you exceed them, so chunking is essential reference. For prompt engineering, use clear instructions in your LLM node, and consider using advanced prompt templates (like Jinja-2) to format each chunk’s input. If you need more flexibility, you can develop a custom tool or plugin for chunking and aggregation reference. More details on the Document Extractor node and its output can be found in the official docs. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.
Now I want to implement a document parsing chatflow in Dify, primarily for document summarization. The current workflow is: Start → List operation (handling multiple documents) → Document extractor → LLM → Reply. My model supports a maximum context length of 128k, but the single input is limited to 8k, so the current issue is that if a document is too large, it will trigger an error. How can I design my workflow and prompt to achieve long-document parsing? For example, by splitting the input into multiple batches for the large model?
2. Additional context or comments
No response
Beta Was this translation helpful? Give feedback.
All reactions