AI EngineeringInterview preparation
Foundation·Concept·2 min read

LLMs and how they work

Practice this question

Overview

  • A large language model, or LLM, is a model trained on large amounts of data to process and generate language.
  • It learns patterns in how text is arranged and can use those patterns for summarization, extraction, explanation, and tool selection.
  • It does not automatically know your database or verify the truth of each sentence.

Why this matters

It provides a reusable language interface without training a separate model for every wording or task.

An everyday example

Imagine an extremely practiced writing assistant who can continue many kinds of text but needs your company records to answer company-specific questions.

A technical example

generate("Summarize this accident description in three bullets: ...") returns a useful draft.

How it works

  1. Text is split into tokens
  2. Converted into numerical representations
  3. Processed through neural-network layers
  4. Scores are produced for possible next tokens
  5. Tokens are selected repeatedly until completion.
  • Attention is a mechanism that lets the model combine information from different positions in its input; training adjusts the numerical parameters used by that process.

Architecture and flow

Prompt → tokenizer → model inference → generated tokens → decoded text. Inference means using an already trained model.

The insurance assistant example

The assistant rewrites backend claim status awaiting_documents into “We are waiting for your repair invoice.” It must get that status from a tool first.

When to use it

For unstructured language transformation, grounded explanations, or bounded selection between tools.

When to avoid it

As the source of truth for claim status, coverage eligibility, prices, or access permissions.

Interview answer

“An LLM generates language from learned patterns and supplied context. I use it for interpretation and communication, while tools and business services provide verified facts and actions.”

Benefits, trade-offs, and production considerations

  • A hallucination is output that is unsupported or false even though it sounds convincing.
  • Better prompting reduces some errors but cannot turn a probabilistic model into a trustworthy database.
  • Version prompts and models and evaluate each change.
Adapted from 13_AI.MD · “LLMs and how they work”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.