Implementation:ANative Lab EvoAgentX QAActionGraph
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Workflow, QA |
| Last Updated | 2026-10-21 00:00 GMT |
Overview
Concrete tool for question answering via self-consistency ensemble, using an action graph with answer generation and voting operators.
Description
The QAActionGraph class extends ActionGraph to provide a simple QA workflow. It initializes two operators: AnswerGenerate (generates candidate answers) and QAScEnsemble (votes on the best answer via self-consistency). The `execute()` method generates 3 candidate answers and ensembles them into a final answer.
Usage
- Benchmark evaluation: Use as the graph for `Evaluator.evaluate(graph=qa_graph, benchmark=...)` when evaluating QA benchmarks.
- Standalone QA: Call `execute(problem="What is the capital of France?")` to get an answer via self-consistency.
Code Reference
Source Location
- Repository: EvoAgentX
- File: evoagentx/workflow/action_graph.py (L110-141)
Signature
class QAActionGraph(ActionGraph):
def __init__(self, llm_config: LLMConfig, **kwargs)
def execute(self, problem: str) -> dict # {"answer": str}
async def async_execute(self, problem: str) -> dict # {"answer": str}
Import
from evoagentx.workflow.action_graph import QAActionGraph
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| llm_config | LLMConfig | Yes | LLM configuration |
| problem | str | Yes (for execute) | Question to answer |
Outputs
| Name | Type | Description |
|---|---|---|
| execute returns | `{"answer": str}` — ensembled best answer |
Usage Examples
QA with Self-Consistency
from evoagentx.workflow.action_graph import QAActionGraph
from evoagentx.models.model_configs import OpenAILLMConfig
qa_graph = QAActionGraph(
llm_config=OpenAILLMConfig(model="gpt-4o-mini", openai_key="sk-..."),
)
result = qa_graph.execute(problem="What is the capital of France?")
print(result["answer"]) # "Paris"
Evaluate Against Benchmark
from evoagentx.evaluators.evaluator import Evaluator
from evoagentx.workflow.action_graph import QAActionGraph
from evoagentx.benchmark.hotpotqa import HotPotQA
qa_graph = QAActionGraph(llm_config=llm_config)
benchmark = HotPotQA(mode="dev")
def collate_func(example):
return {"problem": example["question"]}
def postprocess_func(output):
return output["answer"]
evaluator = Evaluator(
llm=llm,
collate_func=collate_func,
output_postprocess_func=postprocess_func,
)
metrics = evaluator.evaluate(graph=qa_graph, benchmark=benchmark, sample_k=20)
print(metrics)
Related Pages
Implements Principle
- Principle:ANative_Lab_EvoAgentX_Self_Consistency_Voting
- Principle:ANative_Lab_EvoAgentX_Benchmark_Evaluation
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment