Unit 1: Foundations of LLMs and Agentic Systems - Subjective Questions
CSE473 — Large Language Models And Agentic Ai • Practice Questions with Detailed Answers
20 questions
Define an intelligent agent. Explain the key characteristics that make an agent rational and autonomous.
An intelligent agent is an entity that perceives its environment through sensors, processes the received information, and acts upon the environment through actuators to achieve specified goals.
Key characteristics include:
- Perception: It gathers information about the current state of the environment.
- Autonomy: It operates without continuous human intervention and controls its own actions.
- Rationality: It selects actions expected to maximize a given performance measure based on available information.
- Reactivity: It responds appropriately to changes in the environment.
- Proactiveness: It takes initiative and plans actions to achieve future goals.
- Learning ability: It improves its behavior using experience or feedback.
A rational agent does not necessarily make a perfect decision; it chooses the best expected action using its percept history, prior knowledge, available actions, and computational limitations.
Describe the major types of intelligent agents and provide a suitable example of each.
The major types of intelligent agents are:
- Simple reflex agents: Select actions using condition-action rules based only on the current percept. Example: a thermostat switching heating on when the temperature is low.
- Model-based reflex agents: Maintain an internal state to represent aspects of the environment that are not directly observable. Example: a robotic vacuum remembering obstacles.
- Goal-based agents: Evaluate actions according to whether they help achieve a specified goal. Example: a navigation system planning a route to a destination.
- Utility-based agents: Choose actions that maximize a utility function when several outcomes can satisfy a goal. Example: a route planner balancing travel time, cost, and safety.
- Learning agents: Improve their performance through experience and feedback. Example: a recommendation system learning user preferences.
Modern agentic AI systems often combine these types by using internal models, goals, utility criteria, planning, tools, and learning.
Explain the emergence of Agentic AI and identify the technological developments that made it possible.
Agentic AI refers to AI systems that can pursue goals through multiple steps, make decisions, use tools, observe results, and adapt their behavior with limited human supervision.
Its emergence was enabled by:
- Large language models: LLMs provide general-purpose language understanding, reasoning, and generation capabilities.
- Transformer scaling: Larger models trained on extensive datasets exhibit increasingly general capabilities.
- Instruction tuning and alignment: These methods make models better at following goals expressed in natural language.
- Tool and API integration: Agents can search databases, execute code, call services, and interact with software.
- Memory systems: Short-term context and external long-term storage help agents preserve relevant information.
- Planning and reasoning methods: Prompting and orchestration frameworks support task decomposition and iterative problem-solving.
- Feedback loops: Agents can inspect tool outputs, detect failures, and revise their plans.
Thus, Agentic AI extends a generative model from producing a single response to operating within a repeated perception, reasoning, action, and evaluation loop.
Distinguish between a conventional LLM-based chatbot and an agentic AI system.
A conventional LLM-based chatbot and an agentic AI system differ in the following ways:
- Primary behavior: A chatbot usually generates a response to each prompt, whereas an agent pursues a goal through a sequence of actions.
- Planning: A chatbot may explain a plan, but an agent can create, execute, and revise one.
- Tool use: Basic chatbots rely mainly on model parameters and prompt context; agents can invoke APIs, databases, code interpreters, and other tools.
- Memory: Chatbots commonly use the current conversation context, while agents may also maintain task state and external long-term memory.
- Environment interaction: A chatbot primarily exchanges text; an agent observes and modifies an external environment.
- Feedback: An agent evaluates action results and changes its next action accordingly.
- Autonomy: Agentic systems can perform multi-step work with less frequent human intervention.
The boundary is not absolute: an LLM becomes a component of an agent when it is connected to goals, memory, tools, control logic, and an iterative action loop.
Describe the basic architecture of a Transformer and explain the functions of its principal components.
A Transformer processes a sequence using attention and feed-forward layers rather than recurrence.
Its principal components are:
- Token embeddings: Convert discrete token identifiers into dense vectors.
- Positional information: Encodes token order because self-attention alone is permutation-invariant.
- Multi-head self-attention: Allows every token to gather relevant information from other permitted positions through multiple attention heads.
- Feed-forward network: Applies nonlinear transformations independently to each token representation.
- Residual connections: Add a sublayer's input to its output, supporting gradient flow and information preservation.
- Layer normalization: Stabilizes activations and training.
- Stacked layers: Repeated attention and feed-forward blocks build increasingly contextual representations.
- Output projection: Maps final hidden states to vocabulary logits for token prediction.
The original Transformer contains an encoder and a decoder. Encoder-only models emphasize representation learning, decoder-only models perform autoregressive generation, and encoder-decoder models are suited to sequence-to-sequence tasks.
Explain the self-attention mechanism and derive the scaled dot-product attention equation.
Self-attention computes a context-sensitive representation of each token by comparing it with tokens in the same sequence.
Given an input matrix , learned projection matrices produce queries, keys, and values:
Each query is compared with every permitted key using a dot product. The scores are divided by , where is the key dimension, and normalized with softmax:
The derivation can be understood in four stages:
- calculates query-key similarity scores.
- Division by prevents large dot products from pushing softmax into regions with very small gradients.
- Softmax converts scores into nonnegative attention weights that sum to one along each row.
- Multiplication by forms a weighted sum of value vectors.
In decoder-only LLMs, a causal mask blocks attention to future tokens so that prediction remains autoregressive.
What is multi-head attention? Explain why multiple attention heads are useful in Transformers.
Multi-head attention performs several attention operations in parallel using different learned projections of the same inputs. For head :
The outputs are concatenated and projected:
Multiple heads are useful because they can:
- Attend to different positions simultaneously.
- Capture different relationships, such as syntax, coreference, locality, and long-range dependence.
- Operate in distinct learned representation subspaces.
- Provide richer contextual information than a single attention distribution.
Although heads are not guaranteed to have easily interpretable roles, their combined learned patterns increase the model's representational capacity.
Explain why Transformers require positional information. Compare absolute positional embeddings and relative or rotary positional approaches.
Self-attention compares token representations without inherently knowing their order. Without positional information, sequences containing the same tokens in different orders could appear equivalent to the model.
Common approaches include:
- Absolute positional embeddings: A position-specific vector is added to each token embedding. These vectors may be fixed, such as sinusoidal encodings, or learned during training. They directly indicate positions such as first, second, or third.
- Relative positional methods: Attention computations incorporate the distance or relationship between two token positions. These methods emphasize how far apart tokens are rather than only their absolute indices.
- Rotary positional embeddings: Position-dependent rotations are applied to query and key vectors. Their dot products encode relative positional differences while retaining useful absolute-position structure.
Absolute embeddings are conceptually simple, while relative and rotary methods often model token-to-token distance more naturally and may generalize better across sequence lengths. Actual long-context performance still depends on training, scaling choices, and model design.
Define tokenization and explain why it is important in the design and operation of LLMs.
Tokenization is the process of converting raw text into a sequence of discrete units called tokens, each mapped to an integer identifier in a model vocabulary.
It is important because:
- LLMs operate on numerical token identifiers rather than raw text.
- Token choices determine sequence length and therefore affect computation and context-window usage.
- Vocabulary design influences how efficiently common words, rare words, numbers, code, and multilingual text are represented.
- It helps handle words that were not seen exactly during training by dividing them into smaller units.
- Token boundaries affect generation because an LLM predicts one token at a time rather than necessarily one word at a time.
A good tokenizer balances vocabulary size and sequence length. Very small units increase sequence length, while very large vocabularies consume more model capacity and may poorly represent rare or unseen forms.
Compare word-level, character-level, and subword tokenization approaches.
The three approaches differ in their basic units and trade-offs:
- Word-level tokenization: Treats each word as one token. It produces short sequences for familiar text but requires a very large vocabulary and handles rare or unseen words poorly.
- Character-level tokenization: Treats individual characters as tokens. It uses a small vocabulary and can represent nearly any text, but produces long sequences and makes learning word-level patterns more difficult.
- Subword tokenization: Splits text into frequent words and reusable word pieces. It offers a compromise between vocabulary size, sequence length, and open-vocabulary coverage.
Subword methods such as Byte Pair Encoding, WordPiece, and Unigram Language Model tokenization are widely used in LLMs. Byte-level variants can encode arbitrary input bytes and reduce unknown-token problems, though token efficiency may vary across languages and data types.
Describe how Byte Pair Encoding (BPE) constructs a subword vocabulary and tokenizes new text.
Byte Pair Encoding is a data-driven subword tokenization method.
A simplified training procedure is:
- Represent training words as sequences of basic symbols, such as characters or bytes.
- Count adjacent symbol-pair frequencies across the corpus.
- Merge the most frequent adjacent pair into a new symbol.
- Recount pairs and repeat until the desired vocabulary size is reached.
- Store the learned merge rules and their priority order.
To tokenize new text, the tokenizer starts from the same basic symbols and applies learned merges according to the trained rules. Frequent patterns become single tokens, while rare words remain decomposed into smaller pieces.
Advantages include open-vocabulary coverage and efficient encoding of common patterns. Limitations include linguistically unnatural boundaries, different token efficiency across languages, and sensitivity to the training corpus and preprocessing rules.
Explain the autoregressive pre-training objective used by causal language models.
An autoregressive or causal language model learns to predict each token from the tokens that precede it. For a sequence , the probability is factorized as:
Training usually minimizes the negative log-likelihood or cross-entropy loss:
A causal attention mask prevents a position from using future tokens. During training, the correct preceding tokens are normally supplied, while during generation the model repeatedly uses previously generated tokens to predict the next one.
This objective naturally supports open-ended text generation and is widely used by decoder-only LLMs. However, it does not guarantee factuality, reasoning correctness, or alignment with human instructions; those qualities require suitable data, post-training, tools, or verification.
Compare causal language modeling, masked language modeling, and sequence-to-sequence denoising as pre-training objectives.
These objectives teach models using different prediction structures:
- Causal language modeling: Predicts each next token from previous tokens. It uses a left-to-right factorization and is well suited to decoder-only text generation.
- Masked language modeling: Replaces or hides selected input tokens and predicts them using context from both sides. It is common in encoder-only models and produces strong contextual representations.
- Sequence-to-sequence denoising: Corrupts an input sequence and trains an encoder-decoder model to reconstruct the original text. Corruption may involve masking spans, deleting tokens, or rearranging segments.
Causal modeling directly matches autoregressive generation. Masked modeling supports bidirectional understanding but does not directly train unrestricted left-to-right generation. Denoising trains a model to transform an input sequence into an output sequence and is effective for summarization, translation, and other conditional generation tasks.
Describe the perception-action cycle of an intelligent agent.
The perception-action cycle is a repeated loop through which an agent interacts with its environment:
- Perceive: Sensors, interfaces, or tools collect observations from the environment.
- Interpret: The agent converts observations into a useful internal representation.
- Update state or memory: It combines new evidence with prior observations and stored knowledge.
- Select a goal or assess progress: It identifies the desired outcome and checks the current state against it.
- Plan or decide: It evaluates possible actions and selects an appropriate next step.
- Act: Actuators or tools apply the chosen action to the environment.
- Observe feedback: The agent receives the consequences of the action and begins the next cycle.
For an LLM-based agent, perception may be text or tool output, reasoning may be performed by the LLM and controller, and action may be an API call. The feedback loop enables correction and adaptation, but safeguards are needed because errors can propagate across steps.
Explain agent-environment interaction using the concepts of percepts, actions, state, goals, and performance measures.
Agent-environment interaction can be described through the following concepts:
- Percept: An individual observation received by the agent at a particular time.
- Percept sequence: The complete history of observations available to the agent.
- Action: An operation selected by the agent that may change the environment.
- State: A representation of the relevant condition of the environment. The agent may maintain an internal state when the full environment state is not observable.
- Goal: A desired state or outcome that guides planning and action selection.
- Performance measure: An external criterion used to evaluate how successfully the agent behaves.
An agent function conceptually maps percept histories to actions:
A rational agent chooses actions expected to maximize its performance measure given its information and capabilities. Good agent design therefore requires clear goals, reliable observations, suitable actions, and a performance measure that discourages harmful shortcuts.
Classify agent environments using the standard properties of observability, determinism, dynamics, discreteness, and number of agents.
Agent environments can be classified along several dimensions:
- Fully observable vs. partially observable: In a fully observable environment, sensors provide all relevant state information. In a partially observable environment, information is missing, noisy, or hidden.
- Deterministic vs. stochastic: In a deterministic environment, an action has a predictable result. In a stochastic environment, outcomes involve uncertainty.
- Static vs. dynamic: A static environment does not change while the agent deliberates. A dynamic environment may change independently over time.
- Discrete vs. continuous: States, actions, and time may be countable and distinct or may vary continuously.
- Single-agent vs. multi-agent: A single-agent environment contains one decision-maker, whereas a multi-agent environment includes cooperative or competing agents.
- Episodic vs. sequential: Episodic decisions are largely independent; sequential actions influence later situations.
- Known vs. unknown: In a known environment, transition rules are available; in an unknown one, the agent must learn or estimate them.
Real-world agentic systems commonly operate in partially observable, stochastic, dynamic, sequential, and sometimes multi-agent environments.
Discuss the roles of planning, memory, tools, and feedback in an LLM-based agent.
An LLM-based agent combines several components:
- Planning: Decomposes a high-level goal into manageable steps, orders dependencies, and selects future actions.
- Working memory: Holds the current task, recent observations, intermediate results, and active plan within the context or state store.
- Long-term memory: Stores reusable facts, past experiences, preferences, or task records in external systems for later retrieval.
- Tools: Extend the model beyond text generation by enabling search, calculation, code execution, database access, and external actions.
- Feedback: Supplies observations after actions so that the agent can measure progress, detect errors, and revise its plan.
These components form a closed-loop system. Their reliability depends on correct tool schemas, relevant memory retrieval, controlled permissions, output validation, stopping conditions, and human approval for high-impact actions.
Compare encoder-only, decoder-only, and encoder-decoder Transformer models, including their common applications.
Transformer families differ in architecture and attention patterns:
- Encoder-only models: Process the input bidirectionally so each token can use left and right context. They are commonly used for classification, semantic search, token labeling, and representation learning. BERT is a prominent example.
- Decoder-only models: Use causal self-attention so each position accesses only earlier tokens during generation. They are widely used for completion, dialogue, coding, and general-purpose generation. The GPT family, Llama, and many other generative LLMs use this design.
- Encoder-decoder models: The encoder builds a representation of the input, while the decoder generates output using causal self-attention and cross-attention to encoder states. They are suited to translation, summarization, and conditional text transformation. T5 is a well-known example.
Architecture suggests a model's natural strengths, but training data, scale, post-training, context length, and deployment design also strongly influence performance.
Provide an overview of popular LLM families and compare them using meaningful technical and practical criteria.
Representative LLM families include:
- GPT models: Decoder-only generative models known for broad language, reasoning, coding, and tool-use capabilities.
- Gemini models: Multimodal model families designed to process and generate across several forms of information.
- Claude models: General-purpose assistants emphasizing long-context tasks, language generation, reasoning, and tool integration.
- Llama models: A family with openly available model weights for several releases, supporting research and customized deployment subject to their licenses.
- Mistral and Mixtral models: Families that include dense and mixture-of-experts designs, with attention to efficient deployment.
- BERT: An encoder-only masked language model influential in language understanding and representation learning.
- T5: An encoder-decoder family that frames many NLP tasks as text-to-text transformations.
Meaningful comparison criteria include:
- Architecture and parameter activation strategy
- Input and output modalities
- Context-window size
- Benchmark and task-specific quality
- Latency, throughput, and hardware cost
- Tool-use and structured-output support
- Fine-tuning and deployment options
- License, privacy, safety controls, and data governance
No model is universally best; selection should be based on validated task requirements rather than popularity alone.
Analyze the main limitations and risks of LLM-powered agentic systems and describe suitable mitigation measures.
Major limitations and risks include:
- Hallucination: The model may generate unsupported claims or incorrect plans.
- Error accumulation: A small mistake can propagate through a multi-step workflow.
- Prompt injection: Untrusted environmental content may attempt to alter the agent's instructions or misuse its tools.
- Excessive permissions: Broad tool access can turn reasoning errors into harmful real-world actions.
- Bias and unfairness: Training data and system design may produce unequal outcomes.
- Privacy leakage: Prompts, logs, memory, or tool calls may expose sensitive data.
- Unpredictable costs or loops: Poor stopping rules may cause unnecessary actions and resource consumption.
- Limited transparency: It may be difficult to determine why a model selected an action.
Mitigations include:
- Ground responses in trusted data and require citations where appropriate.
- Validate tool arguments and outputs using deterministic checks.
- Apply least-privilege access, sandboxing, rate limits, and allowlists.
- Separate untrusted content from system instructions and treat retrieved text as data.
- Require human approval for irreversible or high-impact actions.
- Use monitoring, audit logs, budgets, timeouts, and explicit stopping conditions.
- Conduct adversarial testing and task-specific evaluation before deployment.
Define an intelligent agent. Explain the key characteristics that make an agent rational and autonomous.
An intelligent agent is an entity that perceives its environment through sensors, processes the received information, and acts upon the environment through actuators to achieve specified goals.
Key characteristics include:
- Perception: It gathers information about the current state of the environment.
- Autonomy: It operates without continuous human intervention and controls its own actions.
- Rationality: It selects actions expected to maximize a given performance measure based on available information.
- Reactivity: It responds appropriately to changes in the environment.
- Proactiveness: It takes initiative and plans actions to achieve future goals.
- Learning ability: It improves its behavior using experience or feedback.
A rational agent does not necessarily make a perfect decision; it chooses the best expected action using its percept history, prior knowledge, available actions, and computational limitations.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →