From 72 hours to 4: Security at the Speed of Business
In just 6 months, Foursys strengthened a financial institution’s security with Zero...
Before switching models or starting to fine-tune, learn how to diagnose the problem using instructions, context, and the model—in that order.
An internal assistant provides a generic response. The team’s immediate reaction is to look for a larger model. After a few hours of comparison, the quality improves only slightly, and the cost doubles.
The problem, however, wasn’t with the model. The instruction didn’t specify the expected format, and the system didn’t provide the necessary documents. The team tried to fix an error in the most expensive layer that was actually in the simpler layers.
This pattern frequently arises in AI projects. To avoid it, it’s helpful to focus on three key areas: instructions, context, and the model.
The three levers represent different ways to alter the system’s behavior:
1. Instructions: change what we ask for and how we define the task.
2. Context: changing the information the model receives at runtime.
3. Model: swap or adjust the model’s weights to fine-tune it.
The order matters. Instructions are usually faster and less expensive. Context adds infrastructure but keeps the model intact. Modifying the model tends to require data, training, more extensive evaluation, and specialized operation.
The framework does not imply that fine-tuning is always the last step in chronological order. In some products, it is a strategic choice from the outset. The point is this: do not assume that the model needs to change before proving that instructions and context are insufficient.
Instructions define the task. In a conversational system, they can appear in the user prompt, in system messages, in internal templates, and in tool descriptions.
A weak prompt often omits one or more important aspects: objective, target audience, available data, constraints, output format, and quality criteria.
Compare two requests:
Vague prompt: Review this contract and tell me if there are any issues.
More specific prompt: Review the contract exclusively for automatic renewal obligations. List each relevant clause, cite the corresponding excerpt, classify the risk as low, medium, or high, and do not draw conclusions about topics not mentioned in the document.
The second prompt does not make the model smarter. It narrows the range of possible interpretations and transforms a generic intent into an operational specification.
In production, prompts should not exist solely in a person’s memory or in manually copied blocks. They need to be versioned, reviewed, associated with test cases, and evaluated before any changes are made.
A seemingly minor change—such as asking for more conciseness, changing the order of instructions, or adding an example—can improve one scenario and worsen another. Therefore, the prompt must be tested on a representative set of inputs.
It’s also helpful to separate responsibilities. The system instruction defines policies and the general role; the task template describes the specific work; and user data and retrieved context go into their own fields. This organization reduces ambiguities and facilitates auditing.
When a textual description is not enough, examples can demonstrate the expected behavior. A small set of input–output pairs shows the model the relevant level of detail, structure, and exceptions.
Few-shot learning is especially useful in structured extraction, classification with company-specific categories, and text transformation. But bad examples also teach bad patterns. They need to represent real-world cases, including edge cases.
No formulation can retrieve information that isn’t in the model or the prompt. Nor is it reasonable to use pages of instructions to force the model to memorize rules that change every week.
When the problem depends on specific, up-to-date, or private knowledge, the next lever is context.
Context is everything the system provides in addition to the instruction: conversation history, documents, database records, search results, user preferences, and tool outputs.
In practical terms, context engineering is the discipline of selecting, organizing, and presenting to the model the information it needs at that moment.
The goal is not to put as much as possible into the input window. Too much context increases cost, can dilute important evidence, and introduce contradictions. The challenge is to provide the minimum sufficient set.
Retrieval-Augmented Generation, or RAG, combines information retrieval and generation. When a user asks a question, the system searches for relevant excerpts in an external database and sends them to the LLM as evidence.
A simplified pipeline consists of the following steps:
1. Receive the question.
2. Transform the query into a format suitable for searching.
3. Retrieve candidate documents or excerpts.
4. Select and rank the most relevant evidence.
5. Create the prompt with instructions, a question, and context.
6. Generate the response and, when necessary, cite the sources.
The advantage is separating knowledge from linguistic ability. The LLM does not need to memorize every internal policy; it needs to know how to interpret the correct excerpts when they are provided.
It is common to reduce RAG to the choice of a vector database. In practice, quality depends on the entire pipeline: how documents are segmented, what metadata is preserved, how the query is rewritten, how results are reordered, and how the prompt guides the use of sources.
Even a perfect search can fail if the model ignores the evidence. Similarly, an excellent prompt cannot compensate for poorly processed documents. RAG is a retrieval and generation system, not a single component.
Not all information needs to be retrieved as text. To calculate an account balance, check calendar availability, or verify the status of an order, the system can call an API. The tool’s output is returned as context for the model to interpret and present.
This architecture is the foundation of many agents: the model decides which tool to use, receives the output, and continues its reasoning. The more autonomy is granted, the more important permissions, validations, and action limits become.
The third lever involves two distinct decisions: choosing the most appropriate model and modifying the model through training or optimization.
Models vary in reasoning ability, context size, multimodal support, speed, cost, language, licensing, and the possibility of on-premises deployment. There is no one-size-fits-all solution.
Public rankings help you create an initial list, but they are no substitute for your own evaluation. A model that excels at programming may be only average at legal text extraction. Another model may achieve similar quality with much lower latency.
Create a test suite with real-world examples and compare alternatives based on the criteria that matter: accuracy, completeness, format, security, latency, and cost. The desired result is a range of options, not an abstract “champion.”
Fine-tuning adjusts the model’s weights based on additional examples. It is useful when the system needs to consistently reproduce specific behavior, domain-specific terminology, or a format that extensive prompts cannot stabilize.
It can also enable a smaller model. Instead of relying on a very large model to interpret complex instructions on every call, a team can specialize a compact model and reduce cost and latency.
However, fine-tuning is not an efficient way to incorporate frequently changing facts. For updated policies, product catalogs, or news, external context is often more appropriate. Adjusting weights to memorize changing information makes updates and traceability more difficult.
Training is only part of the process. The team needs to build high-quality data, manage versions, repeat evaluations, monitor regressions, and operate the new model. A fine-tuned model may improve performance on the target task but lose capability in other scenarios.
Therefore, the decision must be based on a verifiable hypothesis: which current flaw will fine-tuning correct, with which dataset, and how will we know that the change worked?
When the system does not deliver the expected quality, follow this sequence:
1. Is the task clearly defined? If not, refine the instructions, format, and criteria.
2. Did the model receive the necessary information? If not, add context, follow-up, or tools.
3. Is the retrieved information truly relevant and usable? If not, correct the context pipeline.
4. Does the model have sufficient capacity to perform the task? If not, compare it with better models.
5. Does the behavior need to be consistent, specialized, or more cost-effective at scale? Consider fine-tuning or a specialized model.
6. Did the change improve the entire test suite? If not, revert the change and investigate the hypothesis.
LLMOps is a set of practices for deploying, evaluating, monitoring, and evolving applications based on language models. It builds on the fundamentals of DevOps and MLOps but broadens the scope of operations.
In a traditional system, the primary deployment unit might be a model and its inference pipeline. In an LLM-based application, behavior depends on a composition of elements: prompt template, model version, context rules, tools, policies, generation parameters, and post-processing.
Versioningonly the model name is not enough. A change in document chunking or in a tool’s description can alter the response more than changing the architecture.
LLMOps does not replace MLOps. It extends its principles to a system where behavior depends on more components and where quality cannot always be captured by a single metric.
The Problem with Open Evaluation
A multiple-choice question has a relatively clear answer key. A long answer may be correct yet still inadequate because it is confusing, verbose, incomplete, or uncertain.
A robust strategy combines various forms of evaluation:
The goal is not to find a perfect metric, but to gather sufficient evidence to decide whether a version is better and whether it can be released with an acceptable level of risk.
Frameworks and providers change rapidly. A sustainable architecture avoids unnecessary coupling: it separates business logic, templates, model access, data retrieval, tools, and evaluation.
This separation allows you to replace a model, experiment with another search strategy, or change a prompt without rewriting the entire product. It also makes it easier to compare versions and understand the source of a regression.
Tools change. The principles remain: clear objectives, observable systems, reproducible changes, continuous evaluation, and responsible deployment.
The main purpose of the three levers is to prevent the team from treating every failure as a model deficiency.
A poor response may be the result of a vague task. A hallucination may occur because the system did not consult the correct source. High latency may stem from an over-engineered model. An inconsistent format may warrant fine-tuning—or simply better examples.
Diagnosis comes before optimization. First, identify where the behavior deviates from the requirement; then choose the lever capable of correcting that deviation at the lowest systemic cost.
Building with LLMs isn’t about finding the largest model and hoping for a good response. It’s about controlling, measuring, and combining instructions, context, and the model until the system becomes useful—and remains useful in production.
In just 6 months, Foursys strengthened a financial institution’s security with Zero...
Artificial Intelligence, non-human identities, post-quantum cryptography, the evolving...
How to transition data analytics from a one-off project to a continuous engine of...
At Foursys, we connect strategy, innovation, digital engineering, data, AI, cybersecurity and organizational agility to build complete, secure and scalable solutions. We work from concept to sustained operation, helping companies modernize, accelerate delivery, make smarter decisions and generate continuous value across their digital transformation journey.
Av. Tamboré, 267 - Torre Norte
9º Floor |+55 (11) 4134-2222
Av. Paulista, 1912
15th Floor | +55 11 4861-8560
R. Comendador Araújo, 499
10th Floor | +55 (41) 2106-6709
Av. Pres. Vargas, 3131 - Suite 604
Cidade Nova, Rio de Janeiro
980 N. Federal Highway #110
Boca Raton, Florida 33432
Dedicated to Information Security and AI
Avenida da Liberdade, 110
1269-046 Lisboa, Portugal