Showing posts with label Interview Preparation. Show all posts
Showing posts with label Interview Preparation. Show all posts

Sunday, June 29, 2025

30 Interview Questions on AI Engineering (from the chapter "Introduction to Building AI Applications with Foundation Models")

To See All Interview Preparation Articles: Index For Interviews Preparation

Generate 30 questions (10 easy, 10 medium, 10 complex) along with answers from this PDF

Here are 30 questions (10 Easy, 10 Medium, 10 Complex) based on the provided PDF content, along with their answers and page references:


Easy Questions

  1. What term describes AI models like GPT-4 and Gemini?

    • Answer: Foundation Models.

    • Page: 9

  2. What enables language models to scale into LLMs?

    • Answer: Self-supervision.

    • Page: 6

  3. What are the two main types of language models?

    • Answer: Masked language models and autoregressive language models.

    • Page: 4

  4. What is the basic unit of a language model?

    • Answer: Token.

    • Page: 3

  5. Name one common AI engineering technique for adapting models.

    • Answer: Prompt engineering, RAG, or finetuning.

    • Page: 11

  6. What is the most popular AI use case according to surveys?

    • Answer: Coding.

    • Page: 20

  7. What does "human-in-the-loop" mean?

    • Answer: Involving humans in AI decision-making processes.

    • Page: 31

  8. What metric measures the time to generate the first token?

    • Answer: TTFT (Time to First Token).

    • Page: 33

  9. Which company launched the code-completion tool GitHub Copilot?

    • Answer: GitHub (owned by Microsoft).

    • Page: 20

  10. What does LMM stand for?

    • Answer: Large Multimodal Model.

    • Page: 9


Medium Questions

  1. Why do language models use tokens instead of words or characters?

    • Answer: Tokens reduce vocabulary size, handle unknown words, and capture meaningful components (e.g., "cook" + "ing").

    • Page: 4

  2. How does self-supervision overcome data labeling bottlenecks?

    • Answer: It infers labels from input data (e.g., predicting next tokens in text), eliminating manual labeling costs.

    • Page: 6–7

  3. What distinguishes foundation models from traditional task-specific models?

    • Answer: Foundation models are general-purpose, multimodal, and adaptable to diverse tasks.

    • Page: 10

  4. What are the three factors enabling AI engineering's growth?

    • Answer: General-purpose AI capabilities, increased AI investments, and low entry barriers.

    • Page: 12–14

  5. How did the MIT study (2023) show ChatGPT impacted writing tasks?

    • Answer: Reduced time by 40%, increased output quality by 18%, and narrowed skill gaps between workers.

    • Page: 23

  6. What is the "Crawl-Walk-Run" framework for AI automation?

    • Answer:

      • Crawl: Human involvement mandatory.

      • Walk: AI interacts with internal employees.

      • Run: AI interacts directly with external users.

    • Page: 31

  7. Why are internal-facing AI applications (e.g., knowledge management) deployed faster than external-facing ones?

    • Answer: Lower risks (data privacy, compliance, failures) while building expertise.

    • Page: 19

  8. What challenge does AI's open-ended output pose for evaluation?

    • Answer: Lack of predefined ground truths makes measuring correctness difficult (e.g., for chatbots).

    • Page: 44

  9. How did prompt engineering affect Gemini's MMLU benchmark performance?

    • Answer: Using CoT@32 (32 examples) instead of 5-shot boosted Gemini Ultra from 83.7% to 90.04%.

    • Page: 45

  10. What are the three competitive advantages in AI startups?

    • Answer: Technology, data, and distribution.

    • Page: 32


Complex Questions

  1. Why do larger models require more training data?

    • Answer: Larger models have higher capacity to learn; more data maximizes performance (not efficiency).

    • Page: 8

  2. Explain how AI engineering workflows differ from traditional ML engineering.

    • Answer:

      • ML Engineering: Data → Model → Product.

      • AI Engineering: Product → Data → Model (due to pre-trained models enabling rapid iteration).

    • Page: 47 (Figure 1-16)

  3. What ethical concern arises from AI-generated SEO content farms?

    • Answer: Proliferation of low-quality, automated content risks degrading trust in online information.

    • Page: 24

  4. How did Goldman Sachs Research quantify AI investment growth by 2025?

    • Answer: $100B in the US and $200B globally.

    • Page: 13

  5. What inference optimization challenges exist for autoregressive models?

    • Answer: Sequential token generation causes high latency (e.g., 100 tokens take ~1 second at 10ms/token).

    • Page: 43

  6. Why might GPU vendor restrictions pose a "fatal" risk for AI products?

    • Answer: Bans on GPU sales (e.g., due to regulations) can cripple compute-dependent applications overnight.

    • Page: 35

  7. How does the "data flywheel" create a competitive moat for AI startups?

    • Answer: Early market entry gathers usage data → insights improve products → attracts more users → reinforces data advantage.

    • Page: 32 (Footnote 21)

  8. Contrast pre-training, finetuning, and post-training.

    • Answer:

      • Pre-training: Training from scratch (random weights).

      • Finetuning: Adapting a pre-trained model (application-level).

      • Post-training: Further training by model developers (e.g., instruction-tuning).

    • Page: 41–42

  9. What are the three layers of the AI engineering stack?

    • Answer:

      1. Application development (prompts, interfaces).

      2. Model development (training, datasets, optimization).

      3. Infrastructure (serving, compute, monitoring).

    • Page: 37

  10. How did the 2023 Eloundou et al. study measure "AI exposure" in occupations?

    • Answer: % of tasks where AI reduces completion time by ≥50%. Fully exposed jobs included mathematicians, tax preparers, and web designers.

    • Page: 17


These questions and answers comprehensively cover key concepts, use cases, and technical nuances from Chapter 1 of the provided text.

Questions generated using DeepSeek Tags: Agentic AI,Interview Preparation,Generative AI,Artificial Intelligence,Large Language Models,

Thursday, June 19, 2025

Interview Questions on "Arrays" - Ch 2 - Fluent Python

All Posts on Python

Interview Questions from "Fluent Python" Chapter 2: Sequences

Easy Questions

  1. What are the two main categories of sequences based on mutability?

  2. How do container sequences differ from flat sequences?

  3. What is the key advantage of list comprehensions over map/filter?

  4. How do you prevent list comprehensions from leaking variables (Python 2 vs. Python 3)?

  5. What is the purpose of collections.namedtuple?

  6. How does tuple unpacking work in Python?

  7. What does the * operator do in tuple unpacking (e.g., a, *rest = [1, 2, 3])?

  8. Why do Python slices exclude the last item (e.g., my_list[0:3])?

  9. How do you reverse a sequence using slicing?

  10. What is the difference between list.sort() and sorted()?


Medium Questions

  1. Explain how generator expressions save memory compared to list comprehensions.

  2. How would you use a list comprehension to generate a Cartesian product?

  3. When should you use bisect instead of the in operator for membership tests?

  4. How does bisect.insort maintain a sorted sequence efficiently?

  5. Why might array.array be preferable to list for numerical data?

  6. What is the purpose of memoryview in handling large datasets?

  7. How does deque.rotate() work, and when would you use it?

  8. What happens when you assign to a slice (e.g., my_list[2:5] = [20, 30])?

  9. Why does my_list = [[]] * 3 create a list with shared references?

  10. How does the key parameter in sorted() enable case-insensitive sorting?


Complex Questions

  1. Explain the behavior of a += b for mutable vs. immutable sequences.

  2. Why does t[2] += [50, 60] raise a TypeError but still modify a tuple’s mutable element?

  3. How does NumPy’s ndarray improve performance for numerical operations?

  4. Discuss the performance trade-offs of using deque vs. list for FIFO/LIFO operations.

  5. How can memoryview.cast() manipulate binary data without copying bytes?

  6. When would you use array.tofile() instead of pickle for saving numerical data?

  7. Explain how the key parameter in sorting functions leverages stability (e.g., Timsort).

  8. How does bisect support efficient table lookups (e.g., converting scores to grades)?

  9. Why is deque thread-safe for append/pop operations?

  10. Compare the performance of array.fromfile() vs. reading floats from a text file.


These questions cover core sequence operations, performance optimizations, and practical applications from the chapter, suitable for evaluating a candidate's depth of understanding.

Wednesday, June 18, 2025

What is the Python Data Model?

All Questions From This Chapter

The Python Data Model is the framework that defines how Python objects behave and interact with each other. It’s the foundation for all built-in behavior in Python, such as arithmetic operations, attribute access, iteration, string representation, and more.

🧩 Key Idea:

The Python Data Model is made up of special methods (a.k.a. "dunder" methods — methods with double underscores like __len__, __getitem__, __str__, etc.) that let you hook into the language’s syntax and built-in functions.


🔍 Examples of Special Methods and What They Enable:

MethodTriggered byUse Case
__len__len(obj)Make object countable
__getitem__obj[index]Indexing, slicing support
__iter__for item in objMake object iterable
__str__str(obj) or print(obj)Human-readable string representation
__repr__repr(obj)Debug-friendly object display
__call__obj()Make object behave like a function
__add__obj1 + obj2Operator overloading
__bool__if obj:Truthiness of an object

🎯 Why It Matters:

  • Lets you create custom classes that integrate seamlessly with Python’s built-in operations.

  • Powers frameworks like Django, Pandas, NumPy, and more.

  • Enables writing Pythonic, intuitive, and idiomatic code.


📘 Example:

python
class Word: def __init__(self, text): self.text = text def __len__(self): return len(self.text) def __str__(self): return f"Word: {self.text}" word = Word("Python") print(len(word)) # → 6 print(str(word)) # → Word: Python

📚 Summary:

The Python Data Model is what allows Python to be flexible, expressive, and powerful. It’s the secret sauce behind how user-defined classes can behave like built-in types.

Want to dive deeper into this? Luciano Ramalho's "Fluent Python" is an excellent book focused on this very concept.

Tags: Technology,Python,Interview Preparation,

What built-in function calls __abs__?

All Questions From This Chapter

The built-in function abs() in Python calls the __abs__ dunder method on an object.


✅ Example:

python
class Temperature: def __init__(self, value): self.value = value def __abs__(self): return abs(self.value) temp = Temperature(-40) print(abs(temp)) # Output: 40

🔍 What’s Happening:

When you write abs(temp), Python internally calls:

python
temp.__abs__()

This allows you to define custom behavior for abs() on your own classes.


🧠 Summary:

  • abs(obj) → Calls obj.__abs__()

  • You must implement __abs__ if you want your custom class to support abs()

This is part of Python’s data model that allows operator/function overloading.

Tags: Technology,Python,Interview Preparation,

What are "dunder" methods? Give an example.

All Questions From This Chapter

"Dunder" methods (short for "double underscore" methods) are special methods in Python that begin and end with double underscores (__), like __init__, __str__, and __len__. They’re also known as magic methods or special methods.

These methods are used to:

  • Customize the behavior of built-in operations

  • Enable operator overloading

  • Integrate your class with Python's core language features (like iteration, context managers, etc.)


Example:

python
class Book: def __init__(self, title): self.title = title def __str__(self): return f"Book: {self.title}" book = Book("Fluent Python") print(book) # Output: Book: Fluent Python
  • __init__: Initializes the object (like a constructor).

  • __str__: Defines what str(obj) or print(obj) returns.


🧠 Common Dunder Methods:

MethodPurpose
__init__Constructor (called on object creation)
__str__String representation (print(obj))
__repr__Debug representation (repr(obj))
__len__Length (len(obj))
__getitem__Indexing (obj[i])
__iter__Makes an object iterable
__eq__Equality (==)

Dunder methods let your objects behave like built-in types and integrate seamlessly with Python’s syntax and idioms.

Tags: Technology,Python,Interview Preparation,

What happens if you don’t implement __bool__ in a class?

All Questions From This Chapter

If you don’t implement __bool__ in a Python class, Python falls back to another method to determine the truthiness of your object.

🔁 Fallback Behavior:

  1. If __bool__ is not defined, Python checks for __len__.

  2. If __len__ is defined:

    • if obj: will evaluate to False if len(obj) == 0.

    • Otherwise, it evaluates to True.

  3. If neither __bool__ nor __len__ is defined, the object is considered truthy by default (i.e., True).


🔍 Example Without __bool__:

python
class Empty: def __len__(self): return 0 e = Empty() print(bool(e)) # False, because __len__ returns 0

🧱 Example With Neither:

python
class Thing: pass t = Thing() print(bool(t)) # True, because no __bool__ or __len__

✅ Summary

You define…bool(obj) is…
__bool__Uses the returned Boolean value
__len__, no __bool__False if len(obj) == 0, True otherwise
NeitherAlways True

🧠 Tip: Define __bool__ if you want explicit control over an object’s truthiness.

Tags: Technology,Python,Interview Preparation,