Bird
Raised Fist0
Prompt Engineering / GenAIml~10 mins

Model selection (GPT-4, GPT-3.5) in Prompt Engineering / GenAI - Interactive Code Practice

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
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select the GPT-4 model for generating text.

Prompt Engineering / GenAI
model = "[1]"
Drag options to blanks, or click blank then click option'
Agpt-3.5-turbo
Bcurie
Cgpt-4
Ddavinci
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'gpt-3.5-turbo' instead of 'gpt-4'.
Using older model names like 'davinci' or 'curie'.
2fill in blank
medium

Complete the code to set the temperature parameter for more creative responses.

Prompt Engineering / GenAI
response = openai.ChatCompletion.create(model="gpt-4", temperature=[1], messages=messages)
Drag options to blanks, or click blank then click option'
A0.7
B0.0
C1.5
D-0.5
Attempts:
3 left
💡 Hint
Common Mistakes
Using a temperature like 1.5, which produces overly random output.
Setting temperature to 0.0, which makes output very deterministic.
3fill in blank
hard

Fix the error in the code to correctly select GPT-3.5 model.

Prompt Engineering / GenAI
model_name = "[1]"
Drag options to blanks, or click blank then click option'
Agpt-4
Btext-davinci-003
Cgpt-3
Dgpt-3.5-turbo
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gpt-4' instead of GPT-3.5.
Using older names like 'text-davinci-003'.
4fill in blank
hard

Fill both blanks to create a dictionary with model and max tokens for GPT-4.

Prompt Engineering / GenAI
config = {"model": "[1]", "max_tokens": [2]
Drag options to blanks, or click blank then click option'
Agpt-4
Bgpt-3.5-turbo
C8192
D4096
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPT-3.5 model name with GPT-4 max tokens.
Setting max tokens too low for GPT-4.
5fill in blank
hard

Fill all three blanks to create a request with GPT-3.5, temperature 0.5, and max tokens 4096.

Prompt Engineering / GenAI
response = openai.ChatCompletion.create(model="[1]", temperature=[2], max_tokens=[3], messages=messages)
Drag options to blanks, or click blank then click option'
Agpt-4
B0.5
C4096
Dgpt-3.5-turbo
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPT-4 model name instead of GPT-3.5.
Setting temperature too high or too low.
Using max tokens not supported by GPT-3.5.

Practice

(1/5)
1. Which model should you choose if you need detailed and complex text generation?
easy
A. GPT-3.5
B. Both are equally detailed
C. GPT-4
D. Neither, use a smaller model

Solution

  1. Step 1: Understand model capabilities

    GPT-4 is designed for more complex and detailed tasks compared to GPT-3.5.
  2. Step 2: Match task complexity to model

    For detailed and complex text generation, GPT-4 is the better choice.
  3. Final Answer:

    GPT-4 -> Option C
  4. Quick Check:

    Complex tasks = GPT-4 [OK]
Hint: Choose GPT-4 for complexity, GPT-3.5 for speed [OK]
Common Mistakes:
  • Choosing GPT-3.5 for complex tasks
  • Thinking both models have same detail level
2. Which of the following is the correct way to specify GPT-3.5 in an API call?
easy
A. "model": "gpt-3.5-turbo"
B. "model": "gpt-3"
C. "model": "gpt-4"
D. "model": "gpt-5"

Solution

  1. Step 1: Recall model naming conventions

    The GPT-3.5 model is named "gpt-3.5-turbo" in API calls.
  2. Step 2: Identify correct option

    "model": "gpt-3.5-turbo" matches the exact model name for GPT-3.5.
  3. Final Answer:

    "model": "gpt-3.5-turbo" -> Option A
  4. Quick Check:

    Correct model name = "model": "gpt-3.5-turbo" [OK]
Hint: Use exact model name string in API call [OK]
Common Mistakes:
  • Using "gpt-3" instead of "gpt-3.5-turbo"
  • Confusing GPT-4 name with GPT-3.5
3. Given this code snippet calling the OpenAI API, which model will produce faster responses but possibly less detailed output?
response = openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[{"role": "user", "content": "Explain photosynthesis."}]
)
medium
A. GPT-3.5, faster but less detailed
B. GPT-4, slower but more detailed
C. GPT-4, faster and more detailed
D. GPT-3.5, slower but more detailed

Solution

  1. Step 1: Identify the model used in code

    The code uses "gpt-3.5-turbo" as the model parameter.
  2. Step 2: Recall model speed and detail tradeoff

    GPT-3.5 is faster but less detailed compared to GPT-4.
  3. Final Answer:

    GPT-3.5, faster but less detailed -> Option A
  4. Quick Check:

    Model in code = GPT-3.5 [OK]
Hint: Check model name string to know speed/detail tradeoff [OK]
Common Mistakes:
  • Assuming GPT-3.5 is slower
  • Confusing model names in code snippet
4. You wrote this API call but get an error:
response = openai.ChatCompletion.create(
  model="gpt-3.5",
  messages=[{"role": "user", "content": "Tell me a joke."}]
)
What is the likely problem?
medium
A. Messages list is missing a system role
B. Model name is incomplete, should be "gpt-3.5-turbo"
C. API key is missing
D. The model "gpt-3.5" does not exist

Solution

  1. Step 1: Check model name correctness

    The model name "gpt-3.5" is incomplete; the correct full name is "gpt-3.5-turbo".
  2. Step 2: Understand error cause

    Using an incomplete model name causes the API to reject the call.
  3. Final Answer:

    Model name is incomplete, should be "gpt-3.5-turbo" -> Option B
  4. Quick Check:

    Model name must be exact [OK]
Hint: Use full model name string to avoid errors [OK]
Common Mistakes:
  • Using partial model names
  • Assuming system role is mandatory
  • Ignoring API key errors
5. You want to build a chatbot that answers customer questions quickly and cheaply but can switch to detailed answers when needed. How should you select models in your code?
hard
A. Always use GPT-4 for all answers
B. Use GPT-4 only, it is always more accurate
C. Use GPT-3.5 only, it is always faster and cheaper
D. Use GPT-3.5 for quick replies, switch to GPT-4 for detailed ones

Solution

  1. Step 1: Understand tradeoffs between GPT-3.5 and GPT-4

    GPT-3.5 is faster and cheaper but less detailed; GPT-4 is slower and costlier but more detailed.
  2. Step 2: Match chatbot needs to model selection

    Use GPT-3.5 for quick, cheap answers and switch to GPT-4 when detailed responses are needed.
  3. Final Answer:

    Use GPT-3.5 for quick replies, switch to GPT-4 for detailed ones -> Option D
  4. Quick Check:

    Balance speed and detail with model switching [OK]
Hint: Switch models based on answer detail needed [OK]
Common Mistakes:
  • Using only one model for all tasks
  • Ignoring cost and speed tradeoffs