Prompt Engineering Comprehensive Quiz & Projects
30 questions on Prompt Engineering Tutorial.
Question 1: What is the difference between Zero-Shot and Few-Shot prompting?
- A. Zero-shot uses zero tokens, while Few-shot uses a compressed token vocabulary.
- B. Zero-shot asks the model to perform a task without examples, while Few-shot provides examples of desired input-output behavior. β (correct answer)
- C. Zero-shot is used for images, while Few-shot is used for code.
- D. Zero-shot runs faster but costs more in token usage.
Explanation: Few-shot prompting provides context examples to steer the model towards specific structural formats or processing logic.
Question 2: How does Chain-of-Thought (CoT) prompting improve an LLM's performance on logical reasoning tasks?
- A. By forcing the model to generate a hidden key token.
- B. By instructing the model to output its reasoning steps sequentially before outputting the final answer. β (correct answer)
- C. By increasing the model's training learning rate.
- D. By executing calculations in a Python interpreter sandbox.
Explanation: Explaining step-by-step logic allows the model to compute intermediate states, increasing accuracy in math and logic.
Question 3: What is the primary function of a 'System Prompt' in API integrations?
- A. To define server configurations like memory usage and execution timeouts.
- B. To set the persistent behavior, persona, bounds, and safety guidelines for the model across interactions. β (correct answer)
- C. To clean input whitespace strings automatically.
- D. To log user queries to administrative database tables.
Explanation: System prompts establish the global behavior and strict guardrails that dictate how the model interacts with user prompts.
Question 4: What is a 'Prompt Injection' attack?
- A. A technique used to optimize token consumption in REST APIs.
- B. When malicious user inputs trick the LLM into ignoring its system prompt guardrails to output restricted content. β (correct answer)
- C. When an attacker hacks the database holding raw model weights.
- D. When a model generates response payloads containing SQL code.
Explanation: Prompt injection bypasses system prompts, overriding safety constraints via user commands (e.g. 'Ignore previous instructions').
Question 5: How does the Top-P (Nucleus Sampling) parameter differ from Temperature?
- A. Top-P scales GPU processing threads.
- B. Top-P limits token selection to a dynamic set of words whose cumulative probability exceeds the threshold P. β (correct answer)
- C. Top-P checks grammar syntax, while Temperature controls model speed.
- D. Top-P restricts output token count limits.
Explanation: Top-P controls token selection diversity. Setting P=0.9 considers only the top words making up 90% of probability mass.
Question 6: What is 'Prompt Engineering'?
- A. Coding the neural network parameters in Python.
- B. The practice of designing and refining inputs to get the most accurate, relevant, and formatted outputs from LLMs. β (correct answer)
- C. Managing server API server hardware.
- D. Parsing user databases automatically.
Explanation: Prompt engineering aligns input instructions to steer LLM probability generation effectively.
Question 7: What is the difference between dynamic prompts and static prompts?
- A. Static prompts are encrypted.
- B. Static prompts use fixed text, while Dynamic prompts use templates that inject variables at runtime (e.g. user queries). β (correct answer)
- C. Dynamic prompts require fine-tuning of the model.
- D. There is no difference.
Explanation: Dynamic prompts utilize template frameworks to customize queries based on variables.
Question 8: What does the 'ReAct' (Reasoning + Acting) prompt pattern enable LLMs to do?
- A. Re-compile code files.
- B. Interleave reasoning steps with action calls (e.g., searching the web or running code) to solve complex tasks using tools. β (correct answer)
- C. Encrypt API connection headers.
- D. Route requests to different servers.
Explanation: ReAct patterns structure cycles of thought, action, and observation, allowing tools integrations.
Question 9: Which parameter controls the maximum length of the output generated by the model?
- A. Temperature
- B. Max Tokens β (correct answer)
- C. Top-P
- D. System Prompt
Explanation: Max Tokens limits generation length, stopping the model once the token count is hit.
Question 10: How do you instruct an LLM to reliably return data in JSON format?
- A. By writing the prompt in JSON.
- B. By providing a strict system prompt, requesting JSON explicitly, and showing a few-shot example of the target schema. β (correct answer)
- C. By disabling text output channels.
- D. By modifying the database schemas.
Explanation: Explicit schema descriptions + few-shot templates are standard to guarantee formatting patterns.
Question 11: What is the role of 'Few-Shot Chain of Thought' prompting?
- A. Limiting output token length.
- B. Combining few-shot examples with step-by-step reasoning steps to demonstrate logical processing workflows. β (correct answer)
- C. Training parameters on small arrays.
- D. Resetting weight metrics.
Explanation: Few-shot CoT guides the model to solve complex math/logic using the correct sequential thought structure.
Question 12: What is a 'Negative Prompt'?
- A. A prompt containing spelling mistakes.
- B. An instruction telling the model what NOT to include or generate in its response. β (correct answer)
- C. A query that returns error codes.
- D. A script that deletes log files.
Explanation: Negative prompts set explicit boundaries (e.g. 'Do not write any introductory text').
Question 13: What does 'Context Window Stuffing' refer to?
- A. Compressing PDF payloads.
- B. Overloading the prompt context with massive reference data, which can degrade model attention focus and cause recall failures. β (correct answer)
- C. Compiling multiple models.
- D. Clearing browser cookies.
Explanation: Excess filler context can cause models to miss details buried in the middle of long prompts.
Question 14: What is 'Self-Consistency' sampling in prompt engineering?
- A. Restricting the model to a single temperature value.
- B. Generating multiple reasoning paths (using high temperature) and voting on the most common final answer. β (correct answer)
- C. Compacting parameter tables.
- D. Clearing memory states.
Explanation: Self-consistency generates multiple outputs, choosing the consensus answer to improve reasoning stability.
Question 15: How does 'Role Prompting' affect model outputs?
- A. It changes database user roles.
- B. It instructs the model to act as a specific persona (e.g., Expert Developer), tuning the tone and depth of responses. β (correct answer)
- C. It encrypts the user's input.
- D. It routes requests dynamically.
Explanation: Role prompts establish contextual boundaries, steering the language patterns the model uses.
Question 16: Which prompt technique asks the model to review and correct its own first draft?
- A. Few-Shot
- B. Self-Refinement (or Self-Correction) β (correct answer)
- C. Zero-Shot
- D. Role Prompting
Explanation: Self-refinement loops prompt the model to find flaws in its previous output and rewrite it.
Question 17: What is the difference between 'In-Context Learning' and 'Fine-Tuning'?
- A. In-context learning updates model weights dynamically.
- B. In-context learning alters model behavior strictly via prompt contexts without changing weights, while Fine-Tuning updates weights. β (correct answer)
- C. Fine-tuning is faster and requires no data.
- D. There is no difference.
Explanation: In-context learning uses the active prompt context, leaving the underlying model frozen.
Question 18: What does the 'Delimiter' check refer to in prompt design?
- A. Calculating the total number of characters.
- B. Using specific characters (e.g. triple backticks ``` or HTML tags) to clearly separate instructions from input text blocks. β (correct answer)
- C. Formatting database index columns.
- D. Styling layout designs.
Explanation: Delimiters help models distinguish where instructions end and target variables begin.
Question 19: What is the purpose of 'Least-to-Most' prompting?
- A. Reducing the number of input tokens.
- B. Decomposing a complex problem into smaller sub-problems, solving them sequentially, and building up to the final answer. β (correct answer)
- C. Hashing prompt strings.
- D. Querying databases.
Explanation: Least-to-most prompting guides models to solve easy milestones first, using those states to address complex tasks.
Question 20: What is a 'Zero-Shot Prompt'?
- A. A prompt containing zero words.
- B. An instruction asking the model to perform a task without providing any example inputs or outputs. β (correct answer)
- C. A prompt that returns empty JSON.
- D. A server configuration parameter.
Explanation: Zero-shot relies entirely on the pre-trained generalized capabilities of the model.
Question 21: Which parameter value is best to generate predictable, consistent outputs like code or strict formats?
- A. Temperature = 1.5
- B. Temperature = 0.0 β (correct answer)
- C. Top-P = 1.0
- D. Max Tokens = 0
Explanation: Temperature 0.0 makes the model greedy, selecting the single most probable token repeatedly.
Question 22: How do you mitigate 'Prompt Leaking' in production applications?
- A. By deleting the database log files.
- B. By implementing strict system prompt rules instructing the model to never repeat its instructions and validating outputs. β (correct answer)
- C. By running the model on local servers only.
- D. By encrypting input strings.
Explanation: Output filters and defensive system prompting help shield instructions from user exposure.
Question 23: What does the system prompt establish?
- A. The local database connection parameters.
- B. The persistent rules, instructions, persona, and safety guidelines for the AI assistant. β (correct answer)
- C. The network routing paths.
- D. The compiler configurations.
Explanation: System prompts set the foundational behavior constraints for the model session.
Question 24: What does 'Few-Shot' prompting mean?
- A. Limiting the prompt to a few characters.
- B. Providing a few examples of inputs and target outputs to show the model the desired processing pattern. β (correct answer)
- C. Running the model on multiple CPUs.
- D. Restricting output token counts.
Explanation: Few-shot prompting demonstrates formatting, tone, and mapping styles implicitly.
Question 25: What is the core concept of the 'Tree of Thoughts' (ToT) prompting framework?
- A. Creating multiple folders for code storage.
- B. Maintaining a tree of self-generated thought branches, evaluating progress, and using search algorithms (like BFS/DFS) to find solutions. β (correct answer)
- C. Compiling model weights.
- D. Clearing system caches.
Explanation: ToT extends Chain of Thought by allowing search, backtracking, and multiple parallel reasoning branches.
Question 26: What is a 'Tokens-Per-Second' metric?
- A. The number of database index rows.
- B. A measure of the model's inference generation speed. β (correct answer)
- C. The frequency of API request calls.
- D. The compiler speed.
Explanation: Tokens-per-second measuring output speeds, crucial for evaluating user experience.
Question 27: What does the term 'Hallucination' refer to in LLMs?
- A. The model crashing due to memory.
- B. The generation of false or unverified facts presented as true statements. β (correct answer)
- C. The model outputting binary code.
- D. The GPU threads running in parallel loops.
Explanation: Hallucinations represent logical errors or invalid assertions created by statistical next-token generation.
Question 28: Why is 'Chain of Thought' prompting less effective on simple classification tasks?
- A. It consumes too much CPU memory.
- B. Simple tasks do not require step-by-step logic, meaning CoT only adds unnecessary token overhead and latency. β (correct answer)
- C. It throws syntax errors.
- D. It does not support JSON.
Explanation: CoT is designed for multi-step reasoning. Simple labeling is best handled directly.
Question 29: How does 'Prompt Templating' help developers?
- A. It speeds up model training times.
- B. It modularizes prompt creation by separating static instructions from dynamic user parameters. β (correct answer)
- C. It encrypts database keys.
- D. It routes requests.
Explanation: Templates let developers reuse instructions (e.g. 'Translate: {text}') programmatically.
Question 30: Which symbol is standard in Python f-strings to inject variables into prompt strings?
- A. %
- B. { } β (correct answer)
- C. < >
- D. [ ]
Explanation: Curly braces define placement variables inside Python f-strings.