flowchart TD
A["Long Document"] --> B{"Fits in
context window?"}
B -->|Yes| C["Process directly"]
B -->|No| D{"Task type?"}
D -->|Summarization| E["Chunk and summarize
each piece"]
D -->|Question answering| F["Extract relevant
sections only"]
D -->|Analysis| G["Hierarchical: outline first,
then drill down"]
E --> H["Combine chunk summaries
into final summary"]
F --> I["Process focused excerpt
with question"]
G --> J["Process relevant
sections in detail"]
C --> K["Final Output"]
H --> K
I --> K
J --> K
classDef startNode fill:#4a7fb5,stroke:#333,stroke-width:2px,color:#fff,font-size:16px
classDef decisionNode fill:#f0a04b,stroke:#333,stroke-width:2px,color:#333,font-size:16px
classDef processNode fill:#a3c4dc,stroke:#333,stroke-width:2px,color:#333,font-size:16px
classDef combineNode fill:#7ec4a7,stroke:#333,stroke-width:2px,color:#333,font-size:16px
classDef endNode fill:#2e6b4f,stroke:#333,stroke-width:2px,color:#fff,font-size:16px
class A startNode
class B,D decisionNode
class C,E,F,G processNode
class H,I,J combineNode
class K endNode
linkStyle default font-size:16px