LLM Deployment and Tuning in Practice: Knowledge Q&A and Dorm Repair Requests

    Deploying a large language model is not the same as delivering a usable application. This guide explains how to move from a working inference path to a maintainable campus knowledge Q&A system and a dorm repair workflow, covering architecture boundaries, knowledge governance, retrieval-augmented answers, evaluation, cost and performance tuning, and acceptance criteria.

    1. Project Goal: From a Working Model to a Usable Application

    Deploying a large language model does not mean the application is finished. Returning text only shows that the inference path works. Practical value depends on whether the system can cite policies accurately, detect missing information, respect access control, and complete business operations reliably.

    This tutorial starts with campus knowledge Q&A and then extends to a “dorm assistant” repair scenario. The first mainly answers information queries, such as housing rules, repair scope, and how to file a request. The second requires the system to understand the user’s description, collect required details, and create a repair record only after the user confirms.

    The project should produce the following deliverables:

    • A maintainable runtime environment for the LLM application.
    • A business knowledge base that has been cleaned, classified, and versioned.
    • An intelligent Q&A application that answers from evidence.
    • A test suite covering typical questions, abnormal inputs, and permission boundaries.
    • A repair workflow with confirmation and status feedback.

    Each deliverable must be independently verifiable. Smooth conversation is not a substitute for knowledge-accuracy tests, and a well-written repair description is not a substitute for verifying that a real business record was created.

    2. Overall Architecture and Deployment Boundaries

    2.1 Split the application into core components

    Divide the system into five parts: user entry, application orchestration, model inference, knowledge retrieval, and business services.

    The user entry handles identity, question input, and result display. Orchestration decides whether a request is a knowledge query, a request for more information, or a business operation. Model inference handles language understanding and answer generation. Knowledge retrieval finds relevant content in authorized materials. Business services handle repair records, status queries, and operation audit.

    A typical knowledge Q&A path is:

    User question → identity and permission check → question processing → knowledge retrieval → context assembly → model generation → citations and result display.

    The repair path also needs structured information extraction, business-rule validation, and user confirmation. The model should not receive arbitrary operation privileges, and it should not decide on its own to bypass business checks.

    2.2 Separate model deployment from application deployment

    Model deployment focuses on compute, model files, the inference process, and request scheduling. Application deployment focuses on authentication, knowledge access, workflow orchestration, data persistence, and runtime monitoring. The two can be scaled and updated separately so that a knowledge-base change does not force a full redeployment of the inference environment.

    When running inference yourself, estimate resources from model size, numeric precision, context length, and concurrency. Memory use includes model weights, runtime overhead, and cache that grows with requests. Model file size alone is not enough to decide whether a machine is adequate.

    When using a hosted inference service, check request limits, data-handling boundaries, failure handling, and cost constraints. In either case, validate behavior with a small load test instead of relying on an unverified capacity estimate.

    2.3 Use separate environments for release

    Keep development, test, and production as separate as practical. Development is for changing prompts and flows. Test is for validating new knowledge and regression cases. Production serves real users.

    Inject secrets and connection credentials through controlled configuration. Do not place them in knowledge documents, front-end pages, or code samples. Persistent data needs backup and restore procedures, and those procedures should be rehearsed. A backup file existing does not mean restore will succeed.

    3. Build the Knowledge Base: Govern the Material Before Indexing

    3.1 Define knowledge boundaries and owners

    A knowledge base is not a pile of uploaded files. Before building it, decide which content is an official basis, which is only reference material, and which rule applies when sources conflict.

    For a campus setting, organize material into categories such as:

    • Housing rules and conduct standards.
    • Repair scope and how to file a request.
    • Common troubleshooting steps and safety notices.
    • Service hours, contact channels, and temporary notices.

    Each document should have a source, scope, effective date, version, and owner. Content that differs by building or campus should be marked separately so the system does not treat a local rule as campus-wide.

    3.2 Clean and parse documents

    Before upload, check whether body text can be extracted, whether tables are complete, whether scanned content needs text recognition, and whether headers and footers interfere with understanding.

    Cleaning should remove duplicates, fix obvious recognition errors, and preserve heading hierarchy and clause numbers. For tables, keep the relationship between fields. For example, “fault type—handling department—requirements” must not be split into unrelated text; otherwise a retrieval hit can still produce a wrong answer.

    Sensitive content such as personal contact details and student identity information should be removed, masked, or access-restricted according to business need. Uploading knowledge does not mean every user may see it.

    3.3 Chunk carefully and design metadata

    Chunking lets retrieval locate content with a self-contained meaning. Chunks that are too small lose preconditions. Chunks that are too large pull in unrelated text and increase context cost.

    Prefer splits by headings, paragraphs, clauses, and table structure, then adjust length based on the actual model and retrieval results. A small overlap between neighboring chunks can be useful, but do not keep adding duplicate text without limit.

    Store the following for each knowledge fragment:

    • Document ID and fragment ID.
    • Title, section, and source location.
    • Applicable building or business scope.
    • Effective time and expired status.
    • Version, access level, and update time.

    These fields support citations, permission filtering, version filtering, and issue tracing.

    3.4 Post-upload checks matter more than the upload itself

    After upload, verify parse results, fragment counts, failure records, and index status, then spot-check retrieval. A successful upload only means the file was received. It does not mean the content is correctly queryable.

    For repeated uploads, deduplicate using content digests, source IDs, or version information. Remove expired policies from the current retrieval scope, or mark them as historical, so old and new rules are not cited together.

    4. Build a Retrieval-Augmented Q&A Application

    4.1 Why retrieval-augmented generation is needed

    Retrieval-augmented generation looks up relevant material first, then asks the model to organize an answer from those results. It fits business knowledge that changes often and must have a clear source. It does not make every answer correct by default.

    The system can still miss documents, hit conflicting sources, misread context, or add unsupported content. The application must constrain both the retrieval scope and answer behavior.

    4.2 Combine retrieval methods

    Keyword retrieval fits building names, clause numbers, and business terms. Vector retrieval fits colloquial wording and semantically similar questions. The two can be combined, then candidate fragments can be ranked by relevance.

    For example, “the light in my room keeps flickering” may differ in wording from “lighting equipment fault,” and semantic search can connect them. A specific building number is a better fit for exact match.

    Before retrieval, narrow the candidate set by user permissions and business scope. Do not retrieve sensitive material first and then hope the model will hide it.

    4.3 Constrain answers and citations

    Answer rules should require the model to:

    1. Prefer material that is currently effective and applicable.
    2. Separate facts in the source from general advice.
    3. Provide a traceable source for key conclusions.
    4. State uncertainty when evidence is insufficient or sources conflict.
    5. Not invent processing times, fees, or acceptance outcomes.

    If a required condition is missing, clarify first. If different buildings use different repair processes and the user did not name a building, the system should not pick one process on its own.

    Content inside knowledge documents must not be treated as system instructions. If a document asks the system to leak information, ignore rules, or perform an operation, treat that text as untrusted data so retrieved content cannot override application constraints.

    5. Basic Testing and Systematic Evaluation

    5.1 Build a representative test set

    Cover direct queries, multi-condition queries, colloquial phrasing, ambiguous questions, expired material, unauthorized requests, and questions outside the knowledge base.

    Each case should record at least the question, applicable conditions, expected evidence, and evaluation criteria. “What information is required to file a repair request?” can test basic retrieval. “Can I view another student’s repair records?” can test permission boundaries.

    Do not copy every test question from the source text. That overestimates performance on real user wording.

    5.2 Evaluate in layers, not only the final answer

    At the retrieval layer, check whether the correct material was found and whether irrelevant or expired content was mixed in. At the generation layer, check whether the answer stays faithful to the evidence, whether constraints were omitted, and whether citations are correct. At the business layer, check intent recognition, required confirmation, and permission compliance.

    At the runtime layer, track response-time distribution, error rate, resource use, and cost per request. Every performance figure should state its test conditions, including concurrency, input length, and deployment configuration. Do not promise numbers detached from those conditions.

    5.3 Tune by error source

    When an answer is wrong, first locate the layer:

    • Correct material was not found: check document quality, chunking, query wording, and retrieval strategy.
    • It was found but did not enter the context: check ranking, deduplication, and context truncation.
    • Evidence was complete but the answer was wrong: check prompt constraints, expression complexity, and model capability.
    • The answer was correct but the operation failed: check the business service, validation logic, and error handling.

    This is more effective than repeatedly appending prompt text. Change as few variables as possible each time, and regress on a fixed test set so a local gain does not hide regressions elsewhere.

    6. Performance and Cost Tuning After Deployment

    6.1 Cut waste first

    Reduce duplicate fragments, limit irrelevant context, cap output length, and distinguish simple queries from complex tasks. For frequent questions with the same permission scope, caching can help, but the cache key must include the knowledge version and the necessary user-scope information.

    Cache entries must not cross permission boundaries. Invalidate them when knowledge changes, or the system may keep returning old rules.

    6.2 Use model compression and concurrency carefully

    Quantization can lower resource demand and can also hurt accuracy on some tasks. Validate it on the target business test set. Raising concurrency does not always improve the overall experience. Too much concurrency can cause queuing, memory pressure, or worse tail latency.

    Optimize for correctness, throughput, response time, and cost together, not for a single metric. For business operations, do not drop the confirmation step just to reduce latency.

    6.3 Separate knowledge updates from model fine-tuning

    Policies, procedures, and notices that change often are usually better maintained by updating the knowledge base. Fine-tuning fits relatively stable behavior, output format, or specific language style. It does not replace access control, and it does not keep facts current.

    Before fine-tuning, confirm that the problem cannot already be solved by better material, retrieval, and workflow changes. Without high-quality training data and an independent evaluation set, fine-tuning can add complexity without a stable gain.

    7. Extension: Closing the Loop on Dorm Repair Requests

    7.1 Extract required fields from free text

    A repair scenario must turn a description such as “the faucet in my dorm keeps leaking” into a structured record. Required information usually includes location, fault category, fault description, and contact arrangements. The exact fields come from the real business rules.

    The model may help extract fields and ask follow-up questions. It must not infer a room number, contact method, or handling time the user did not provide. When information is missing, ask for it. Do not generate a record that only looks complete.

    7.2 Constrain operations with an explicit state flow

    Split the repair flow into “collect information—validate rules—user confirmation—submit—report the result.” The logic below is platform-neutral and is not a ready-made API:

    1. Receive the user description
    2. Decide whether it is a repair request
    3. Extract required fields
    4. If fields are missing:
    5. Ask for the missing information
    6. Else:
    7. Validate identity, location, and acceptance scope
    8. Show the content to be submitted
    9. Wait for explicit user confirmation
    10. After confirmation:
    11. Submit to the business service
    12. Report status from the actual response

    “Ready to submit” and “submitted successfully” must stay distinct. Report success only after the business service confirms that the record was created. On timeout or an unclear result, query the actual status or tell the user to check later. Do not create another record immediately.

    7.3 Prevent duplicate submissions and unauthorized lookups

    The submit path needs duplicate protection, and the business service must perform the final permission check. A user may view only records within their authorized scope. Changing how the question is phrased must not reveal someone else’s repair information.

    If there is an urgent safety risk, tell the user to take safety measures first and contact the appropriate emergency channel. Do not advise an unqualified user to handle dangerous equipment. An ordinary repair flow must not be described as if emergency handling were already complete.

    8. Operations, Iteration, and Acceptance

    After launch, monitor retrieval failures, model-call failures, business-submit failures, knowledge-update failures, and permission denials. Logs should be enough to locate problems, but sensitive conversations should not be stored in full by default. If they must be stored, define the purpose, access rights, and retention period.

    Ongoing iteration can follow user feedback: collect issues, classify errors, find the cause, fix knowledge or workflow, run regression tests, then release gradually. Knowledge versions, prompt versions, and application versions should be linkable so the conditions behind a given answer can be traced.

    Acceptance should at least confirm that:

    • The runtime can start, recover, and roll back reliably.
    • Knowledge has a clear source, version, and access boundary.
    • Answers cite their basis and stop guessing when evidence is insufficient.
    • Repair operations are validated and confirmed, and feedback matches the actual status.
    • Tests cover normal cases, abnormal cases, and unauthorized access.
    • Monitoring and maintenance ownership are clear, and knowledge updates follow a fixed process.

    The point of an LLM project is not to give the model every responsibility. It is to let the model operate on trusted data, explicit permissions, and verifiable workflows. Building deployment, knowledge governance, retrieval evaluation, and business execution in layers is what turns a demo conversation into a maintainable, auditable application.