Introduction
In the landscape of modern information retrieval, data is rarely confined to a single format. Real-world queries often require synthesizing information across structured tables, unstructured text passages, and visual elements like images. This task, known as Hybrid Question Answering (HQA), presents a significant challenge for traditional AI systems. For instance, answering a question about a specific railroad's logo might require identifying the railroad in a table, following a link to a text description of its owner, and finally analyzing an image of a shield-shaped logo.
Existing approaches to HQA typically rely on specialized retrievers or modal transformations (e.g., converting images to text captions). However, these methods often suffer from out-of-distribution failures or information loss during conversion. To address these limitations, we introduce HPROPRO (Hybrid Program-Based Prompting), a framework that treats the reasoning process as a code generation task, leveraging the logical precision of Python scripts to navigate heterogeneous data sources.
Methodology: The HPROPRO Framework
HPROPRO adopts a "generate-then-execute" paradigm. Instead of prompting a Large Language Model (LLM) to provide a direct answer, the system generates a Python program designed to retrieve and process the necessary information. This approach offers several advantages in terms of interpretability and logical consistency.
Semantic Functions and Tooling
To bridge the gap between rigid code and fluid natural language, HPROPRO utilizes custom semantic functions:
extract_info(cell, target): This function acts as a reading comprehension tool, allowing the model to query unstructured text or images associated with a specific table cell.check(obj1, obj2, op): Unlike standard Python equality checks, this function uses an LLM to perform semantic comparisons. It can recognize that "The Capital of China" and "Beijing" refer to the same entity, or that "20,000" matches "twenty thousand."
The Execution Pipeline
The framework operates through a multi-stage pipeline:
- Query Simplification: A retriever links complex descriptive phrases in the question to specific table cells, reducing the reasoning burden during the coding phase.
- Code Generation: The LLM (GPT-4) generates a Python script using the predefined semantic functions.
- Code Refinement: If the script encounters an error during execution, the system captures the Python traceback and feeds it back into the LLM. This allows the model to "self-correct" and generate a functional version of the program.
Experimental Evaluation
We evaluated HPROPRO on two primary benchmarks: HybridQA (table and text) and MultiModalQA (table, text, and images). The system utilized GPT-4 for code generation and GPT-4V (Vision) for image-based extraction tasks.
Key Results
HPROPRO demonstrated state-of-the-art (SOTA) performance, particularly in few-shot settings (using only 4 examples):
- MultiModalQA: The framework outperformed previous non-fine-tuned systems like Binder and MMHQA-ICL by 4.2% Exact Match (EM).
- HybridQA: HPROPRO achieved an EM of 48.0% and an F1 score of 54.6%. This represents a substantial 20% improvement over standard end-to-end GPT-4 prompting with a retriever.
Ablation Insights
Ablation studies highlighted the critical role of semantic flexibility. Removing the check function resulted in a performance drop of over 20% on MultiModalQA, confirming that the ability to perform semantic rather than just syntactic matching is essential for reasoning across diverse data formats.
Discussion and Limitations
The success of HPROPRO suggests that programs serve as superior reasoning traces compared to standard chain-of-thought prompting for structured data. By looping over tables and executing discrete logic, the model avoids the "hallucinations" common in pure text-based reasoning.
However, several challenges remain:
- LLM Dependency: Performance is intrinsically linked to the underlying model's coding proficiency.
- Complexity and Cost: The multi-stage process (simplification, generation, extraction, refinement) increases latency and computational cost compared to single-pass models.
- Logic Constraints: Error analysis shows the model still struggles with highly complex nested logic or extremely messy data strings that require advanced data cleaning (e.g., complex
split()orint()operations).
Conclusion
HPROPRO provides a robust, distribution-agnostic solution for Hybrid Question Answering. By combining the structured logic of programming with the semantic power of LLMs, it effectively bridges the gap between heterogeneous data sources. Future work will focus on expanding the framework's scope to include knowledge graphs and charts, further enhancing its utility in complex information environments.
Summary updated