LLM Selection and Cost Optimization: A Practical Guide to Long Document Analysis

    As the number of large language models (LLMs) increases, model selection has shifted from a simple choice to a complex engineering decision. This article provides a practical guide to LLM selection and cost optimization using long document analysis as a use case. It covers task decomposition, establishing quality evaluation frameworks, calculating the true cost of tasks, and designing automated routing strategies to help teams balance model performance and operational expenses effectively.

    1. Why LLM Selection is an Engineering Problem

    In the past, when teams used LLMs, they often had only one or two fixed options, making the selection process straightforward. As the pool of available models grows, the question has shifted from “Can it work?” to “Which is more cost-effective?” Different models vary significantly in capabilities, response speed, context length, and unit pricing. The same task can yield vastly different results and incur different costs across various models.

    Without a systematic approach, teams tend to fall into two extremes: using the most powerful model for everything, leading to inflated costs; or using the cheapest model for everything, resulting in substandard outputs that require rework and ultimately increasing manual labor costs. Therefore, model selection must be treated like any other engineering decision, requiring clear metrics, testing workflows, and decision rules.

    2. Breaking Down Tasks: A Case Study on Annual Report Analysis

    Annual report analysis is a typical long document processing scenario that generally involves three categories of sub-tasks:

    1. Information Summarization: Reading lengthy materials to distill business performance, profit composition, risk warnings, and subsequent events, outputting a summary within a specified word limit.
    2. Data Extraction: Locating metrics from financial chapters, structuring them into tables, and annotating source page numbers.
    3. Result Validation: Checking the cross-referencing logic between numbers, such as verifying whether operating revenue matches the sum of its sub-items, or whether year-over-year changes are accurately calculated from raw data.

    These three types of tasks require different model capabilities. Information summarization relies on semantic understanding and length control; data extraction emphasizes precise localization and format stability; result validation requires a degree of reasoning capability. Assigning all three tasks to a single model is often neither economical nor stable.

    Benefits of Task Layering

    By layering tasks based on difficulty, you can assign low-cost models to simple sub-tasks while reserving high-capability models for complex reasoning. For example, mechanical operations like page tagging and header formatting typically do not require a top-tier model. Layering also provides teams with clearer visibility into where exactly the money is being spent.

    3. Establishing a Quality Evaluation Framework

    A prerequisite for model selection is the ability to determine whether the output is acceptable. It is recommended to define quantifiable acceptance criteria for each type of task:

    • Completeness: Does it cover all required questions?
    • Accuracy: Can key numbers be traced back to their corresponding page numbers in the original text?
    • Format Compliance: Does the word count exceed the limit? Are all table fields complete?
    • Consistency: After running the same material multiple times, are the core conclusions stable?

    During evaluation, use the same set of materials to conduct blind tests on candidate models—meaning human reviewers score the outputs without knowing the model names. Manual spot-checking of key numbers is more reliable than relying on overall impressions. Evaluation results should be recorded in a table for easy horizontal comparison.

    4. Calculating the True Cost

    The price of a single API call is only part of the cost. A more reasonable metric is the “cost per accepted task,” calculated as follows:

    Single Task Effective Cost = Single Call Cost × Average Attempts ÷ Acceptance Pass Rate

    This helps avoid a common misconception: a model with a low unit price might not result in a lower total cost if it requires multiple retries or extensive manual corrections.

    Common billing methods include charging based on input and output length, charging per call, or deducting from a unified quota. Different models may apply different billing multipliers. When reviewing billing documentation, focus on confirming the following:

    • Whether input and output are priced separately;
    • Whether there are time-based discounts or free quotas;
    • Whether long contexts are billed at a higher tier.

    Refer to the official documentation for the latest pricing rules published by the service provider. This article does not make specific numerical inferences.

    5. Designing an Automated Routing Strategy

    Once the mapping between sub-tasks and models is clear, you can implement automated routing using rules. A simplified approach is as follows:

    1. function route(task):
    2. if task.type in ["Format Conversion", "Page Tagging"]:
    3. return Low-cost model
    4. if task.type == "Information Summarization" and task.length <= Medium length:
    5. return Balanced model
    6. if task.type == "Data Validation" or task.requires_reasoning:
    7. return High-capability model
    8. return Balanced model
    9. function run_with_fallback(task):
    10. model = route(task)
    11. result = call(model, task)
    12. if not passes_validation(result):
    13. result = call(High-capability model, task)
    14. return result

    The key is to set up a fallback mechanism: if the low-cost path fails, automatically upgrade to a more powerful model instead of abandoning the task. Additionally, log the results of each routing decision and use this data to continuously optimize the rules.

    6. Risks and Precautions

    Financial analysis involves data accuracy and compliance requirements. When selecting models, pay extra attention to the following:

    • Data Boundaries: Confirm whether the materials contain sensitive information and comply with internal data processing regulations;
    • Traceability: Require outputs to include original page numbers for easy manual verification;
    • Manual Review: Key metrics must be verified item-by-item against the original report. Model results should not be used directly as a basis for external disclosure;
    • Cautious Conclusions: For judgmental statements regarding “risks” or “potential impacts,” retain the original text basis to avoid over-inference.

    7. Implementation Recommendations

    1. Select around ten historical materials to build a small-scale evaluation set.
    2. Record the quality scores, time consumption, and costs of each candidate model by task type.
    3. Assign a default model and a fallback model for each task category.
    4. Review cost and acceptance data monthly, and adjust routing rules based on changes.

    There is no one-size-fits-all answer to model selection. Model capabilities, prices, and service rules will change over time. What teams need is an evaluation mechanism that can run continuously. By clearly decomposing tasks, setting acceptance standards, and calculating costs down to a single effective result, model selection can evolve from an experience-based judgment into a reusable engineering workflow.