Notebooks
A
Arize AI
Langgraph Parallel

Langgraph Parallel

agentsllmsLlamaIndexarize-phoenixopenaitutorialsevalsllmopsai-monitoringaiengineeringprompt-engineeringdatasetsllm-evallanggraphai-observabilityllm-evaluationsmolagentsanthropiclangchain

Open In Colab

Langgraph - Parallel Evaluation

Parallel Evaluation in LangGraph In this tutorial, we’ll build a parallel execution workflow using LangGraph — ideal for scenarios where multiple evaluations or subtasks can run independently before being aggregated into a final decision.

Our application generates a compelling product description and then runs three checks in parallel:

  • Safety Check: Is the content safe and non-violent?

  • Policy Compliance: Does it follow company policy?

  • Clarity Check: Is it understandable to a general audience?

This pattern demonstrates how to fan out execution after a shared generation step, and aggregate results before producing a final output.

We use Phoenix tracing to gain full visibility into each node execution, making it easy to debug or audit how decisions were made across the parallel branches.

[ ]
[ ]
[ ]

Configure Phoenix Tracing

Make sure you go to https://app.phoenix.arize.com/ and generate an API key. This will allow you to trace your Langgraph application with Phoenix.

[ ]
[ ]
[ ]

LLM of choice

[ ]

Graph State Definition

We define a State object to keep track of all data flowing through our LangGraph. This includes the input product name, the generated description, results of three independent evaluation checks, and the final aggregated output.

[ ]

Node 1: Generate Product Description

This node uses the LLM to write a compelling marketing-style description of the product. The output is stored in the description field of the graph state.

[ ]

Node 2–4: Parallel Evaluation Checks

After the product description is created, we fan out to three evaluators, each performing an independent check in parallel:

Safety Check: Is the language safe and non-violent?

Policy Compliance: Does it align with company guidelines?

Clarity Check: Is it understandable by a general audience?

Each function receives the same description as input and returns a binary decision ("yes" or "no").

[ ]
[ ]

Node 5: Aggregate the Results

Once the checks complete, this node gathers their responses. If all checks return "yes", the product description is approved. Otherwise, it’s flagged as rejected, along with reasons.

[ ]

Building the Parallel Evaluation Graph

With all our nodes defined, we now assemble them into a LangGraph using StateGraph.

Start → Description: We begin by generating the product description.

Fan Out Checks: The output fans out into three parallel paths — safety, policy, and clarity checks — enabling efficient, simultaneous validation.

Converge → Aggregate: Once all checks complete, the results converge into a final aggregation node that determines whether to approve or reject the description.

End: The final result is produced.

This setup showcases LangGraph’s ability to manage parallelism and convergence, streamlining complex workflows while remaining transparent and modular.

[ ]

Example Usage

[ ]
[ ]

Make sure to view your traces in Phoenix!

Let's add some Evaluations (Evals)

In this section we will evaluate the accuracy of our safety, policy, and clarity checkers with another LLM call.

[ ]
[ ]

Custom Eval Template

Here we define a custom eval template, designed to evaluate the policy, clarity, and safety checkers' decisions.

[ ]
[ ]

Generate Evals

[ ]
[ ]

Export Evals to Phoenix!

[ ]
[ ]