Practices for Search, File Parsing, and Citation in LLM Applications

    Building reliable Large Language Model (LLM) applications requires more than just prompt engineering; it demands robust practices for data retrieval, file parsing, and citation. This article explores how to decompose tasks between models and tools, choose between managed tools and independent APIs, verify search results, and handle file inputs securely. It also covers multimodal design strategies and pre-launch evaluation methods to ensure your LLM application delivers accurate, verifiable, and permission-controlled responses.

    1. Task Decomposition: Models Reason, Tools Retrieve

    When a user asks, “Based on the procurement requirements in the attachment, cross-check the latest public guidelines and explain which clauses need adjustment,” it appears to be a single Q&A interaction but actually involves multiple steps: reading the attachment, identifying clauses to verify, searching public materials, reading the original text, and finally compiling the comparison conclusions and evidence. The model excels at understanding questions and organizing answers, but it cannot rely solely on its existing knowledge to judge whether external materials are up-to-date, nor can it provide credible page references without actually reading the file.

    Architecturally, such applications can be divided into three layers: the tool layer fetches materials, the dialogue layer understands and uses materials, and the application layer determines which materials are accessible and which conclusions can be delivered. Managed tools can reduce the integration effort for search, web scraping, and context preparation, but they do not replace the application’s own permission checks, evidence verification, and exception handling. Clearly defining the responsibilities of these three layers early in the design process is more important than immediately building independent workflows for each input type.

    2. Managed Tools vs. Independent APIs: Choosing Based on Business Control

    One integration method involves declaring available search or web-reading tools in the dialogue request, allowing the model to decide whether to call them based on the task, with the server handling the actual retrieval, page fetching, and context processing. This approach is suitable for exploratory Q&A: some questions require consecutively consulting multiple sources, while others can be resolved using content provided by the user. The application does not need to pre-define a fixed call sequence for every type of question.

    The alternative is for the application to explicitly call search, web reading, or content conversion APIs, and then pass the filtered materials to the model. This is ideal for scenarios with fixed business constraints. For example, policy Q&A may require prioritizing the original text from the publishing institution, while an enterprise internal assistant must first complete document permission checks before deciding which fragments can enter the session. Independent calls allow the application to filter materials before they reach the model and make it easier to record exactly which inputs were used for a specific task.

    These two approaches can be combined. For general public information Q&A, retrieval decisions can be left to the model; when internal materials, designated sources, or compliance reviews are involved, the application should first collect and filter evidence before letting the model summarize. The key to choosing is not the number of API calls, but clearly defining: which decisions the model is allowed to make based on context, and which must be enforced by application rules. For instance, the model can decide if it needs to look up another public document, but it cannot unilaterally decide to include customer information from an attachment in a public search query.

    3. Search Discovers Sources, Web Reading Verifies Conclusions

    Titles and snippets from search results are suitable for filtering candidate pages, but should not be used directly as factual evidence. Snippets may only capture a small portion of the text, or omit effective dates, applicable conditions, or exception clauses. For conclusions that affect business decisions, you should read the original text as much as possible to verify the publisher, version, date, and applicable scope. If a page is inaccessible, you should state that the original text could not be verified rather than presenting the search snippet as a confirmed conclusion.

    For questions requiring multiple rounds of retrieval, break the task down into several items to verify. For example, when verifying a requirement, separately confirm “what is the current version,” “what is the applicable scope,” and “does the practice in the material fall within this scope.” Each round of search should fill a specific evidence gap, rather than repeatedly searching the same thing with different keywords. Retrieval should end when the core question has sufficient evidence, no more valid materials can be obtained, or the call budget is reached. The answer should clearly distinguish between verified items and items that remain uncertain.

    When encountering conflicting sources, do not simply vote based on the number of web pages. Multiple pages may repost the same outdated material. You should first check whether they reference different versions, target different regions, or describe a draft versus the final text. Conflicting sources only truly help the user understand the conclusion once the differences are explained.

    4. File Input is More Than Handing the Whole File to the Model

    File Q&A is typically divided into two stages: upload parsing and dialogue citation. In a scheme where attachments are associated via file IDs, the application first submits the file, waits for parsing to complete, and then adds the file ID to the session. The user interface should clearly distinguish between “Uploaded,” “Parsing,” “Ready,” and “Failed.” Otherwise, users may see a successful upload and mistakenly assume the model has finished reading the file.

    Parsing quality depends on the document itself. Documents with extractable text can retain chapters and page numbers; scanned files typically require OCR; complex tables require identifying the rows, columns, and units corresponding to numbers. While line-by-line text extraction is convenient, it might merge amounts from adjacent columns. For critical fields like numbers, dates, units of measurement, or clause IDs, the application should preserve their positional relationship to the original page. When uncertain, it should prompt the user to check the original page rather than letting the model guess illegible content.

    Long documents should be chunked by semantic boundaries such as chapters, clauses, or tables, selecting fragments relevant to the current question. Chunking should preserve headings, page numbers, and paragraph order, and retrieve adjacent content when necessary. For example, if the text says “except those who meet the conditions,” but the conditions are in the next paragraph, submitting only the paragraph that hits the keyword might lead to the opposite conclusion. A file ID is merely a citation credential, not an access authorization; every time an attachment is reused, the application must verify whether the current user has access rights.

    5. Citations Must Point to Evidence, Not Just List Sources

    Reliable citations should allow readers to verify a key conclusion. For web pages, retain the page title, source, accessible publication or update date, and corresponding content; for attachments, record the filename, page number, section, or table location. When constructing the answer, the application should link conclusions to retrieved evidence, generating citations from these materials to prevent the model from hallucinating links, page numbers, or filenames.

    Additionally, distinguish three types of statements: directly stated facts from materials, inferences made based on materials, and items that cannot be confirmed due to insufficient evidence. For example, if an attachment lists a specific condition, that is a directly citable fact; whether that condition applies to the user’s current business usually depends on whether their business scope meets the document’s definition, which is an inference requiring stated prerequisites. The two should not share an unqualified conclusion. Citations help readers find the basis but cannot replace the explanation of the inference process.

    During review, you can ask the question in reverse: if the reader only opens this specific citation and ignores the rest, can they find the content supporting this statement? If the citation only proves part of the claim, split the conclusion or add more evidence; if it supports nothing, delete the assertion or mark it as pending confirmation. This approach reflects quality much better than simply counting how many citations are in the answer.

    6. Design Multimodal Capabilities Independently for Input and Output

    OCR and speech recognition are responsible for converting non-text materials into analyzable content, while text-to-speech (TTS) converts generated text into audio. Designing them as independent steps facilitates retries, human proofreading, and reuse. For example, a meeting recording can be transcribed first, retaining usable time markers, and after the user reviews names, numbers, and technical terms, minutes can be generated. If the transcription is uncertain, the minutes should not present vague phrases as definitive decisions.

    Voice output also does not need to read the written answer verbatim. Long answers with multiple citations can broadcast the main conclusions and necessary limitations first, while displaying detailed evidence and location information in the UI. If TTS fails, the text answer remains usable; if speech-to-text (STT) fails, the system should prompt the user to resubmit the material or provide text directly, rather than guessing the content based on the audio file’s title.

    7. Pre-Launch: Define Permissions, Degradation, and Evaluation Criteria

    Permission control must be placed at data flow points. Enterprise attachments, recordings, and user questions may contain sensitive fields; collection scope, retention periods, and access personnel should be limited according to business needs. Before generating external search queries, irrelevant personal information and internal identifiers should be removed. Text in web pages and attachments should be treated as data to be analyzed; instructions demanding task changes, content transfers, or tool calls embedded within them must not gain higher authority than application rules.

    Degradation strategies must explain what was lost. If a search times out, you can answer based on already retrieved materials, but must flag that external verification was not completed; if attachment parsing fails, you should preserve the user’s question and prompt a re-upload, rather than generating non-existent file citations. For recoverable temporary failures, limited retries can be performed within the total time limit; for permission denials or unsupported formats, clear prompts should be given quickly. Logging the duration and failure reasons of search, reading, parsing, and generation stages stage-by-stage is necessary to determine whether the bottleneck is in evidence gathering or answer writing.

    Evaluation must cover the entire pipeline. It is recommended to use a set of test tasks including normal Q&A, expired web pages, conflicting sources, scanned documents, and unauthorized attachments to check whether tools are selected correctly, whether sufficient evidence is obtained, whether citations truly support conclusions, and whether missing materials are honestly reported. Beyond answer accuracy, observe citation locatability, task latency, API call volume, and failure causes, avoiding validating the system solely with successful examples.

    For actual implementation, start by building a minimal verifiable chain: read a locatable material, answer a specific question, and generate checkable citations for key conclusions. Once this chain can stably distinguish “verified,” “inferable,” and “unknown” items, expand to multi-round search, scanned files, and audio. This approach leverages managed capabilities to reduce integration work while keeping evidence quality, data permissions, and delivery standards within the application’s controllable range.