Artificial intelligence
AI from model choice to evaluation
Classifying requests, detecting objects in images and answering questions from documents are three different problems. I start with the task, the available data and the errors we can tolerate.
- 01QuestionUnderstand the request and its constraints.
- 02RetrievalRetrieve passages from authorised documents.
- 03ContextAttach passages and their references.
- 04AnswerCite sources or flag insufficient evidence.
Start with the task and the cost of error
- Define the task
- Identify costly errors
- Measure on a test set
I start by stating what the system must recognise or produce, then collect a few difficult examples. When triaging requests, confusing two common categories may cost less than overlooking an emergency. I look at recall for emergencies and inspect false negatives. Then I choose a decision threshold. Higher recall can also send too many cases to an already busy team. The metric should help weigh a real consequence.
For tabular data, I first compare a simple rule, logistic regression or a decision tree. I keep a test set separate from training and tuning. If rows come from the same users or period, the split should reflect how the model will be used. Otherwise similar information can cross the boundary and make the score overly optimistic.
Choose an architecture that fits the signal
- Features · dense network
- Images · convolution
- Sequences · attention
A dense network combines numerical features across several layers. A convolutional network applies local filters and reuses them across an image. A Transformer uses attention to relate elements of a sequence. I compare these architectures by data structure, available examples, latency and budget. TensorFlow and Keras provide tools to build, train and evaluate networks. The framework helps implement and measure a modelling decision.
Evaluate RAG at each step
- Expected sources
- Retrieved passages
- Answer and citations
In a document assistant, I separate indexing from question handling. Indexing splits documents into passages and retains metadata such as their source and access rights. For a question, retrieval selects passages the user is allowed to see, then the model receives that context and produces an answer. Two failures can look the same. Retrieval may have missed the right passage, or the model may have ignored a passage it was given.
To tell the difference, I prepare questions with expected passages, ambiguous cases and questions with no answer. I check the passages retrieved, then citations and whether the response stays faithful to its sources. On the backend I check permissions before sending context to the model. I also measure time and cost per step so I know where to intervene. A fluent answer is easy to generate when documents conflict. A useful answer must make the uncertainty visible.