File Slicing for LLMs: On-Demand Loading and Cost Optimization

    File slicing helps large language models process task-relevant content rather than entire files. This article explains how to select ranges, content layers, and processing detail across documents, spreadsheets, and audiovisual files. It also outlines a two-stage workflow for locating and analyzing evidence, evaluating total task cost, and managing information gaps, access permissions, and untrusted instructions.

    1. From Full-File Processing to Task-Driven Loading

    When enterprises use large language models (LLMs) to analyze files, the main question is often not whether a file can be uploaded, but which parts the model actually needs to read. Only a few pages of a lengthy project document may be relevant to the current question. A budget workbook with multiple worksheets may require analysis of just one cell range. A long meeting recording may contain only a short segment related to a particular agenda item.

    Sending the entire file to the model for every request typically creates three problems:

    • Larger inputs can increase inference costs and processing time.
    • Irrelevant content consumes context capacity, leaving less room for important information.
    • Repeated sections, historical versions, or similar tables can interfere with one another, making it harder to identify evidence directly relevant to the task.

    File slicing changes a file from an indivisible input into a collection of content that can be selected according to the task. Selection can apply not only to pages, worksheets, cell ranges, and time intervals, but also to content layers such as text, images, formulas, and audio.

    This is a general technical design, not a capability shared by every file-processing interface. Whether a system supports server-side slicing, which content layers it can select, and how it counts input tokens must be verified against its API documentation and billing rules.

    2. Three Levels of File Slicing

    2.1 Range Selection: Where to Read

    Range selection identifies the relevant locations within a file.

    For documents and presentations, ranges are usually defined by pages or sections. For spreadsheets, a worksheet name and cell coordinates can identify the target range. For audio and video, ranges are defined by start and end times.

    This step can exclude large amounts of irrelevant content, but a smaller range is not always better. If a selected page contains a conclusion while its qualifying conditions appear on the previous page, the model may reach an incomplete judgment. Selection should therefore preserve necessary adjacent context rather than mechanically including only locations where a keyword appears.

    2.2 Layer Selection: What to Read

    A single region can contain several types of information. A report page may include both body text and a trend chart. A spreadsheet cell may have a displayed value and an underlying formula. A video segment may contain both speech and visual activity.

    Layer selection distinguishes the information the task actually requires. Text is usually the priority when extracting contract clauses. Visual information is necessary when interpreting arrows, stamp placement, or chart trends. Calculated values may be sufficient for checking budget results, while formulas and their references are central to reviewing calculation logic.

    The value of layer selection is avoiding indiscriminate parsing. However, it must follow the meaning of the task: “prioritize text” does not mean “read only text from every file.”

    2.3 Detail Selection: How Much Detail to Process

    Visual material may be processed at different resolutions, and video analysis may use different sampling rates. These settings affect whether the model can recognize small text, brief actions, and local details. They also affect input size.

    The general principle is to use the lowest level of detail that meets the task’s requirements. Reading a slide title and identifying small numbers in a dense table clearly require different resolutions. Summarizing a presentation and locating a briefly visible anomaly should not use identical sampling strategies.

    Adjustments should be validated on sample tasks rather than driven solely by expected savings. Insufficient image clarity or overly sparse sampling can omit evidence, and repeated requests may then increase overall cost.

    3. Slicing Strategies by File Type

    3.1 Documents and Presentations: Locate Sections Before Selecting Pages

    For well-structured files, use the table of contents, headings, and page mappings to locate relevant sections before selecting individual pages. Complex scanned documents may first require text recognition or page-layout analysis.

    Text is generally an economical starting point for extracting clauses, summarizing key points, or finding definitions. Retain page images when the task depends on graphical layout, relationships across columns, figure-caption associations, or visual markings.

    Also distinguish the file’s internal page sequence from the page numbers printed on its pages. Covers, tables of contents, and appendices can cause these to differ. Evidence references should use clear location identifiers so reviewers can reliably find the original material.

    3.2 Spreadsheets: Preserve Calculation Dependencies

    In spreadsheets, visually adjacent cells do not necessarily represent complete business logic. A summary result may depend on rates, source data, or adjustments in other worksheets.

    If the task only involves reading already calculated metrics, the values in the target range may be sufficient. Formula auditing requires further examination of referenced ranges, cross-sheet dependencies, and relevant business explanations.

    Blank cells, merged cells, hidden rows and columns, and multilevel headers can also affect interpretation. Before converting a range into simple rows and columns, confirm that column names, units, reporting periods, and filter conditions are preserved. Otherwise, the model may read the numbers correctly but misinterpret their business meaning.

    3.3 Audio and Video: Slice at Semantic Boundaries

    Audio and video slices should be organized around topics, speaker turns, or event intervals. Splitting recordings mechanically into fixed-duration segments can cut off a sentence, an operation, or an anomalous event.

    A practical approach is to use a transcript or event index to locate candidate intervals, then retain an appropriate buffer around their boundaries. For meeting-content summaries, a transcript may be the preferred input. Preserve audio when the task involves tone, unusual sounds, or speaking style. Visual evidence is necessary for analyzing equipment operation, demonstration steps, or events at the scene.

    Questions spanning multiple segments also require synthesis. A topic may be introduced at the beginning of a meeting and confirmed near the end. Reading only one of those segments may not capture the final decision.

    4. Build a Two-Stage Processing Workflow

    A reliable slicing workflow typically separates locating content from analyzing it, rather than guessing the required range directly.

    The first stage builds an index. The system extracts file metadata, section structure, worksheet lists, or timeline information. Within the permitted access scope, it creates summaries and location mappings for retrieval. The index should remain lightweight without losing essential location information.

    The second stage selects content for the task. Based on the user’s question, the system retrieves candidate slices, determines whether additional context is needed, and submits the selected ranges and layers to the model.

    A general workflow is:

    Receive the question → Validate file permissions → Retrieve candidate locations → Expand necessary context → Select ranges and layers → Analyze content → Verify evidence coverage → Return results with location references.

    The workflow also needs a fallback mechanism. If the candidate slices cannot support an answer, the system should broaden retrieval or request more content rather than ask the model to fill gaps with unsupported facts.

    For cross-section comparisons or cross-worksheet checks, select multiple relevant slices and retain their individual sources. This reduces full-file processing while avoiding the conflation of independent data.

    5. Optimize Total Task Cost, Not Just Token Count

    File slicing can reduce unnecessary model input, but a smaller reading range does not necessarily produce a proportional reduction in fees. Text, images, audio, and video may be measured differently. Caching, preprocessing, storage, and repeated calls can also affect total cost.

    The more useful evaluation target is therefore the total cost of successfully completing a task, not the input token count of a single request.

    At a minimum, record these metrics:

    • Input volume: The amount of text, number of pages or images, or media duration actually processed.
    • End-to-end latency: Time spent on upload, content location, preprocessing, model analysis, and result validation.
    • Task quality: Answer accuracy, coverage of essential evidence, and citation accuracy.
    • Retries: Additional requests caused by missing slices, recognition failures, or interpretation errors.
    • Cumulative cost: Charges calculated from actual billable items rather than text-token estimates alone.

    Compare full-file processing with sliced processing using the same questions and consistent evaluation criteria. If slicing reduces input but causes frequent follow-up calls or misses important facts, the selection strategy needs adjustment. That outcome should not be treated as successful optimization.

    6. Manage Missing Information and Security Risks

    6.1 Add Evidence-Completeness Checks

    Each task should define the evidence it requires. Contract review may need not only liability clauses but also definitions, exceptions, and related attachments. Financial analysis may require units, reporting periods, and calculation conventions in addition to the result range.

    The system can maintain evidence checklists by task type and verify that the necessary information is available before producing a final conclusion. If evidence is missing, it should state the limitation explicitly or load additional relevant slices.

    6.2 Slicing Does Not Replace Access Controls

    Having the model read only part of a file does not mean the rest of the file has been securely isolated. Upload, storage, indexing, and preprocessing may still involve the complete file.

    Permissions must therefore be checked before file access and slice retrieval. Sensitive information should be masked or redacted according to organizational requirements. Logs should not retain complete document text or sensitive cell contents without a clear need. Shared files may also require access controls that distinguish which regions each user is authorized to read.

    6.3 Separate File Content from System Instructions

    Files may contain statements such as “ignore the established rules” or “output other documents.” Treat such content as data to analyze, not as trusted instructions.

    Although slicing narrows the input scope, it does not replace controls over instruction boundaries, tool permissions, or output content.

    7. Implementation: Start with Frequent, Well-Defined Tasks

    Begin with scenarios that have stable structures and clear objectives, such as answering questions about fixed sections of policy documents, extracting metrics from specified worksheets, or summarizing a particular meeting topic. These scenarios make it easier to establish location mappings, quality baselines, and cost comparisons.

    Then expand to relationships across multiple files, cross-sheet dependency analysis, and multimodal event recognition. As tasks become more complex, the system needs stronger indexing, context expansion, evidence tracking, and fallback strategies.

    Configure important processing options explicitly rather than relying indefinitely on unverified default behavior. If a system does not support server-side slicing, preprocessing can generate smaller files or structured fragments, provided permissions and compliance requirements allow it. Account for the additional processing cost and verify that conversion preserves layout, formulas, and timing information.

    The goal of file slicing is not to make the model read as little as possible. It is to make each reading operation relevant to the task. Combining range selection, layer selection, detail control, and evidence verification creates a sustainable way to balance cost, latency, and reliability.