LearnFrenzy
Sign in Take a free test

Generative AI & LLMs interview · Set 1 of 3

LLM Fundamentals: Tokens, Embeddings and Training

  • 5 follow-up questions
  • 4 key points
  • Code examples
Test yourself

An accurate mental model of LLMs

Next-token prediction, tokens and context, embeddings, and the training stages explain nearly everything else: costs, limits, hallucinations and why grounding works.

  • MechanicsTransformers, attention and tokens.
  • MeaningEmbeddings and semantic similarity.
  • BehaviourTraining stages, hallucinations and reasoning.

You do not need a PhD to answer LLM questions well, but you do need an accurate mental model. Interviewers check whether you understand what a model actually does (predict the next token), what limits it (context, training data) and why it sometimes confidently makes things up.

1. What is a large language model, in simple terms?

A neural network — almost always a transformer — trained on huge amounts of text to predict the next token given everything before it. Repeating that prediction produces sentences, code and analysis. Through scale and further training on instructions and feedback, models learn to follow requests, reason through problems and use tools.


2. What are tokens and the context window?

Models read and write tokens — pieces of words, roughly 3–4 characters of English on average (other languages and code often use more). The context window is how many tokens the model can consider at once, including the prompt, documents, conversation history and its own reply. Pricing, speed and limits are all measured in tokens.


3. What is attention and why did transformers win?

Attention lets each token look at every other token in the context and decide which ones matter for its meaning — “it” can attend to the noun it refers to. Transformers process all tokens in parallel during training (unlike older RNNs that read one word at a time), which made it possible to train on far more data with far bigger models.


4. What are embeddings and where are they used?

An embedding is a list of numbers (a vector) that represents meaning, so similar texts get vectors that are close together. They power semantic search, recommendation, clustering, de-duplication and the retrieval step of RAG. Similarity is usually measured with cosine similarity.

import numpy as np

def cosine(a, b):
    return float(np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)))

# vectors from any embedding model
print(cosine(embed("How do I reset my password?"), embed("Forgot login credentials")))   # high
print(cosine(embed("How do I reset my password?"), embed("Best biryani in Hyderabad")))  # low

5. How are LLMs trained?

Pre-training: predict the next token over a vast text corpus — this builds knowledge and language skill. Instruction tuning (supervised fine-tuning): train on examples of good responses to requests. Preference training: reinforcement learning from human feedback (RLHF) or from AI feedback guided by written principles (as in Anthropic's Constitutional AI), so the model becomes more helpful, honest and harmless.


6. Why do LLMs hallucinate?

The model generates the most plausible continuation, not a looked-up fact. When it lacks knowledge — recent events, private data, obscure details — a fluent but wrong answer can still look plausible. Reduce it by grounding answers in retrieved sources, allowing “I don't know”, asking for citations, and verifying critical facts.


7. What are reasoning (thinking) models?

Models that spend extra computation reasoning before answering — internally working through steps, checking and revising. They do much better on maths, coding and multi-step analysis. Many APIs let you control how much effort the model spends, trading cost and latency for quality.


8. Open-weight vs closed (API) models — how do you choose?

API models (such as Claude, GPT and Gemini) usually lead on capability, need no infrastructure and improve continuously. Open-weight models (such as Llama, Mistral, Qwen and Gemma) can run on your own servers for strict data-residency or offline needs and can be fine-tuned freely, but you manage hosting, scaling and safety. Many teams prototype with an API and evaluate open models for specific high-volume tasks.


Remember

Key points

  • Everything is tokens

    Cost, speed and limits are measured in tokens.

  • Embeddings capture meaning

    Close vectors mean similar texts.

  • Plausible is not true

    Ground answers in sources.

  • Reasoning costs tokens

    Spend effort where tasks need it.

Interview drill

Follow-up questions

What the interviewer asks after your first answer. Turn on practice mode, answer each one aloud, then reveal.

  1. 1 What is the difference between a base model and an instruct/chat model? Basic

    A base model only continues text; an instruct model has been further trained to follow requests and hold conversations safely.

  2. 2 What is a knowledge cutoff? Basic

    The date after which the model has no training data. For later information you must provide it — through search, RAG or the prompt.

  3. 3 What is quantisation? Advanced

    Storing model weights with fewer bits (8-bit, 4-bit) to cut memory and speed up inference, with a small loss of quality. Common for running open models on modest hardware.

  4. 4 What is multimodality? Basic

    Models that accept more than text — images, PDFs, audio — and reason across them, such as reading a chart and answering questions about it.

  5. 5 Why do longer prompts cost more and run slower? Intermediate

    Every input token is processed and billed; attention cost also grows with context length. Prompt caching and trimming irrelevant context help.

Preparing with friends?

Share this page with your study group or placement batch.

Search LearnFrenzy

Esc

Quick links