Databricks Generative AI Engineer Associate exam dumps

Databricks Generative AI Engineer Associate practice question 194 of 306

Databricks Certified Generative AI Engineer Associate. Free level, Databricks. Free question with the correct answer and a full explanation.

Databricks Generative AI Engineer Associate Question 194

Single answer

You are tasked with creating a simple chain in Databricks that consists of two steps. The first step prompts a user for input, and the second step generates a response using a pre-trained language model. Which code snippet best implements this functionality?

  1. A

    from langchain.chains import SimpleChain from langchain.prompts import PromptTemplate

    input_prompt = PromptTemplate(input_variables=['input'], template='Your input: {input}') chain = SimpleChain.from_prompts(input_prompt, None)

  2. B

    from langchain.chains import SimpleChain from langchain.prompts import PromptTemplate from langchain.llms import OpenAI

    input_prompt = PromptTemplate(input_variables=['input'], template='Your input: {input}') llm = OpenAI() chain = SimpleChain.from_prompts(input_prompt, llm)

  3. C

    from langchain.chains import SequentialChain from langchain.prompts import PromptTemplate from langchain.llms import OpenAI

    input_prompt = PromptTemplate(input_variables=['input'], template='Your input: {input}') llm = OpenAI() chain = SequentialChain.from_prompts(input_prompt, llm)

  4. D

    from langchain.chains import LLMChain from langchain.prompts import PromptTemplate from langchain.llms import OpenAI

    input_prompt = PromptTemplate(input_variables=['input'], template='Your input: {input}') llm = OpenAI() chain = LLMChain(prompt=input_prompt, llm=llm)

Show answer and explanation

Correct answer: D

Explanation

The LLMChain class in LangChain is specifically designed for creating simple chains that involve a prompt and a language model. It is the appropriate choice for implementing this two-step functionality. Other options either misuse classes or do not properly define the components needed for the chain.

  • A. Incorrect.

    This option incorrectly uses the SimpleChain class without providing a valid language model for the response generation step. The None value for the second step is not valid.

  • B. Incorrect.

    While this option correctly includes a prompt and a language model, the SimpleChain class is not the correct choice for chaining a prompt with an LLM.

  • C. Incorrect.

    This option uses SequentialChain instead of LLMChain. SequentialChain is designed for multiple chained steps with dependencies, which is unnecessary for this simple two-step chain.

  • D. Correct.

    This option correctly uses the LLMChain class, which is specifically designed for chains that include a prompt and an LLM. It correctly defines both the input prompt and the language model, making it the best choice for this task.

Timed practice exam

Take a Databricks Generative AI Engineer Associate practice test under exam conditions

45 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam