TL;DR
This paper introduces "Foundation Model Programs" (FMPs) – a novel approach to tackle the high inference costs of large AI models. By breaking down tasks into programs and dynamically selecting the most resource-efficient AI "backends" for each sub-task, they achieve up to 98% resource savings with minimal accuracy loss on streaming visual question-answering tasks.
What Problem Does This Paper Address?
Deploying large foundation models (FMs) like LLMs and vision models in real-world applications, especially those requiring real-time responses to continuous streams of data (e.g., agentic systems, streaming VQA), is hampered by their significant inference-time resource costs. This leads to high operational expenses and degraded user experience. While existing methods try to mitigate this by using smaller models or routing queries, they often fail to leverage the inherent structure of complex, multi-step tasks. The challenge is to efficiently allocate computational resources dynamically based on the specific demands of each part of a task, rather than using a one-size-fits-all approach.
Methods
The authors propose a two-phase approach:
- Offline Code Generation: A task is first translated into a Foundation Model Program (FMP) using an LLM. This program is a neurosymbolic representation that outlines the computational workflow, including a sequence of generic neural function calls and their dependencies. This phase is agnostic to the specific FM backends used.
- Online Resource Allocation: For each input, a structured policy dynamically assigns specific FM "backends" (models with varying costs and capabilities) to each generic function call within the FMP. This is achieved using a Structured REINFORCE algorithm combined with Thompson Sampling. Instead of optimizing all backend selections jointly (which is computationally intractable), the approach decomposes the problem into N independent sub-policies, one for each function call. Each sub-policy learns to predict the reward (balancing accuracy and cost) for different backends and uses Thompson Sampling to balance exploration and exploitation, selecting the best backend for that specific sub-task and input.
Datasets
- New Benchmarks Introduced:
- Streaming Binary VQA: Focuses on yes/no questions over sequences of images, involving 33 compositional reasoning tasks with over 2,000 annotated images per task. It features realistic class imbalance and compositional queries (spatial, logical, numerical).
- Streaming Open-form VQA: Evaluates answering open-form questions on image sequences, with 50 queries and 25,000 images. It covers five reasoning categories (spatial, logical, numerical, comparative, external knowledge) and includes unanswerable images to test robustness.
Key Insights and Ideas
- Task Structure is Key: The core insight is that by representing tasks as programs with explicit dependencies, we can make much more informed and efficient resource allocation decisions than by treating the task as a monolithic block.
- Decomposition for Scalability: Decomposing the resource allocation problem into independent sub-policies for each function call is crucial. This avoids the combinatorial explosion of joint optimization and allows for more precise credit assignment, especially in programs with control flow.
- Dynamic Backend Selection: The ability to dynamically select backends based on input complexity and sub-task requirements is what unlocks significant resource savings. Cheaper, simpler models handle easy sub-tasks, while more complex ones are reserved for harder parts.
- Streaming Data Advantage: The streaming nature of the tasks allows for online learning where feedback is received after each decision, enabling the policy to adapt and improve over time.
Key Results
- Significant Resource Savings: The proposed FM Programming approach achieved up to 98% resource savings compared to monolithic multi-modal models on the streaming VQA benchmarks.
- Minimal Accuracy Loss: These savings were achieved with minimal to no loss in task accuracy.
- Superior Cost-Accuracy Trade-offs: The method consistently outperformed baselines (Single MLLMs, LLM Routing, Pareto Random) in terms of cost-accuracy and cost-F1 trade-offs, particularly in the low-cost regime.
- Adaptability: The framework demonstrated adaptability across different FM backend configurations, maintaining its performance advantage.
Limitations and Future Work
- Program Correctness: The framework's performance relies on the initial program structure being correct. An illogical program will lead to suboptimal performance regardless of backend allocation.
- Backend Pool Limitations: The policy is constrained by the capabilities of the available FM backends. If the pool is insufficient for a given subtask, optimal accuracy might not be achievable.
- Ground-Truth Feedback: The online learning algorithm requires immediate ground-truth feedback, which might not always be available in real-world settings.
- Error Propagation: The current model does not explicitly model error propagation, where an early mistake from a lightweight module could impact downstream steps.
Future Work: The authors suggest exploring broader applications in agentic and multi-agent systems, as well as investigating more advanced program synthesis techniques that jointly learn program structure and configurations.
Summary updated