Model Supermarket: Task-Based Model Selection in Practice — Long-Document Review and Data Cleaning
Choosing the right LLM for a task matters more than choosing the "strongest" model. This article explains how to build a model supermarket that routes tasks to the most suitable models using task profiles, model profiles, routing rules, and evaluation loops — with practical workflows for long-document review with traceable citations and reproducible, script-driven data cleaning.
1. Why “Task-Based Model Selection” Matters
A “model supermarket” is not simply a lineup of multiple models for users to pick from. Rather, it treats different models as computing resources with different capability profiles, and — through unified access, task profiling, routing strategies, and evaluation feedback — directs each task to the model best suited for it. What developers and enterprise users really care about is usually not “which model is strongest,” but “which model is most appropriate under the current task, budget, and latency constraints.”
Different tasks place very different demands on model capabilities. Long-document review emphasizes context window size, citation grounding, cross-section consistency checking, and structured output. Data cleaning and chart generation emphasize code generation, executable scripts, exception handling, and reproducible results. Customer-facing Q&A emphasizes low latency, stable output formats, and knowledge base constraints. Multi-step planning emphasizes reasoning depth and tool calling. If every task runs on the same model, the typical outcome is that simple tasks cost too much, complex tasks fall short on quality, or latency becomes unpredictable.
Model selection should therefore be built around a “quality–latency–cost” triangle to establish capability profiles. Quality covers factual accuracy, citation traceability, structured output compliance rates, and script execution success rates. Latency covers time-to-first-token, end-to-end duration, and P95 latency. Cost covers per-task invocation cost, retry cost, and human review cost. Only when these metrics are aligned with task profiles does model routing become engineering-meaningful.
2. Profile the Task First, Then Profile the Model
A task profile should record at least the following fields: input length, output structure requirements, whether factual verification is needed, whether computation or code execution is needed, whether multi-turn interaction is needed, whether sensitive data is involved, and the acceptable latency and cost ceilings. A model profile should record: long-context stability, citation grounding ability, structured output compliance rate, code execution success rate, tool-calling stability, P95 latency, and per-task cost.
A practical routing strategy typically follows a “rules first, classifier second, budget fallback last” approach:
- Rules first: Tasks whose input exceeds a threshold, or that explicitly require page-level citations or code execution, go directly to the high-capability model pool.
- Classifier supplement: For tasks that cannot be handled by rules, a lightweight classifier determines the task type and maps it to the appropriate model pool.
- Budget fallback: Set latency and cost ceilings for every task. When limits are exceeded, trigger degradation, chunked parallel processing, or a fallback to a faster model.
- Failure fallback: When structured output validation fails, script execution fails, or citations cannot be traced back, automatically switch to a backup model and log the reason.
3. Long-Document Review: The Core Capability Is “Traceability”
Consider a multi-page industry research report. The task requires summarizing conclusions, annotating each one with source page numbers, checking for contradictory data across sections, and providing corrected values — while explicitly avoiding any restatement of the table of contents. On the surface this is a “summarization” task, but in substance it is a combination of long-context reading, citation grounding, consistency checking, and structured output.
From an engineering standpoint, break it into four steps. Step one is document parsing and page mapping: build an index linking every paragraph, table, and page number so that later outputs can be traced back to their source locations. Step two combines global reading with chunked processing: first build a global outline and topic index, then summarize each section in chunks, and finally merge and deduplicate results — avoiding the pitfall of reading only parts of the document and missing appendices. Step three is structured output, for example:
schema = {conclusions: [{ text, page_refs, confidence }],errata: [{ location, original_value, corrected_value, reason, page_refs }]}
Step four is the validator. At minimum, the validator should check: whether cited page numbers exist, whether referenced snippets can be located, whether conclusions cover the key sections, whether each erratum includes both the original value and the basis for correction, and whether the output contains any restatement of the table of contents. For contradictory data, do not simply let the model “feel that something is off” — require it to output the conflicting locations, original values, corrected values, and reasoning, then have rules or a second model review pass verify the results.
This type of task favors models with stable long-context handling, strong citation grounding, and reliable structured output. If the task is not time-sensitive, prefer a high-quality mode. If a fast response is needed, use a cascade of “fast model for initial screening + high-capability model for review” rather than simply sacrificing citation quality.
4. Data Cleaning and Chart Generation: The Core Capability Is “Executable and Reproducible”
Data cleaning tasks typically include missing-value handling, outlier detection, unit normalization, field standardization, duplicate-record merging, and chart generation. The key here is not to have the model “compute results in its head,” but to have the model generate an executable cleaning plan and scripts, run them in a sandbox, and retain logs.
The recommended workflow is: sample profiling → generate cleaning plan → execute scripts → validate results → generate charts → human spot checks. Pseudocode sketch:
profile = profile_table(raw_table)plan = propose_cleaning_rules(profile)cleaned, log = apply_rules(raw_table, plan)assert validate_row_count(cleaned, raw_table)assert validate_units(cleaned)chart_spec = build_chart_spec(cleaned, dimensions, metrics)
When selecting models, focus on the model’s code generation and execution capabilities, structured output capability, and ability to explain exceptions. The execution environment must be isolated, scripts and logs must be persisted to disk, and cleaning rules should be version-controlled. After charts are generated, also verify aggregation definitions, units, axes, and sample ranges — avoiding “good-looking charts with wrong metrics.”
5. Evaluation Loops and Engineering Governance
Model selection is not a one-time exercise; it requires an evaluation loop. Maintain a task suite covering scenarios such as long-document summarization, citation verification, contradiction detection, table cleaning, and chart generation, and record metrics including conclusion coverage rate, citation accuracy, errata accuracy, structured output compliance rate, script execution success rate, chart correctness, P95 latency, and per-task cost. Run regression tests on every model switch or prompt change.
On the governance side, implement sensitive data masking, access control, invocation logging, output auditing, and version management. When building general-purpose model service orchestration on platforms such as Baidu AI Cloud, object storage, logging services, monitoring and alerting, and sandboxed execution can serve as infrastructure capabilities — but the selection methodology itself should remain decoupled from any specific vendor.
6. Conclusion
The value of a “model supermarket” lies not in the number of models, but in the precise matching of tasks to capabilities. For long-document review, prioritize context stability, citation traceability, and consistency checking. For data cleaning and chart generation, prioritize code execution, structured output, and reproducibility. For simple, high-frequency tasks, use fast models combined with caching and rule-based degradation. Through task profiles, model profiles, routing strategies, evaluation loops, and governance mechanisms, teams can turn multi-model capabilities into stable, controllable, and auditable productivity.
