File Slicing for Large Language Models: On-Demand Loading and Cost Control

    This article explains how to slice documents, spreadsheets, and audio/video before they enter a large language model context. It separates upload, parsing, and inference; describes page, range, and time-window selection; and outlines a locate–slice–verify–expand workflow plus metrics that balance cost with answer quality.

    1. From whole-file input to task-driven loading

    In large-model applications, uploading a file is only the start of processing. What actually drives analysis quality and resource use is which content is parsed, how it is represented in context, and whether it is relevant to the current task.

    Typical failures include sending every page image of a long report when the user only needs payment terms; loading every worksheet when only one month of sales is required; or processing a full audio track when only one discussion segment matters. These approaches are simple, but they inject large amounts of irrelevant information.

    File slicing sits between parsing and inference as an explicit scope choice: limit processing to pages, worksheets, cell ranges, or time intervals, then pick representations—text, images, data, formulas, or audio—according to the task.

    It is not merely shrinking the uploaded file, and it is not deleting unused results after generation. Screening should happen before content enters the model context. If the service supports native range handling, the app can submit a file reference plus a processing range; otherwise preprocessing happens on the application side. The two paths differ in capability, cost, and complexity.

    2. Separate upload, parsing, and inference

    Cost discussions should not mix file size, processing volume, and token usage.

    2.1 Upload: transfer and storage

    Upload covers network transfer, storage, access control, and retention. Analyzing two pages may still require uploading the whole file, so slicing does not automatically cut upload traffic.

    For files that are analyzed repeatedly, reuse a file reference when authorization and retention allow. Reusing a reference is not free inference, and it does not imply that parse results are cached.

    2.2 Parsing: converting files into usable content

    Parsing may extract text, recognize page images, read table structure, fetch formulas, transcribe media, or sample video frames.

    Whether slicing reduces parse cost depends on whether the engine can read by range and whether the file has cross-region dependencies. Some files need a table of contents or structure first; spreadsheet formulas may reference other sheets. Requesting a subset does not always mean only those bytes are read.

    2.3 Inference: sending only necessary context

    Inference scale tracks what is actually submitted, but text, images, audio, and video may be billed differently. Bills may also include parsing, media processing, cache, and output.

    A careful claim is: good slicing can reduce irrelevant input and related resource use. Whether total cost falls, and by how much, depends on the billing model and measurement—not a blanket promise that only the selected slice is charged.

    3. Documents and slides: page range and representation both matter

    Document slicing must answer two questions: which pages, and how those pages are viewed.

    3.1 Keep semantic boundaries when selecting pages

    A page is a convenient unit, not always a complete semantic unit. Clauses can span pages, tables can continue, and notes may sit at the end of a section.

    For locating a clause, identify candidate pages, then check neighbors for continuation, conditions, or exceptions. For contracts and policy documents, a keyword on one page does not mean that page is enough.

    A safer pattern is candidate-page location, adjacency check, then necessary expansion—not a fixed single-page crop.

    3.2 Text for retrieval, images for layout

    Extracting paragraphs, summarizing sections, or finding keywords usually works better with page text and a smaller input.

    Tasks that depend on table alignment, annotation position, legends, flowcharts, or multi-column layout often need page images. Text extraction can keep every word and still lose which caption belongs to which figure.

    A practical pattern is text-first localization, then image analysis on key pages. Combine representations as needed; do not always load both.

    3.3 Choose resolution for readability

    Lower resolution is enough for coarse layout; higher resolution helps with small type, dense tables, or chart labels. Higher resolution increases processing, and gains depend on source quality. Validate on real samples rather than defaulting to high resolution.

    4. Spreadsheets: crop ranges with business and formula dependencies

    The hard part of spreadsheets is not only volume, but headers, units, formulas, and cross-sheet references that give numbers meaning.

    4.1 Select worksheets, then cell ranges

    For workbooks with multiple periods or departments, locate relevant sheets first, then the necessary cells. Keep column headers, row labels, and units so the model does not see isolated numbers.

    Values such as 100, 120, and 150 cannot be interpreted as revenue, quantity, or budget without dates, currency, or statistical definitions.

    4.2 Data, formulas, and visuals play different roles

    Totals and line items mainly need values. Debugging calculation errors needs formulas and their dependents. Explaining a chart needs legends, axes, and source data.

    Values alone hide the calculation path. Formulas alone may be insufficient if referenced cells sit outside the selected range.

    4.3 Integrity-check the crop

    Check for cross-sheet references, hidden rows or columns, merged cells, totals rows, and comments outside the range. Not every task needs all of these, but it should be clear which omissions can change conclusions. For financial checks and metric audits, keep the calculation chain complete before further compression.

    5. Audio and video: time windows and information density

    Media analysis is driven by clip length, frame sampling, resolution, and content representation.

    5.1 Leave margin around time crops

    If the user cares about one utterance, cover the full question, answer, and needed follow-up. Tight windows can cut sentences or drop referents such as “this plan” or “the data above.”

    If transcription locates timestamps and original media is then read, allow for alignment error and keep a buffer rather than treating hits as exact cut points.

    5.2 Match frame rate to how fast events change

    Talk-heavy video with little visual change can use sparse frames. Demos, fast motion, or anomaly localization need denser sampling on candidate segments. Lower density reduces image input but can miss brief events. Coarse locate, then denser inspection, is usually better.

    5.3 Let the question choose modalities

    Minutes rely mainly on speech. Procedure analysis also needs picture. Sound-event judgments cannot rest on transcripts alone. Transcripts miss tone, pauses, and non-speech audio; frames do not replace sound.

    The goal is not to drop modalities, but to cut redundancy while keeping evidence the task needs.

    6. A locate–slice–verify–expand pipeline

    A production system should not leave all range choice to the user, nor load every file unconditionally. A workable flow:

    1. Clarify the task: extraction, summary, calculation check, or visual judgment, and the required content types.
    2. Read structure: table of contents, page count, sheet list, or media duration.
    3. Propose candidate ranges from keywords, structure labels, or indexes.
    4. Load local content in the representations the task needs.
    5. Check evidence completeness: missing definitions, units, context, or dependencies.
    6. Expand only if evidence is insufficient; if still uncertain, report the limitation.

    Illustrative internal planning logic (not a real service API):

    1. task = analyze user question
    2. structure = get file structure
    3. range = locate candidate content(task, structure)
    4. repr = select required content types(task)
    5. evidence = read content(range, repr)
    6. check = inspect context and dependencies(evidence, task)
    7. if check shows insufficient evidence:
    8. range = expand necessary context(range, check)
    9. evidence = read content(range, repr)
    10. generate answer with source locations and uncertainty(evidence)

    Cap expansion count, processing budget, and timeouts so repeated context fills do not erase cost control.

    7. Evaluate cost and quality together

    Slicing cannot be judged only by how much input shrank. After savings, answers must still be accurate, complete, and traceable.

    Track at least:

    • Input scale: text tokens, page count, media duration, and frame samples.
    • Latency: locate, parse, infer, and retry.
    • Actual cost: real bills, not text-length estimates.
    • Task quality: field accuracy, calculation correctness, missed key facts.
    • Evidence coverage: answers mapped to pages, sheet ranges, or timestamps.
    • Expansion rate: how often the first slice had to grow.

    On the same questions and samples, compare whole-file processing, fixed-range slicing, and task-dynamic slicing, holding other conditions constant. Include hard cases: cross-page clauses, cross-sheet formulas, poor scans, and events near time boundaries.

    Savings depend on redundancy and task mix; a few cases are not a general guarantee.

    8. Permissions, defaults, and platform limits

    Slicing is not access control. Confirm the user may access the file and target content before locate and load; if local analysis depends on other regions, re-check those permissions.

    Define defaults: which pages, sheets, and modalities load when range or type is unspecified. Cost-sensitive apps should log the selection policy so default changes do not silently inflate input.

    Partial load usually cannot bypass upload size, page, or duration limits. Oversized files may still need preprocess or split. Splits should keep original position maps so page numbers and timestamps remain meaningful for verification.

    9. Conclusion: optimize cost on complete evidence

    File slicing turns large-file processing from “read everything, then find the answer” into “assemble the evidence the task needs.” It affects parse scope, representation, inference input, and verification, so it is not a single token-reduction switch.

    Reliable practice: locate relevant content, then load suitable representations; keep semantics and dependencies intact, then drop irrelevant input; validate with real cost and task quality. That is how on-demand loading becomes a sustainable engineering optimization rather than cheaper answers that are incomplete.