Building Enterprise AI with Fine-Tuning, RAG and Prompt Engineering
When a company-policy assistant gives the wrong answer, should you refine the prompt, add RAG, or fine-tune the model? Follow a hypothetical Taiwan travel-policy scenario from verified clauses and held-out test questions through Responses API retrieval and a TRL/PEFT fine-tuning plan, comparing advantages, limitations, access controls, and acceptance checks to trace failures across evidence, interpretation, and output.

Since ChatGPT and related AI technologies appeared, companies have hoped to improve efficiency, simplify cumbersome processes, and reduce costs. Yet despite ChatGPT’s capabilities, several concerns have held businesses back from routine use:
- Expertise: without a connection to company data, ChatGPT cannot access internal information, making it difficult to fit existing workflows.
- Privacy: in 2023, media reported that Samsung employees using ChatGPT for work had disclosed confidential company information.
- Integration: if AI cannot connect to existing processes or systems, its contribution to process automation is limited.
The arrival of Llama 2 offered companies a possible way forward: running a model internally gives greater deployment control, but does not automatically solve data, access-control, or integration problems. Llama 2 belongs to the historical context of the first draft, rather than today’s recommendations. Its training corpus was predominantly English, with relatively little Chinese data, so Chinese-language applications still required additional adaptation and evaluation. At the time, companies and public-sector initiatives such as TAIDE explored fine-tuning models with Chinese data to strengthen Chinese-language knowledge and understanding.
Fine-tuning is nevertheless more involved than it may appear. Engineers need the relevant knowledge and skills, and training requires compute. Not every company can purchase fleets of GPUs and recruit AI specialists as large technology companies do. Fortunately, fine-tuning is only one option.
Companies can consider prompt engineering, model fine-tuning, retrieval-augmented generation (RAG), or a combination of these methods. The following distinctions help identify where each fits:

- Fine-tuning: consider it when a model must produce a specific form of output, such as SQL from natural-language input.
- RAG: use retrieval to attach a company knowledge base to a language model.
- Prompt engineering: refine how the task is presented—for example, by supplying several examples—to improve response quality.
Compare all three methods on the same policy questions
An employee asks, “How much can I claim for a hotel on a business trip to Taichung?” The AI promptly returns a figure—from a policy that expired last year. Another answer gets the amount right but omits eligibility rules and cannot fill the company’s reimbursement form fields. Although both answers fail, they require different fixes.
Prompt engineering sets the task, reference context, and response rules inside each request. Retrieval-augmented generation (RAG) pulls relevant evidence from documents or internal systems before the model answers. Fine-tuning updates model parameters with training examples so the model handles a specific class of tasks more consistently. These three methods work well together, provided you first identify what is actually missing: current knowledge, clear instructions, or repeatable behavior. Walking through a hypothetical company-policy assistant shows how to choose between them, implement each layer, and verify the results.
Suppose a company’s Domestic Travel Policy v3 took effect on October 1, 2026. Under Clause 4, hotel reimbursement for regular employees traveling to Taichung is capped at NT$2,400 per day, requires a receipt, and allows exceptions only with prior special approval. These figures and provisions are purely illustrative and do not represent any real company’s policy.
Start by having HR confirm the authoritative version, covered employee groups, and original document location. Next, assemble a held-out set of test questions. Beyond asking directly for the hotel cap, test edge cases: Can someone claim without a receipt? Does prior managerial approval permit an exception? Which version applies to a trip in September last year? Does the policy cover contractors? Include questions the document does not address at all. For each question, record the governing clause, necessary conditions, acceptable answer, and whether the case should escalate to HR. Never copy these evaluation questions into training data—memorizing a test is not the same as learning a rule.
Whenever an answer goes wrong, split the diagnosis into three checks: Did the context supplied to the model contain the right clause? Did the model interpret it faithfully? Did the output match the required fields? The selection guide below separates these layers and sets the troubleshooting order for the steps that follow.
Each approach is explained in more detail below:
1. Model Fine-Tuning
Fine-tuning a pretrained model is one option for businesses. It adjusts and optimizes an existing model for a particular application or need. With suitable training and verification, for example, a model may generate SQL from instructions or respond using phrasing more natural in Taiwan.
Fine-tuning costs need careful estimation. Projects such as Taiwan-LLM illustrate why complete model development and task-specific adaptation should not share the same hardware estimate. Cloud resources from GCP, Azure, or AWS are another option, but training involves repeated experimentation, engineers who understand suitable methods such as LoRA and QLoRA, and high-quality datasets. DPO and RLHF are other training and alignment methods, not requirements for every fine-tuning task. GPU and time requirements depend on the model, data volume, and method; fine-tuning can also reduce existing capabilities and cannot be assumed to outperform the original model.

Ready-made models for private deployment are another option. The ikala evaluation dataset and C-Eval provide useful test signals but cannot replace a company’s own questions. The first draft mentioned Alibaba’s Qwen and Mistral AI’s Mixtral-8x7B. These remain historical examples; current choices require checking versions, licenses, provenance, deployment costs, and performance on the actual task. Public-sector organizations must also apply relevant security and procurement requirements instead of choosing solely from a leaderboard.
For Taiwan Traditional Chinese models, the first draft’s claim that no strong options existed should no longer guide selection. TAIDE and Taiwan-LLM have released subsequent versions. Evaluate them using company-specific Traditional Chinese questions and deployment requirements.
Advantages and drawbacks of fine-tuning
Advantages: closer alignment with specific user requirements, with possible improvements in a domain or language that still need testing.
Drawbacks: training requires resources and time; costs depend on the model and method, and general capabilities may regress.
Fine-tuning the policy assistant and checking results
Suppose retrieval consistently returns v3, Clause 4, and you have already refined both the prompt and output structure, yet the model repeatedly places unresolved questions inside the “approval result” field or misuses company categories. You now have a specific fine-tuning objective: training on human-reviewed inputs and ideal outputs so the model follows the required response convention consistently. Use cases such as text-to-SQL, consistent Taiwan phrasing, and fixed output formats remain valid evaluation targets, though whether training is worthwhile depends on baseline failures, data quality, and acceptance results.
Fine-tuning updates some or all model parameters. Parameter-efficient fine-tuning (PEFT) trains only a small subset of parameters: LoRA learns adjustments through additional small matrices, while QLoRA combines that approach with quantization to reduce memory requirements. Both lower parts of the compute barrier, yet neither guarantees that any chosen model will train on a particular consumer GPU. Model size, sequence length, batch size, numerical precision, and training settings all determine required hardware.
One practical route pairs Hugging Face TRL’s SFTTrainer with PEFT. Supervised fine-tuning (SFT) teaches a task from verified demonstrations. First confirm that the base model’s license, provenance, Traditional Chinese capability, and deployment footprint meet company policy, then work through these steps:
- Pair each question and its retrieved passages with a reviewed answer. Keep citation fields intact, and include insufficient evidence, conflicting documents, and clarification requests so the model learns when to abstain instead of only producing fluent answers.
- Split training, validation, and held-out test sets by document or question family so paraphrases of the same question never span across splits. Remove personal data, keys, and unnecessary secrets, and confirm rights to use the material for training.
- Save the examples as conversational JSONL supported by TRL. The single row below illustrates the format only; one example is not an adequate training dataset.
{"messages":[{"role":"user","content":"Evidence: Domestic Travel Policy v3 Clause 4 caps hotel costs for regular employees visiting Taichung at NT$2400/day, requires a receipt and prior approval for exceptions. Question: What can I claim?"},{"role":"assistant","content":"Answer: Up to NT$2400/day. Conditions: Regular employees; receipt required; exceptions need prior special approval. Evidence: Domestic Travel Policy v3 Clause 4. Confirm: Travel date and any special approval."}]}
Install trl, peft, and datasets in an isolated environment with compatible PyTorch and GPU support. Format records using the model’s chat template, construct SFTTrainer(model=approved_model, train_dataset=dataset, peft_config=LoraConfig(...)), and call train(). Target layers, learning rate, sequence length, and batch size must be configured for the specific model and available GPU memory; this describes the setup order, not a universal executable script. Save the adapter weights, base-model version, training configuration, and evaluation logs together so deployment can reproduce the exact combination.
Connect both the original and fine-tuned models to the same retrieval pipeline, then compare citations, required conditions, classification, appropriate abstention, and latency on held-out questions. Introduce a new policy version to confirm the fine-tuned model follows newly retrieved evidence instead of clinging to amounts seen in training. Keep the fine-tuning route only when measurable gains on the defined task outweigh its training and maintenance costs.
2. Retrieval-Augmented Generation (RAG)
RAG combines retrieval and generation. It represents material from an existing knowledge base or database as semantic vectors (embeddings) stored in a vector database. When a user asks a question, the system retrieves the most relevant documents as context for generation. This supplies checkable evidence without changing the original model; any accuracy improvement still depends on retrieval and interpretation quality.
RAG can use hosted document retrieval or a self-managed retrieval pipeline. The first draft mentioned knowledge in ChatGPT GPTs and OpenAI’s Assistants API. The latter shut down on August 26, 2026, so new API implementations should use Responses API document retrieval. To operate a dedicated vector database, companies can evaluate Chroma, Supabase, or Qdrant, optionally with frameworks such as LangChain or LlamaIndex. These frameworks are not mandatory.
RAG alone does not fully resolve privacy concerns: sensitive information may be exposed when documents enter the generation context. Companies can evaluate locally deployed models or cloud services such as Azure OpenAI APIs, but security still depends on access controls, retention, network configuration, and contracts. Uploading data to a cloud may carry risk; neither a supplier’s brand nor open weights establish security by themselves.
How does RAG alone perform? In a study by Microsoft researchers, RAG alone exceeded RAG plus fine-tuning on many evaluations under the tested models, knowledge tasks, and training settings, while some tasks favored the combination. RAG therefore merits comparison when the goal is AI integration with less training investment. Any cost comparison must include retrieval, storage, inference, and maintenance.

Advantages and drawbacks of RAG
Advantages: RAG can draw on a rich database for more precise, comprehensive answers while avoiding major changes to the original model.
Drawbacks: privacy protection for sensitive documents remains limited, and performance depends heavily on retrieval quality.
RAG implementation and permission checks
Once travel, leave, and purchasing policies span hundreds of files, employees cannot paste the right clauses for every question. RAG hands that lookup to a retrieval system: it extracts text, splits it into passages that preserve headings, clause numbers, and surrounding context, and builds a searchable index. Embeddings represent text as numeric vectors so questions and passages with similar meaning match even when phrasing differs; pairing vector search with keyword search helps retain exact document identifiers and specialist terms. The model then generates an answer grounded in the retrieved passages.
RAG updates the evidence available for a request, usually without changing model weights. When a reimbursement limit changes, update the document and re-index it rather than expecting an older fine-tuned model to know the new figure. This walkthrough uses file_search in the Responses API to illustrate hosted retrieval; the Assistants API used in earlier guides was shut down on August 26, 2026, so it is no longer a starting point for a new implementation.
- Save the hypothetical clause as a UTF-8 file named
travel-policy-v3.txt, including its document name, effective date, and clause number. Start with non-confidential demonstration data and set a project spending limit. - Install the official Python package with
pip install openai. SetOPENAI_API_KEYin your runtime environment, and setOPENAI_MODELto a model ID available to your account that supports file_search. Keep the key out of source code. - Create a vector store, upload the file, and wait for indexing to complete, following the retrieval documentation. Running this walkthrough incurs usage-based charges.
import os
from openai import OpenAI
client = OpenAI()
store = client.vector_stores.create(name="travel-policy-demo")
with open("travel-policy-v3.txt", "rb") as document:
indexed = client.vector_stores.files.upload_and_poll(
vector_store_id=store.id, file=document
)
if indexed.status != "completed":
raise RuntimeError(f"Indexing failed: {indexed.status}")
response = client.responses.create(
model=os.environ["OPENAI_MODEL"],
instructions="Search the supplied policy. Answer only from it; cite the clause. If evidence is missing, say HR must confirm.",
input="Under the current policy, what hotel limit and conditions apply to a regular employee visiting Taichung?",
tools=[{"type": "file_search", "vector_store_ids": [store.id],
"max_num_results": 4}],
include=["file_search_call.results"],
store=False,
)
print(response.output_text)
print(response.model_dump_json(indent=2))
Do not stop at reading the final answer—inspect the full output to verify that a search call actually ran, returned the right passages, and included file citations. Ask a question the policy never covers and check that the system flags insufficient evidence. Once the demonstration is complete, delete unneeded files and vector stores in the project and review usage; setting store=False does not delete the knowledge base you uploaded.
This single-file example does not implement production access control, and RAG itself is not an access-control layer. In production, the application must authenticate the employee while a trusted backend decides which documents and versions may be searched—writing “do not disclose” in a prompt is not an enforceable boundary. A self-managed database can filter on metadata such as Qdrant payload filters for department, document status, and effective period, but a trusted backend must construct those filters; database filtering alone does not establish company access policy.
3. Prompt Engineering
Prompt engineering improves response quality by changing how a task or question is presented. It does not require additional model training, but it still requires understanding the task and testing the answers against the situation.
If AI is so capable, why do people still need to learn how to prompt it?
ChatGPT’s answers depend on its training data as well as the instructions and context supplied with each request. For Taiwan Traditional Chinese, specify Taiwan usage and show examples; no reproducible evidence establishes that one Chinese name for the script always works better than another. Few-shot prompting and chain-of-thought prompting can improve some tasks, but should be compared on your own questions. A 2023 medical question-answering study by Microsoft researchers showed that prompt methods improved the then-current GPT-4 without domain fine-tuning, exceeding Google’s Med-PaLM 2 on the specified medical evaluations. This neither establishes clinical safety nor directly predicts company-policy performance.

Advantages and drawbacks of prompt engineering
Advantages: no additional training hardware or large training dataset is required, allowing quick implementation and possible improvements in answer quality.
Drawbacks: effective prompt design has a learning curve for non-specialists; complex situations can limit its effectiveness, and changing requirements require continued adjustment.
Prompt implementation and output verification
When a policy runs only a few pages, you can establish a checkable baseline without training a model by passing the relevant clauses directly in the request. Clear instructions, supporting context, and a handful of correct examples—few-shot prompting—are detailed in the prompt engineering documentation. Start with a chat tool or API your company has already approved, and check your data classification policy and service agreement before uploading confidential material.
Supply the verified clause alongside a prompt like the one below. The system or responsible employee fills in the bracketed placeholders. Treat document content strictly as evidence, never as instructions that can override system rules.
Task: Answer employee questions using the supplied company policy.
Use Traditional Chinese as used in Taiwan.
Rules: Answer only from the Evidence. Do not invent amounts or eligibility.
If the travel date, employee status or approval status is missing,
identify what needs clarification.
If evidence is insufficient or versions conflict, say "HR must confirm"
and explain what is missing.
Output: Answer / Conditions / Evidence (document, version, clause) /
Items requiring confirmation.
Evidence: [Verified clause, effective date and document identifier]
Question: [Employee question]
In this hypothetical case, an acceptable answer states the NT$2,400 daily cap, the receipt requirement, and the prior-approval exception while citing v3, Clause 4. This is the expected target answer, not a reported model test result. If the response runs too long, supply one concrete example of a good answer. For form integration, define exact field names and types first, then consider the API’s Structured Outputs. Matching a JSON Schema verifies structure only—it does not guarantee factual accuracy, so amounts, eligibility, and citations still need independent checks.
Combining All Three
As the online saying goes, “Why choose? I want them all.” Companies can combine fine-tuning, RAG, and prompt engineering to build a flexible AI system that addresses specialized problems alongside general questions. Fine-tuning personalizes behavior, RAG improves the relevance of supporting material, and prompt engineering shapes usability and user experience. This broad strategy can improve operational usefulness, but adopting everything also tests a company’s finances and staffing. Costs and return on investment need to guide the decision.
Trace failures before combining methods
| Failure | Evidence to inspect first | Possible correction |
|---|---|---|
| The hotel amount comes from an old policy | Retrieved version, effective date, and trip date | Fix version filters and indexing updates; retain historical lookup rather than defaulting blindly to the latest version |
| The amount is right, but receipt or approval conditions are missing | Whether the passage contains the full clause and whether the answer actually uses it | Improve chunking and adjacent context first, then refine the prompt; do not immediately blame model size |
| Correct structure, unsupported content | Original passages, file citations, and each claim in the answer | Add grounding checks and abstention rules; schema compliance does not guarantee factual accuracy or authorize reimbursement |
| An employee sees an unauthorized document | Authentication, backend filters, search results, and cache scope | Fix access control and cache isolation, then test other departments and departed employees’ accounts |
| A fine-tuned model handles only familiar wording | Training/test overlap and unseen clauses or phrasing | Split the dataset again, add representative demonstrations, and re-compare against the untuned baseline |
During acceptance testing, track each dimension separately: whether retrieval found the required clause, whether the answer is grounded, whether citations match, whether necessary conditions are complete, and whether the system abstains when it should. Log latency and cost alongside the model version, document version, questions, and test date. That breakdown shows which layer actually improved far more clearly than a single “accuracy” score.
This article originally examined enterprise AI adoption through Llama 2 and the Chinese-language models of that period. The underlying requirements still hold: internal knowledge, data protection, and outputs that fit company workflows. Today’s model choices, however, should not recycle those historical leaderboards, hardware prices, or sweeping judgments about regional model quality. Local deployment still requires account, log, backup, and network controls—running on-premises does not make a system secure by itself. For organizational and rollout questions, see the enterprise survival guide (Chinese); the focus here is choosing and verifying the right technical layer.
Earlier studies—Fine-Tuning or Retrieval? and the medical question-answering paper Can Generalist Foundation Models Outcompete Special-Purpose Tuning?—show that retrieval and prompt design are well worth comparing alongside fine-tuning under specific experimental conditions. They do not prove that RAG always beats fine-tuning or that one prompt works for every company. GraphRAG can be worth evaluating for themes and relationships spanning many documents, whereas a single travel-policy lookup is much easier to diagnose once basic retrieval and version handling are solid. Multi-step tool calling also introduces stopping conditions, latency budgets, and permission controls that must be managed.
For a policy assistant like this one, start with clear instructions and a verifiable clause, add RAG as the document collection grows and changes, and reserve fine-tuning for measurable behavior failures that persist. AI can help employees find the basis for a claim, while the existing reimbursement system and authorized staff still handle approval. Starting from one reproducible question and building toward a versioned, permission-aware service with clear acceptance checks ensures each technical investment addresses an identified problem.
Enterprise AI Developments in 2026: GraphRAG, Agentic RAG and Efficient Fine-Tuning
RAG can use a single retrieval step or an agent-directed tool loop. GraphRAG brings knowledge graphs into retrieval, while parameter-efficient fine-tuning offers alternative ways to customize models. They address different problems and are not all necessary for every business.
GraphRAG and Agentic RAG: from pipelines to tool loops
A conventional RAG design can follow a linear “retrieve once, generate once” pipeline. Agentic RAG lets an LLM select a search strategy, call tools, and continue from the resulting observations. GraphRAG maps entities and relationships into a knowledge graph to analyze themes and connections across documents; it is a different technique from Agentic RAG. Evaluate whether the task requires tool loops or a graph index, and manage stopping conditions, latency, and permissions.
Efficient fine-tuning: LoRA, QLoRA and synthetic data
Parameter-efficient methods such as LoRA and QLoRA can reduce some training requirements. Whether a consumer GPU suffices still depends on model size, sequence length, precision, and configuration. Synthetic data generation can produce candidate training examples, followed by human checks of accuracy, representativeness, and usage rights; generated content is not automatically high quality. Self-RAG trains a model to retrieve when needed and critique retrieved passages and its own output. It is not a generic form of “self-evaluation fine-tuning,” nor does it guarantee lower API costs on every task.
Prompt engineering: structured outputs and ReAct
ReAct (Reason + Act) interleaves reasoning and actions, using tool observations to decide what happens next. Structured output prompting with JSON Schema checks whether a response’s shape meets integration requirements, but does not guarantee factual accuracy. HyDE (Hypothetical Document Embeddings) first generates a hypothetical document to guide vector retrieval; actual documents must still supply the answer’s evidence, and any gains require held-out tests. For evaluation, BEIR benchmarks information retrieval across datasets, while Ragas can help assess retrieval and response faithfulness and relevance. Neither is a universal enterprise launch standard: company clauses, permissions, and human review requirements still govern acceptance.
Conclusion
As AI advances, companies may incorporate these methods more widely to reduce costs and improve efficiency. Balancing privacy protection with cost control remains a central adoption decision.
In the first draft, LargitData proposed exploring a combination of prompt engineering, RAG, and locally deployed language models for social-listening and knowledge-management services. Companies considering internal RAG applications are welcome to contact us to discuss possible collaboration.