Databricks Generative AI Engineer Associate Question 74
Select 3You are tasked with fine-tuning a generative AI model designed to generate Python code snippets based on natural language descriptions. Which of the following prompt/response pairs align with the task the model is designed to perform?
- A
Prompt: 'Generate a Python function to calculate the factorial of a number.' Response: 'def factorial(n):\n if n == 0: return 1\n else: return n * factorial(n-1)'
- B
Prompt: 'What is the capital of France?' Response: 'The capital of France is Paris.'
- C
Prompt: 'Generate a Python script to read a CSV file.' Response: 'import pandas as pd\ndata = pd.read_csv("file.csv")\nprint(data.head())'
- D
Prompt: 'Explain the concept of recursion with examples.' Response: 'Recursion is a method of solving problems where a function calls itself. For example, the factorial function uses recursion.'
- E
Prompt: 'Create a Python class for a basic calculator.' Response: 'class Calculator:\n def add(self, a, b): return a + b\n def subtract(self, a, b): return a - b'
Show answer and explanation
Correct answers: A, C, E
Explanation
The task of the model is to generate Python code snippets based on natural language descriptions. Prompt/response pairs that involve generating Python code (like creating a function, script, or class) align with the task, while those focusing on factual answers or conceptual explanations do not.
- A. Correct.
This prompt/response pair aligns with the model's task because it involves generating Python code based on a natural language description.
- B. Incorrect.
This does not align with the model's task as it involves factual question-answering, which is outside the scope of generating Python code.
- C. Correct.
This prompt/response pair aligns with the model's task because it involves generating Python code to perform a specific function as requested.
- D. Incorrect.
This does not align with the model's task as it involves explaining a programming concept rather than generating Python code.
- E. Correct.
This prompt/response pair aligns with the model's task because it involves generating Python code for a specific use case (a calculator class).