Introduction
In this article, we will explore how to build a Proposer-Critic-Judge verification loop in Python utilizing a single small open model. The focus is on measuring the trade-off between accuracy and performance metrics, such as latency and tokens consumed.
Proposer-Critic-Judge Architecture
The Proposer-Critic-Judge framework segregates the responsibilities of generating, verifying, and finalizing a solution into three distinct roles:
- Proposer: Generates an initial response based on user input.
- Critic: Validates the Proposer’s output by independently verifying its correctness, providing detailed critiques when discrepancies arise.
- Judge: Synthesizes the original prompt, the Proposer’s response, and the Critic’s feedback to produce a final answer.
Python Implementation
The implementation of this multi-agent architecture can be resource-intensive, especially when employing advanced models. To optimize performance on limited hardware, such as Google Colab’s T4 GPU, persona multiplexing is employed. This technique involves loading a single model—specifically the Qwen2.5-7B-Instruct model—and dynamically switching its behavior for the three roles using system prompts.
Setup requires the following command:
!pip install -q -U transformers accelerate bitsandbytes torchThis command ensures that necessary libraries are available for execution on the environment.
Functionality and Measurements
The system tracks metrics such as tokens consumed and latency throughout the verification process. Each step in the verification loop employs the generate_and_measure() function, which captures these metrics while facilitating interaction with the model.
Conclusion
The architecture successfully demonstrates a method to optimize accuracy at the cost of increased computational overhead. The initial test case showcased the robustness of the multi-agent verification, proving that a well-structured Proposer-Critic-Judge loop can rectify zero-shot inaccuracies prevalent in simpler models. While this approach significantly increases latency and token usage, the cognitive accuracy achieved makes it a compelling choice for complex reasoning tasks.
Source: machinelearningmastery.com


