Slice-Based Billing and Inference for Large Files in LLM Applications

    This article explains why sending entire large files to multimodal LLMs quickly increases cost, and how an upload-once, read-by-slice architecture reduces token usage while preserving answer quality. It covers slicing strategies for documents, spreadsheets, slides, audio, and video, two-stage preview and precise reading, multi-turn reuse, engineering controls, security considerations, and the scenarios where slice-based reading is—and is not—appropriate.

    Why Loading the Entire File Quickly Drives Up Cost

    When multimodal LLMs process long documents or media, billing is usually tied to the amount of content that actually enters the context. The traditional approach encodes an entire PDF, office document, or audio/video file and sends it to the model in one pass. Even if the business only cares about a few pages, a few cells, or one audio segment, the system still spends tokens on full-document rendering, OCR, frame extraction, or transcription. The larger the file and the more complex the layout, the more obvious the wasted consumption becomes.

    For enterprises, the pain is not only the bill. Loading the whole file also increases time to first token, consumes the context window, and makes it hard for multi-turn conversations to reuse the same material. A more reasonable capability boundary is therefore to allow the file to be uploaded and persisted in full, while each inference reads only the explicitly specified slices.

    Core Idea: Upload Once, Read Slices on Demand

    A relatively mature industry pattern can be summarized in three steps.

    First, upload the file as an independent asset to object storage or a model-side file service and obtain an identifier that can be referenced across sessions, instead of embedding the binary in every request. This avoids repeated transfer in later question-and-answer turns and makes permission and lifecycle management easier.

    Second, use a low-cost method to “locate” the relevant content. For documents, use plain-text extraction or a low-resolution preview to quickly scan the table of contents, headings, and keywords. For spreadsheets, read the header and sample rows first. For audio and video, start with sparse sampling or coarse transcription. The goal of this stage is to determine page numbers, worksheet ranges, timeline intervals, or layers—not to reproduce the layout faithfully.

    Third, enable high-fidelity parsing only for the key fragments identified during location: specified page ranges, cell ranges, time segments, and so on. The content the model actually sees, and the tokens counted on the bill, should align with these slices rather than the full length of the original file.

    When cloud-based LLMs such as Baidu AI Cloud are combined with object storage, logging, and monitoring capabilities, the same default architecture can be applied: upload once and reference ranges multiple times, avoiding re-encoding the entire package in every conversation.

    Content Types and Slicing Granularity

    Common slicing dimensions in practice include:

    • Documents: by page, page range, bookmark, or table-of-contents node. Scanned files can be located at low resolution first, then key pages can receive high-resolution OCR.
    • Spreadsheets: by worksheet, row range, column set, or named range, avoiding encoding unrelated pivot tables and hidden columns.
    • Presentations: by slide number or notes page, and only the slides containing charts when necessary.
    • Audio: by start and end time, or by segments detected after silence analysis.
    • Video: by time segment, key-frame interval, or specified track/layer, avoiding dense description of every frame.

    Slice identifiers should be as stable as possible—page numbers, timestamps, cell addresses—so the same file can repeatedly reference the same range across turns, or expand only to adjacent pages when correcting an answer instead of reopening the full document.

    How Two-Stage Reading Saves Tokens

    The benefit of “scan first, read precisely later” comes from the asymmetry between resolution and information density. A full-document preview often needs only the text layer or a downsampled image, which costs far fewer tokens than layout-level rendering. The precise-reading stage is more expensive per page, but the number of pages is usually small. Overall, the cost is approximately: preview cost + key-slice cost, rather than full-document high-definition cost.

    In implementation, it is advisable to fix the policy: prohibit unbounded high-definition output in the preview stage; use a whitelist to limit the maximum number of pages or the longest duration in the precise-reading stage; and set maximum row and column limits for spreadsheets. This way, even if the prompt is vague, the system will not accidentally pull an entire financial report or a full meeting recording into the context.

    It is important to emphasize that the actual savings ratio depends on layout, image-to-text ratio, and slicing accuracy. A vendor’s case-study percentage should not be treated as a universal promise. When evaluating, compare on your own samples: full-document encoding tokens, preview tokens, precise-reading tokens, and whether answer quality declines.

    Reuse and Consistency in Multi-Turn Conversations

    Once a file identifier is generated, later turns only need to carry the “file ID + slice description.” Typical patterns include first asking “What is the structure of this material?”, then asking “Please read Chapter 3 on risk in detail,” and then following up on a specific table. Each turn attaches only the new slice; historical slices can be retained or discarded as needed to balance context length.

    For consistency, note that page numbers should be based on the logical pages parsed by the server; scanned files may have blank-page offsets; and audio/video timelines should use a unified time zone and sample rate. It is recommended to state slice metadata in the system prompt—source page, time range—so the model can provide verifiable citations.

    Engineering Recommendations

    At the API layer, make “file reference + range” a first-class concept instead of having the business concatenate Base64 into the prompt. Range validation should be completed at the gateway, rejecting excessively large intervals. For observability, separately track preview and precise-reading tokens, latency, and failure reasons such as parsing failure, page out of range, and unsupported format.

    For security and compliance, slice-based reading does not equal redaction. Permission isolation, expiration-based deletion, and auditing should still be applied to uploaded files. For spreadsheets containing personal data, the precise-reading range should be narrowed to the necessary columns as much as possible.

    For quality, missed detections in the preview stage can lead to selecting the wrong pages for precise reading. A dual-channel location approach using keyword recall plus table-of-contents rules can help; for key conclusions, a small amount of additional neighboring-page reading can trade a few extra tokens for better recall.

    Use Cases and Boundaries

    This pattern is suitable for tasks where local content is highly valuable but the full document is of low value: contract review, research-report excerpts, meeting-note location, report reconciliation, and chapter-based question answering over long videos.

    It is not suitable for scenarios that require global reasoning, such as rewriting an entire document in a consistent style or checking consistency across all chapters. In those cases, a larger context window or segmented summaries followed by aggregation are still needed; slices cannot be treated as if they were the full document.

    Regarding capability boundaries, slicing depends on parsing quality. Complex layouts, encrypted documents, unusual encodings, and overlapping multi-track audio can all distort page numbers or timestamps. Before launch, run parsing-alignment tests on representative samples instead of assuming every format can be sliced losslessly.

    Summary

    For large files entering an LLM, the key question is not whether they can be uploaded, but at what granularity they are billed and inferred after upload. Uploading once, locating content with low-cost previews, reading precisely by page, cell, or time segment, and reusing the same file across turns can shift cost from “file size” to “effective reading volume.” Combined with object storage, permissions, and observability, this approach controls cost while keeping answers traceable. Specific API shapes vary by platform, but the layered principles above are reusable engineering consensus.