EN
Free assessment

Expertise · LLM and RAG

LLM and RAG Integration

iTask integrates LLMs and RAG into your company's systems: agents that query data and execute actions, a knowledge base with search and source citation, automatic evaluation on every change and cost per call measured. The project starts with a free assessment and reaches production in weeks.

LLM and RAG

Typical command line

retriever.invoke(query)

When to use it

When LLM and RAG makes sense

  1. Your support repeats the same answers and loses time on simple queries
  2. There is a lot of knowledge in documents that nobody can find
  3. You want to automate a task that reads text, decides and acts in a system
  4. You tried a chatbot and it answered wrong or cost more than planned

Architecture

The architecture we usually apply

Agent orchestration with tool calling, RAG with hybrid search and reranking, input and output guardrails, queues for asynchronous calls, an evaluation set run in the pipeline, cost and latency logging per step and a human handoff queue.

A well-integrated LLM solves tasks that used to require human reading and judgment: answering questions from documents, classifying tickets, extracting data from text and executing actions in systems. Poorly integrated, it invents answers and produces unpredictable cost. The difference lies in the engineering around the model.

We have hands-on experience: customer service with AI agents on WhatsApp; and our own platform, AgentHub, which supports products for clinics, insurance brokers, real estate agencies and condominiums.

RAG in practice

RAG has four stages, and each one can fail.

1. Ingestion. We clean and split documents into passages with size and overlap tuned to the content. We keep metadata: source, date, area, access permission. PDFs with tables and images need their own extraction.

2. Search. We combine vector similarity search with keyword search (hybrid search), because names, codes and acronyms escape vectors. Metadata filters prevent pulling a document from another client or an old version.

3. Reranking. A second pass reorders the retrieved passages by their real relevance to the question, and only the most relevant ones go to the model. This reduces cost and noise.

4. Generation with citation. The model answers only from the passages and cites the sources. When the passages do not cover the question, it says it does not know and hands off to a person.

Agents with tools

An agent combines the model with functions that read and change data: look up an order, open a ticket, book an appointment. Each tool has a validated input schema, least-privilege permission and an audit log. Sensitive actions ask for confirmation. Long flows use queues and persistent state, with the same messaging discipline we apply in RabbitMQ: retries, idempotency and a dead-letter queue.

Continuous evaluation

Without evaluation, tuning a prompt is a bet. From the start we build:

  • A case set. Anonymized real questions, edge cases, abuse attempts and out-of-scope questions.
  • Criteria. Factual correctness, use of the source, tone, refusal when appropriate and correct tool execution.
  • Evaluators. Deterministic rules, a calibrated judge model and human sampling.
  • Execution in the pipeline. On every change of prompt, model or knowledge base, the set runs and compares with the previous version. A regression blocks the deploy.
  • Production monitoring. Samples of real conversations enter the set, and the set grows with use.

Cost per call

We record, per step, input and output tokens, latency and cost. The dashboard shows cost per conversation, per client, per model and per day. The levers:

  • a smaller model for classification and extraction, a larger model only for hard reasoning;
  • caching of answers and embeddings;
  • lean context, with reranking and history summarization;
  • limits per conversation and per user;
  • batch processing for non-urgent tasks.

That way the monthly bill can be forecast before volume grows.

Security and privacy

Masking of personal data before sending when the case allows, access control in search, defense against prompt injection, audit logs and a retention policy. We respect privacy law, with a legal basis and consent where the law requires. Content the user types is treated as untrusted input, and never as instruction.

Working with a Brazilian team

Our engineers are based in Brazil, in time zones that overlap with the US working day, and we communicate in English.

How we deliver in weeks

  1. Our own boilerplates. Agent orchestration, a RAG pipeline, an evaluation and cost dashboard, WhatsApp connectors and queues already built.
  2. AI agents with senior review. Agents write and review code, and senior engineers approve each delivery.
  3. The same team from assessment to deploy. The people who understand the process build and operate the agent.
  4. Fixed scope after the assessment. The free assessment defines use case, sources and criteria, with a timeline of 2 to 4 weeks for an agent.

Common mistakes we fix

Passages that are too large. The model receives noise and the answer gets diluted. We tune the size per document type.

An outdated knowledge base. Old documents coexist with new ones and produce contradictory answers. Each passage has a date and version, and search prioritizes the current one.

No plan for what the agent does not know. The agent must know how to stop. We define the polite refusal, the attempt limit and the handoff to a person, with the conversation history attached.

Changing models without testing. The provider updates the model and behavior shifts. The evaluation pipeline detects the difference before the customer does.

Ignored latency. On WhatsApp or voice, seconds matter. We use streamed responses, context prefetching and smaller models in the fast steps.

When not to use an LLM

If the rule is fixed and known, ordinary code solves it with more predictability and lower cost. If an error has serious consequences and there is no human review, the LLM comes in as support, and the final decision stays with a person. We say so in the assessment, before any contract.

This work is part of the AI agent development service. Request the free assessment.

FAQ

Questions about LLM and RAG

Did not find your question? Write to us.

What is RAG?

It is retrieving relevant passages from your documents and handing them to the model along with the question. The answer rests on your sources, and not only on what the model learned. Updating knowledge means reindexing the documents.

Fine-tuning or RAG?

In most business cases, RAG. It is cheaper, easy to update and lets you cite the source. Fine-tuning comes in to adjust style, format or very specific tasks, after measuring that RAG is not enough.

How do you measure answer quality?

With an evaluation set of real questions, expected answers and criteria, scored by rules and by a judge model, with human sampling. It runs on every change of prompt, model or knowledge base.

How do you control cost?

We record tokens and cost per step and per conversation. We use smaller models where they are enough, caching of frequent answers, context limits and routing by complexity.

Does my data leave the company?

It depends on the provider and the contract. We map what is sent to the model, mask personal data, choose suitable regions and retention terms and log access.

Tell us what you need to build.

Ask for a free assessment and get a clear path for your project, with no commitment.

Free assessment