Why LLMs Cut Corners on Long Documents: Prompt Engineering in Practice and Its Limits

    When large language models process dozens of long reference documents, they often cite only a few keyword-matched passages while ignoring relevant information buried deeper in the material. This article explains how to choose the right model, diagnose shallow reading behavior, apply a four-step prompt template with measurable evaluation criteria, and deploy the workflow on Baidu AI Cloud with proper engineering guardrails—while being clear about what prompt engineering can and cannot guarantee.

    1. Choose the Model Based on the Task

    Models differ in architecture, training corpora, and alignment strategies, and no single model performs best on every task. When evaluating candidates, compare the following dimensions: context window size, per-inference cost, response latency, and auditability of the output—for example, whether the model can reliably cite sources and produce results in a fixed structure.

    For open-ended problems such as architecture design or technical solution evaluation, leading models typically produce well-structured proposals. However, for tasks that require precise citation of source details, the same model may still produce citation errors or omissions. Therefore, model selection decisions should come from testing on your own business data, not from public leaderboard rankings.

    2. Retrieval-Style Reading in Long-Context Scenarios

    When feeding dozens or even hundreds of reference files to a model, developers often observe a pattern: the model concentrates its citations on a small number of passages that match keywords, while overlooking relevant information deep in the documents. This behavior may be related to context window limits, attention computation costs, and retrieval-style usage patterns. The exact behavior varies by model and invocation method, so it must be confirmed through testing rather than assumed to apply to all models.

    The consequences are direct. The model may miss related information scattered across different files, produce one-sided conclusions, or generate logical contradictions between conclusions. To diagnose this, deliberately embed several key facts into your test material and check whether the model’s output references them—this reveals whether the reading was thorough.

    3. Prompt Template and Evaluation Method

    A prompt alone cannot guarantee that the model has actually read everything; it can only guide the model to organize its analysis following a specific process. The template below breaks the task into four steps: reading block by block, filtering relevant files, interrogating core conclusions, and outputting structured results with citations.

    1. [Role]
    2. You are an analyst experienced in system architecture and technical evaluation.
    3. [Task]
    4. Current task: {task_description}
    5. [Material]
    6. The following is block {i} of {n}. Each file carries an ID. Read every block and produce one summary per file.
    7. [Processing Rules]
    8. 1. Read every file without skipping. Mark any file that cannot be read as "unprocessed" and explain why.
    9. 2. Determine whether each file is relevant to the task, and list relevant file IDs with reasons.
    10. 3. Challenge the core conclusions with key questions, e.g.: What assumptions does this conclusion rely on? Which piece of evidence is weakest? How would the conclusion change if the assumption fails? Revise or abandon conclusions based on this interrogation.
    11. 4. Attach the source file ID and original location to every conclusion. Mark conclusions without supporting evidence as "to be verified."
    12. 5. Output structure, in order: list of relevant files, key evidence table, conclusions, items to be verified.

    Step 3 requires the model to output the interrogated conclusions and their evidence, not the full internal reasoning process. This keeps conclusions auditable and makes it easier to retain review material in logs.

    Several engineering measures are also needed. First, split the material according to the model’s context limit; each chunk’s token count should be well below the limit, with some overlap between adjacent chunks. Second, generate a summary for each chunk first, then aggregate them into the final conclusion—a map-reduce style process. Third, record the processing status of every file; unfinished files must not enter the conclusion generation stage.

    To judge whether the method works, compare two prompt groups on the same task: a baseline prompt and the template above. The evaluation table can follow this design:

    Metric Description Pass Criteria
    Key information recall Proportion of embedded key facts correctly cited Higher than the baseline prompt, with specific values reported
    Cross-document logic gaps Number of missing or contradictory conclusions, manually annotated No higher than the baseline prompt
    Citation accuracy Proportion of citations with correct file ID and location Sampled proportionally; results must be recorded
    Human scoring At least two reviewers scoring against a unified rubric Inter-reviewer agreement meets a pre-agreed threshold

    The test set should contain known answers and cover information at different file lengths and positions; otherwise, the evaluation results prove nothing.

    4. Engineering Boundaries for Cloud Deployment

    To deploy this workflow on the cloud, you can use the following pipeline: store the material in Baidu AI Cloud Object Storage (BOS); upload events trigger Baidu AI Cloud Function Compute (CFC) via a message queue; the function calls the LLM inference API chunk by chunk; results are written to structured storage with logs retained. Refer to the official documentation for specific configuration items.

    The following issues must be addressed in production:

    • Permissions: Grant the function’s execution role read/write access only to the required buckets and model APIs, following the principle of least privilege.
    • Failure handling: Retry with exponential backoff on API timeouts or rate limiting, set a maximum retry count, and send tasks exceeding the limit to a dead-letter queue for manual intervention.
    • Idempotency: Deduplicate repeated triggers of the same material using a task ID to avoid duplicate billing and duplicate writes.
    • Log redaction: Logs should only record structured fields such as task ID, file ID, latency, and conclusion summary. Sensitive content such as phone numbers, keys, and identity information must be redacted or never written to disk. Persisting the model’s full reasoning process is not recommended.
    • Cost control: Estimate per-task cost based on chunk count and output length; set per-task budget caps and concurrency limits, pausing and alerting when exceeded.
    • Coverage checks: Write each file’s processing status to a task table. If any file is missing, the conclusion stage fails directly rather than outputting incomplete results.

    5. Scope of Applicability

    A prompt template cannot replace data governance, permission isolation, or human review. Its role is to make the analysis process more structured, help expose weak arguments, and attach verifiable evidence to conclusions. It cannot guarantee that conclusions are correct. In high-risk scenarios such as contract review, healthcare, and financial risk control, final conclusions must still be reviewed by qualified professionals.

    Before going live, run A/B tests on small-scale real tasks and record the metrics in the table above. Only when the metrics genuinely outperform the baseline—and failure cases can be located and explained—is it worth expanding the scope of use.