LLM Workflow Patterns

Let's see five key patterns in which LLM Workflows are implemented.

Prompt Chaining

This workflow is used when we can break down a complex task into a sequence of steps, and each step can be processed as individual LLM call using the output of the previous step.
Example:
  1. Multistep reasoning tasks such as summarize text, critique and then rewrite
  2. Code generation pipeline such as generate plan, write code, test code, explain output


Router

This workflow is used in cases where an agent classifies the intent/task type/domain of the input query and then delegates the request to another agent, tool or workflow. 
Example:
  1. Multimodal agents such as those with separate text processing and image processing LLMs
  2. Multidomain assistants such as processing questions related to legal vs finance vs medical domains

Parallelization

The workflow pattern is useful when a task can be broken down into subtasks which can be handled concurrently by multiple LLM or agents. The outputs of these multiple calls are then aggregated by an aggregator to return a synthesized result to the user.
Example:
  1. Processing multiple documents/images in parallel
  2. Generating and sending emails to multiple clients in parallel



Orchestration

In this workflow, an orchestrator agent plans subtasks and delegates them to multiple specialized subagents or models each with specialized knowledge or domain expertise.
Examples:
  1. A Blog writing agent with researcher, writer and quality-checker subagents
  2. Coding agent with an architect, developer, code reviewer, tester agents 

Evaluators and Reflect-Refine Loop

This workflow provides a loop where one agent/LLM generates the result, and another agent/LLM evaluates the result based on a set criteria. The loop continues until the criteria is fulfilled or loop runs up-to a threshold. This workflow promotes selft-reflection, optimization and iterative improvement.
Example:
  1. Agents that uses a planner and reviewer agents in loop
  2. Blog writer agents with style enhancer agent providing feedbacks


Conclusion

All these patterns are not exclusive to each other and not to be used in isolation. We can create sophisticated complex workflows by using multiple patterns together. For example, by combining router and orchestration workflow, we can have an orchestrator which caters to multi-domain customer support agent.

Comments

Popular posts from this blog

Summary of Paper: RSync Algorithm

Monitoring and Restarting Apache webserver Automatically using AWS CloudWatch

Continuous Integration and Delivery pipeline using Bitbucket, AWS CodeBuild, AWS CodePipline and AWS CodeDeploy - Part 1