Controlling File Slicing for Large Models: Load on Demand to Cut Token Costs

    This article explains how file slicing control reduces the token cost of large multimodal models by loading only the relevant parts of a file instead of the entire document. It breaks the capability into four dimensions—spatial, temporal, fidelity, and semantic—describes the default behavior when no options are passed, and quantifies typical savings. It also provides a selection checklist, engineering practices such as two-stage retrieval and cost observability, and notes the limits of what slicing can solve.

    1. Why Large Files Are Becoming the Main Source of Context Cost

    In scenarios like enterprise knowledge base Q&A, contract review, financial report analysis, and meeting recording retrieval, the input is no longer a short prompt of a few hundred words. It is often a document dozens or even hundreds of pages long, a spreadsheet with multiple worksheets, or audio and video material measured in hours. Sticking with the “upload the whole file and feed everything into the context” approach triggers three problems at once.

    The first is cost. Multimodal input is usually billed by page, by second, or by number of images converted into tokens. Page count and duration scale the bill linearly, yet users often care about only one or two pages or a few dozen seconds.

    The second is quality. Once irrelevant content fills the context window, attention is diluted. The model is more easily distracted by similar clauses or adjacent table data, producing off-topic answers or citing the wrong page.

    The third is engineering. Large file uploads take a long time, retries are expensive, cache hits are hard to achieve, and end-to-end latency becomes unpredictable.

    As a result, the industry is shifting from “enlarging the window” to “precise feeding”: letting the caller declare, at request time, the specific scope the model should inspect, and sending only the relevant fragments into inference.

    2. Capability Model: Four Dimensions of File Slicing Control

    A cloud vendor recently introduced native file slicing control in its multimodal model API, alongside native upload support for office documents and open document formats. Stripping away the specific product form, this capability can be abstracted into four orthogonal dimensions.

    1. Spatial dimension: select pages or regions. Documents and presentations can be cropped by page number or page range; spreadsheets can specify a worksheet and cell range, avoiding loading an entire workbook.
    2. Temporal dimension: select segments. Audio and video support trimming start and end times, keeping only the target interval.
    3. Fidelity dimension: select resolution and frame rate. Documents offer low, medium, and high rendering resolution; video allows adjusting frame rate and image resolution to balance clarity against tokens.
    4. Semantic dimension: select the content layer. Documents can choose the page text layer or the page image layer; tables can choose computed values, formulas, worksheet names, and so on; video can choose transcript text, frames, or the audio track; audio is mainly handled by time interval.

    The four dimensions can be freely combined. Essentially, this turns the “file” from an indivisible minimal input unit into an addressable, structured data source.

    3. Default Behavior: What Happens When You Pass No Options

    The easiest pitfall in engineering is the default semantics. Under the common convention of this type of API, when processing options are omitted: documents and presentations are loaded by default as page images that preserve the original layout, meaning visual information takes priority; spreadsheets include by default the computed values, formulas, and worksheet names of all worksheets, meaning structured information takes priority.

    This means two things. First, the default behavior is not necessarily the most token-efficient; if the task only needs text, you should explicitly switch to the text layer. Second, the default behavior already tries to ensure the result is “usable,” which suits quick validation; before production, you should declare parameters explicitly to make cost predictable.

    1. # Example: load only the text layer of pages 3-5
    2. resp = client.generate(
    3. model="multimodal-model",
    4. contents=[
    5. {"type": "file", "file_uri": uri,
    6. "options": {"pages": "3-5", "layer": "text", "resolution": "medium"}},
    7. {"type": "text", "text": "Summarize the core clauses on these three pages"}
    8. ]
    9. )
    1. # Example: take only the computed values in range B2:D20 of a specific worksheet
    2. resp = client.generate(
    3. model="multimodal-model",
    4. contents=[
    5. {"type": "file", "file_uri": sheet_uri,
    6. "options": {"sheet": "Q3", "range": "B2:D20", "layer": "values"}},
    7. {"type": "text", "text": "Compare the quarter-over-quarter changes across regions"}
    8. ]
    9. )

    4. Quantifying the Gains: Why Slicing Can Deliver an Order-of-Magnitude Drop

    Early adopters’ measurements show that extracting text by page can use an order of magnitude fewer tokens than rendering an entire document. In another set of tests, slicing reduced document-type prompt tokens by about two-thirds and workbook-type tokens by about one-third. The difference in reduction exactly confirms the dimension analysis above: the text layer is cheaper than the image layer, a single page is cheaper than the whole document, and a specified range is cheaper than an entire workbook.

    It is worth stressing that these numbers come from specific workloads and should not be treated as a universal promise. A reliable estimate of the savings is:

    savings ratio ≈ 1 − (converted size of the target fragment / converted size of the full file)

    When the target fragment is a very small share of the whole (for example, finding two pages in a hundred-page contract), the gain approaches an order of magnitude. When the target is widely scattered (for example, reading the whole text to write a summary), the gain from slicing is limited, and you should instead focus on resolution and layer selection.

    5. Selection Checklist

    • Task needs only text: choose the text layer plus low-to-medium resolution for the largest gain.
    • Task depends on layout, stamps, or chart appearance: choose the page image layer; if necessary, use high resolution but narrow the page range.
    • Spreadsheet numeric reconciliation: choose the computed values layer plus a precise range; add the formula layer only when you need to audit formula logic.
    • Finding “a specific sentence” in video: first use the transcript to locate the timestamp, then pull frames from that time interval to verify.
    • Audio retrieval: trim the interval first, then decide whether to transcribe.

    6. Engineering Best Practices

    First, two-stage retrieval. Stage one uses low resolution, the text layer, and coarse intervals to locate content; stage two performs high-fidelity loading only on the matched fragments, forming a “coarse then fine” funnel.

    Second, bring parameters into the configuration and experimentation system. Page numbers, layers, and resolution should be versionable configuration, paired with A/B evaluation, so that cost savings do not come at the expense of key metrics.

    Third, make cost observable. Log the converted input size, slicing parameters, and matched fragments for each request at the gateway layer, and aggregate by business dimension to pinpoint abnormal growth.

    Fourth, keep a fallback path. When slicing parameters do not match the actual need, allow falling back to full-file loading and record the fallback reason for tuning.

    Fifth, mind the capability boundaries. This type of capability typically covers the current mainstream multimodal model family, and existing file size and page count limits are not relaxed. Slicing solves “how much to send in,” not “how large a file can be uploaded.”

    7. Conclusion

    File slicing control moves context engineering from coarse to fine: using pages, regions, time intervals, and content layers as coordinates, taking only what is needed on demand. For developers, the real payoff is not just a lower bill, but faster responses, more accurate citations, and more stable evaluation. In relevant model services and document intelligence scenarios, Baidu AI Cloud likewise recommends organizing input around the principle of “minimum sufficient context,” bringing cost, quality, and latency into the design constraints at the same time.