

























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























































































Question 1. Which information‑theoretic metric quantifies the average number of bits needed to encode a probability distribution? A) Cross‑entropy B) Perplexity C) Entropy D) KL‑divergence Answer: C Explanation: Entropy measures the expected number of bits required to represent a random variable drawn from a distribution. Question 2. In a generative language model, the loss function most commonly used during training is: A) Hinge loss B) Mean squared error C) Cross‑entropy loss D) Triplet loss Answer: C Explanation: Cross‑entropy loss measures the difference between the predicted token distribution and the true distribution, guiding the model to assign higher probability to correct tokens. Question 3. Which of the following best describes the difference between generative and discriminative models? A) Generative models predict class labels, discriminative models generate data. B) Generative models learn joint probability p(x, y), discriminative models learn conditional probability p(y|x). C) Generative models require less data than discriminative models.
D) Discriminative models cannot be used for text generation. Answer: B Explanation: Generative models model the joint distribution, enabling data synthesis; discriminative models focus on directly modeling the conditional probability for classification. Question 4. The Kullback‑Leibler (KL) divergence between the true distribution (P) and the model distribution (Q) is minimized during training to: A) Increase model entropy B) Reduce the difference between (P) and (Q) C) Maximize perplexity D) Ensure model over‑fitting Answer: B Explanation: KL divergence measures how one probability distribution diverges from a reference distribution; minimizing it aligns the model’s predictions with the true distribution. Question 5. In the context of neural networks, which activation function is most commonly used in transformer architectures? A) Sigmoid B) Tanh C) ReLU D) GELU Answer: D Explanation: GELU (Gaussian Error Linear Unit) provides smoother gradients and has become the default activation in many transformer‑based models, including BERT and GPT. Question 6. Which loss function is specifically designed for variational autoencoders (VAEs)?
Question 9. Which component of the transformer architecture allows the model to weigh the importance of each token relative to others? A) Positional encoding B) Feed‑forward network C) Self‑attention mechanism D) Layer normalization Answer: C Explanation: Self‑attention computes attention scores between all token pairs, enabling the model to focus on relevant parts of the input when producing each output token. Question 10. Decoder‑only transformer models, such as GPT‑4, differ from encoder‑only models, such as BERT, in that they: A) Cannot handle long sequences B) Are trained with masked language modeling C) Generate text autoregressively D) Do not use positional embeddings Answer: C Explanation: Decoder‑only models predict the next token given previous ones, enabling generation; encoder‑only models produce contextual embeddings for downstream tasks. Question 11. In software code generation, which specialized model is explicitly trained on large corpora of source code? A) BERT B) Codex C) ResNet D) VGG Answer: B
Explanation: Codex, built on GPT‑3, is fine‑tuned on billions of lines of code, making it proficient at generating and completing programming language snippets. Question 12. When using a VAE for anomaly detection in software logs, the anomaly score is typically derived from: A) The discriminator’s confidence B) Reconstruction error in the latent space C) The number of attention heads used D) The size of the output vocabulary Answer: B Explanation: VAEs learn to reconstruct normal data; high reconstruction error indicates that a sample deviates from the learned distribution, flagging it as anomalous. Question 13. Which of the following best describes “perplexity” as a metric for language models? A) The inverse of accuracy B) The exponentiation of cross‑entropy loss C) The average KL‑divergence across tokens D) The total number of parameters in the model Answer: B Explanation: Perplexity = 2^(cross‑entropy) (or exp(cross‑entropy) depending on base); lower perplexity indicates better predictive performance. Question 14. In prompt engineering, a “few‑shot” prompt provides: A) No examples, only the task description B) One example of input‑output pair C) Multiple examples to illustrate the pattern
A) Factory B) Strategy C) Singleton D) Observer Answer: C Explanation: The Singleton pattern restricts a class to a single instance, making it ideal for shared resources like a connection pool. Question 18. In AI‑assisted database schema design, an LLM suggests normalizing a table that contains repeating groups. This recommendation aligns with which normal form? A) First Normal Form (1NF) B) Second Normal Form (2NF) C) Third Normal Form (3NF) D) Boyce‑Codd Normal Form (BCNF) Answer: A Explanation: 1NF eliminates repeating groups and ensures atomic values; normalizing such a table satisfies 1NF. Question 19. Which of the following is a typical use case for AI‑generated unit tests? A) Replacing integration testing entirely B) Automatically covering edge cases that developers may overlook C) Reducing code coverage to zero D) Generating UI mockups instead of code Answer: B Explanation: AI can analyze code paths and generate tests targeting edge conditions, improving test thoroughness.
Question 20. When an AI agent suggests a security patch for a buffer‑overflow vulnerability, the “human‑in‑the‑loop” principle dictates that: A) The patch must be applied automatically without review B) A security engineer should validate and approve the patch before deployment C) The model should be retrained on the vulnerability data immediately D) The patch should be ignored because AI cannot be trusted Answer: B Explanation: Human‑in‑the‑loop ensures that critical security changes are reviewed by qualified personnel before production use. Question 21. Which metric would you monitor to detect that a code‑generation model is starting to “hallucinate” non‑existent APIs? A) Decrease in training loss B) Increase in token‑level perplexity on validation data containing known APIs C) Higher BLEU scores on code translation tasks D) Lower KL‑divergence between model and prior Answer: B Explanation: Rising perplexity on validation data that includes real APIs indicates the model is less confident, often manifesting as hallucinations. Question 22. In the EU AI Act, which risk category would an AI system that autonomously writes production‑ready code fall under? A) Minimal risk B) Limited risk C) High risk D) Unacceptable risk
C) Setting temperature to 1.0 for maximum randomness D) Disabling token‑level caching Answer: B Explanation: Templates provide a fixed structure, and the AI only generates variable parts, preventing unnecessary duplication. Question 26. When fine‑tuning a code‑generation model on a private repository, which strategy best mitigates the risk of overfitting? A) Training for as many epochs as possible B) Using a very small learning rate and early stopping based on validation loss C) Removing all comments from the training data D) Increasing the batch size to the maximum GPU memory Answer: B Explanation: A low learning rate combined with early stopping helps the model generalize without memorizing the exact training samples. Question 27. In the context of AI‑augmented pair programming, “role‑based prompting” refers to: A) Assigning the model the role of “tester” while the human writes code B) Switching the model between “assistant” (suggestions) and “coder” (full implementations) modes via prompt context C) Using separate models for front‑end and back‑end code D) Training the model on role‑specific datasets only Answer: B Explanation: Role‑based prompting tailors the model’s behavior by specifying its current responsibility, such as offering hints versus producing complete code blocks.
Question 28. Which of the following is a primary advantage of using a decoder‑only transformer for generating API client libraries from OpenAPI specifications? A) Ability to encode bidirectional context B) Direct autoregressive generation of source files in the correct order C) Built‑in support for graph‑structured data D) Automatic schema validation Answer: B Explanation: Decoder‑only models generate tokens sequentially, which aligns well with the need to produce ordered source code files from a specification. Question 29. A generative model outputs a piece of code that uses a deprecated library function. The most appropriate remediation step is: A) Retrain the model from scratch without any deprecated code in the dataset B) Prompt the model with a “replace deprecated function” instruction and regenerate C) Increase the temperature to 2.0 to force new outputs D) Accept the output; deprecated functions are harmless Answer: B Explanation: Providing a corrective instruction (e.g., “use the newer function”) guides the model to adjust its output without costly retraining. Question 30. Which of the following best describes “knowledge distillation” in the context of deploying generative AI for software development? A) Transferring knowledge from a large teacher model to a smaller student model to reduce latency B) Compressing source code into a binary format C) Converting Python code to JavaScript automatically D) Using a GAN to generate synthetic training data
B) One‑shot prompt: Provide an example of a bubble sort and ask for a quicksort implementation. C) Few‑shot prompt: Show two sorting algorithms and request a third distinct method. D) Chain‑of‑thought prompt: Ask the model to explain the algorithm before coding it. Answer: C Explanation: Few‑shot prompting with multiple examples clarifies the expectation for a novel algorithmic approach, reducing reliance on built‑in utilities. Question 34. Which of the following is a common security concern when using AI‑generated code in production? A) The model may intentionally insert backdoors. B) Generated code may lack proper input validation, leading to injection vulnerabilities. C) AI guarantees zero‑day exploits are eliminated. D) The code will always be fully optimized for performance. Answer: B Explanation: AI models often overlook security best practices, such as sanitizing inputs, which can introduce injection or other vulnerabilities. Question 35. In the context of AI‑driven testing, “mutation testing” can be automated by a generative model to: A) Generate new source files unrelated to the original code B) Introduce small syntactic changes (mutations) and verify if existing tests detect them C) Replace all variable names with random strings D) Remove all comments from the code base Answer: B Explanation: Mutation testing evaluates test suite effectiveness by creating altered versions of code; AI can automate the creation of these mutants.
Question 36. Which of the following best explains why temperature hyper‑parameter tuning is important when generating code snippets? A) Higher temperature always yields more correct code. B) Lower temperature reduces randomness, producing more deterministic and often syntactically correct code. C) Temperature controls the size of the generated file. D) Temperature determines the number of attention heads. Answer: B Explanation: Temperature scales the probability distribution; a low temperature (e.g., 0.2) makes the model favor high‑probability tokens, leading to more predictable code. Question 37. When an AI model suggests a design pattern for a microservice architecture, which pattern is most appropriate for handling asynchronous communication between services? A) Singleton B) Factory C) Observer (Publish‑Subscribe) D) Decorator Answer: C Explanation: The Observer or Publish‑Subscribe pattern decouples services and enables asynchronous message passing, suited for microservice communication. Question 38. Which of the following is a direct benefit of using a “semantic code search” powered by embeddings rather than keyword search? A) Faster execution speed B) Ability to retrieve code based on meaning, even if exact keywords differ C) Reduced memory consumption
A) Directly run the script on production B) Use a static analyzer to check for syntax errors and potential data loss C) Increase temperature to 1.5 to ensure variability D) Remove all comments to reduce size Answer: B Explanation: Static analysis can catch syntax issues, missing constraints, or destructive statements, ensuring safety before applying migrations. Question 42. Which of the following is a characteristic of “few‑shot prompting” that makes it especially useful for domain‑specific code generation? A) It eliminates the need for any examples. B) It allows the model to infer the desired pattern from a small number of domain‑specific examples. C) It always produces longer code snippets. D) It forces the model to ignore its pre‑trained knowledge. Answer: B Explanation: By providing a few representative examples, the model can adapt its generation to the specific style or conventions of the target domain. Question 43. In the context of AI‑generated UI mockups, a Conditional GAN would condition the generation on: A) Random noise only B) The desired screen resolution and component hierarchy C) The loss function of the discriminator D) The number of training epochs Answer: B
Explanation: Conditional GANs incorporate auxiliary information (e.g., layout constraints, resolution) to steer image generation toward required UI specifications. Question 44. Which of the following best defines “model collapse” in GAN training, particularly relevant when generating code snippets? A) The generator learns to produce a diverse set of outputs. B) The discriminator becomes too weak, allowing any output. C) The generator outputs the same (or limited) code fragment repeatedly, failing to capture diversity. D) Both models converge perfectly to the data distribution. Answer: C Explanation: Mode collapse occurs when the generator maps many inputs to a few outputs, reducing variety—a problem for code generation where diversity is essential. Question 45. When integrating a generative AI service into a CI/CD pipeline, which practice ensures that generated code does not violate licensing terms? A) Disable all linting checks. B) Run an automated license‑compliance scan on the generated files before merging. C) Use the highest possible temperature. D) Bypass code review for AI‑generated changes. Answer: B Explanation: License‑compliance tools can detect potential infringements, ensuring that AI‑produced code respects open‑source licenses. Question 46. In a transformer, the “feed‑forward network” (FFN) is applied: A) After each attention head, independently per token B) Only at the final layer of the model
Question 49. Which of the following best describes “prompt injection” as a security threat to AI‑assisted development tools? A) The model injects malicious code into the user’s repository. B) An attacker crafts input that manipulates the model’s subsequent behavior to produce unintended or harmful outputs. C) The model’s weights are overwritten by external data. D) The API key is leaked in the prompt. Answer: B Explanation: Prompt injection exploits the model’s sensitivity to input, causing it to follow malicious instructions embedded in the prompt. Question 50. When evaluating the fairness of an AI model that suggests UI color palettes, an appropriate metric would be: A) Perplexity on color token sequences B) Distribution parity across culturally diverse color preferences C) Number of tokens generated per second D) Model size in megabytes Answer: B Explanation: Fairness assessment should examine whether the model’s suggestions reflect a balanced representation of diverse cultural color norms. Question 51. Which of the following statements about “self‑supervised pre‑training” for code models is correct? A) It requires manually labeled bug data. B) The model learns by predicting masked tokens or next tokens from raw source code without explicit labels. C) It can only be performed on natural‑language corpora.
D) It eliminates the need for any downstream fine‑tuning. Answer: B Explanation: Self‑supervised learning leverages the structure of the data itself (e.g., masked token prediction) to learn representations, applicable to raw code. Question 52. In a multi‑modal AI system that generates both code and UI screenshots, the “shared latent space” concept enables: A) Independent training of each modality B) Transfer of semantic information between text/code and images, improving consistency across outputs C) Reduction of model parameters by half D) Automatic conversion of images to binary executables Answer: B Explanation: A shared latent representation aligns concepts across modalities, allowing the system to produce coherent code and corresponding UI visuals. Question 53. Which of the following is a primary reason to use “knowledge graphs” alongside generative models in software engineering? A) To replace the transformer architecture entirely B) To provide structured contextual information (e.g., API relationships) that can guide generation and reduce hallucinations C) To increase token count dramatically D) To enforce strict type checking at the hardware level Answer: B Explanation: Knowledge graphs encode relationships and constraints that can be consulted during generation, improving factual accuracy.