Bird
Raised Fist0
Prompt Engineering / GenAIml~20 mins

Emerging trends (smaller models, edge AI) in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Edge AI Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why are smaller AI models important for edge devices?

Edge devices like smartphones and IoT sensors have limited power and memory. Why is using smaller AI models on these devices beneficial?

ASmaller models require constant internet connection to work properly on edge devices.
BSmaller models use less memory and power, making them faster and more efficient on edge devices.
CSmaller models always provide higher accuracy than larger models.
DSmaller models increase the need for cloud computing, reducing edge device independence.
Attempts:
2 left
💡 Hint

Think about the limitations of battery and storage on small devices.

Predict Output
intermediate
1:30remaining
Output of model size comparison code

Given the following Python code comparing two model sizes, what is the printed output?

Prompt Engineering / GenAI
model_a_size = 25000000  # 25 million parameters
model_b_size = 5000000   # 5 million parameters

if model_b_size < model_a_size:
    print(f"Model B is smaller by {model_a_size - model_b_size} parameters")
else:
    print("Model A is smaller or equal in size")
AModel B is smaller by 20000000 parameters
BModel A is smaller or equal in size
CModel B is smaller by 30000000 parameters
DSyntaxError due to missing colon
Attempts:
2 left
💡 Hint

Check which model size is bigger and subtract accordingly.

Model Choice
advanced
2:00remaining
Best model type for real-time edge AI

You want to deploy an AI model on a wearable device that must respond instantly and use very little battery. Which model type is best?

AA large transformer model with billions of parameters
BA cloud-based model accessed via internet
CA deep recurrent neural network with many layers
DA small convolutional neural network optimized for mobile
Attempts:
2 left
💡 Hint

Consider model size and power use for wearables.

Hyperparameter
advanced
2:00remaining
Which hyperparameter tuning helps reduce model size for edge AI?

To make a model smaller and faster for edge deployment, which hyperparameter adjustment is most effective?

AUsing a higher learning rate
BIncreasing the batch size during training
CApplying pruning to remove less important weights
DIncreasing the number of layers
Attempts:
2 left
💡 Hint

Think about removing parts of the model that are not needed.

Metrics
expert
2:30remaining
Evaluating edge AI model trade-offs

You have two edge AI models:
Model X: 90% accuracy, 50ms latency, 10MB size
Model Y: 85% accuracy, 20ms latency, 5MB size

Which metric best captures the trade-off between accuracy and latency for edge use?

AAccuracy divided by latency
BLatency alone
CAccuracy alone
DModel size alone
Attempts:
2 left
💡 Hint

Think about a metric that balances speed and correctness.

Practice

(1/5)
1. What is a key benefit of smaller AI models in devices like smartphones?
easy
A. They need large servers to work
B. They require constant internet connection
C. They run faster and use less memory
D. They always produce more accurate results

Solution

  1. Step 1: Understand smaller AI models

    Smaller AI models are designed to be lightweight, so they use less memory and compute power.
  2. Step 2: Identify benefits for smartphones

    Because phones have limited memory and processing power, smaller models help them run AI tasks faster and more efficiently.
  3. Final Answer:

    They run faster and use less memory -> Option C
  4. Quick Check:

    Smaller models = faster, less memory [OK]
Hint: Smaller models save memory and speed up devices [OK]
Common Mistakes:
  • Thinking smaller models need big servers
  • Assuming smaller models require internet
  • Believing smaller models always improve accuracy
2. Which code snippet correctly shows a simple way to run AI on an edge device?
easy
A. model = download_model('cloud_model') result = model.predict_online(input_data)
B. model = load_model('big_model.h5') result = model.train(input_data)
C. model = load_model('small_model.tflite') result = model.upload(input_data)
D. model = load_model('small_model.tflite') result = model.predict(input_data)

Solution

  1. Step 1: Identify edge AI code

    Edge AI runs AI models locally, so loading a small model like 'small_model.tflite' fits this.
  2. Step 2: Check correct method usage

    Using predict runs inference, which is typical for edge AI. Training or uploading is not common on edge devices.
  3. Final Answer:

    model = load_model('small_model.tflite') result = model.predict(input_data) -> Option D
  4. Quick Check:

    Load small model + predict locally = edge AI [OK]
Hint: Edge AI loads small models and predicts locally [OK]
Common Mistakes:
  • Using training instead of prediction on edge
  • Downloading models from cloud during inference
  • Uploading data instead of predicting locally
3. Given this Python code simulating edge AI inference, what is the printed output?
class SmallModel:
    def predict(self, x):
        return x * 2

model = SmallModel()
result = model.predict(5)
print(result)
medium
A. 10
B. 5
C. 25
D. Error

Solution

  1. Step 1: Understand the predict method

    The method multiplies input x by 2 and returns it.
  2. Step 2: Calculate the output for input 5

    5 * 2 = 10, so result is 10.
  3. Final Answer:

    10 -> Option A
  4. Quick Check:

    5 times 2 equals 10 [OK]
Hint: Multiply input by 2 as per predict method [OK]
Common Mistakes:
  • Confusing multiplication with addition
  • Expecting input as output
  • Assuming code causes error
4. This code tries to run AI on an edge device but has an error. What is the problem?
input_data = [1, 2, 3]
model = load_model('small_model.tflite')
result = model.train(input_data)
print(result)
medium
A. The model file name is incorrect
B. Edge devices usually do not train models, only predict
C. The print statement is missing parentheses
D. The input_data variable is not defined

Solution

  1. Step 1: Understand edge AI capabilities

    Edge AI devices typically run inference (predict), not training, because training needs more resources.
  2. Step 2: Identify incorrect method usage

    Calling train on the model is incorrect for edge AI; it should be predict.
  3. Final Answer:

    Edge devices usually do not train models, only predict -> Option B
  4. Quick Check:

    Edge AI = predict, not train [OK]
Hint: Edge AI predicts, does not train models [OK]
Common Mistakes:
  • Thinking edge devices can train models
  • Assuming file name causes error
  • Ignoring method misuse
5. You want to build a voice assistant that works offline on a smartwatch. Which approach best fits this edge AI trend?
hard
A. Use a small AI model running locally on the watch
B. Use no AI and only pre-recorded responses
C. Stream audio to a server for processing
D. Use a large cloud AI model accessed via internet

Solution

  1. Step 1: Understand offline edge AI needs

    Offline means no internet, so AI must run locally on the device.
  2. Step 2: Choose model size for smartwatch

    Smartwatches have limited memory and power, so a small AI model is best to run locally.
  3. Final Answer:

    Use a small AI model running locally on the watch -> Option A
  4. Quick Check:

    Offline + smartwatch = small local model [OK]
Hint: Offline device needs small local AI model [OK]
Common Mistakes:
  • Choosing cloud models needing internet
  • Streaming audio defeats offline goal
  • Ignoring device memory limits