0
0
LangChainframework~10 mins

Connecting to open-source models in LangChain - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the OpenAI model from LangChain.

LangChain
from langchain.llms import [1]
Drag options to blanks, or click blank then click option'
AGPT4All
BOpenAI
CHuggingFaceHub
DCohere
Attempts:
3 left
💡 Hint
Common Mistakes
Importing GPT4All instead of OpenAI
Using incorrect module path
2fill in blank
medium

Complete the code to create a GPT4All model instance with the model path.

LangChain
from langchain.llms import GPT4All
model = GPT4All(model=[1])
Drag options to blanks, or click blank then click option'
A'gpt4all-model.bin'
Bgpt4all-model.bin
C'openai'
D'gpt-3.5-turbo'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the model path
Using OpenAI model name instead of GPT4All model file
3fill in blank
hard

Fix the error in the code to load a HuggingFaceHub model with the repo_id.

LangChain
from langchain.llms import HuggingFaceHub
model = HuggingFaceHub(repo_id=[1])
Drag options to blanks, or click blank then click option'
Agpt2
B"gpt2"
C'gpt2'
Dgpt-3
Attempts:
3 left
💡 Hint
Common Mistakes
Passing repo_id without quotes causing syntax error
Using incorrect model name like gpt-3
4fill in blank
hard

Fill both blanks to create a GPT4All instance with streaming enabled and a callback.

LangChain
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
callbacks = [[1]()]
model = GPT4All(model='gpt4all-model.bin', streaming=[2], callbacks=callbacks)
Drag options to blanks, or click blank then click option'
AStreamingStdOutCallbackHandler
BTrue
CFalse
DStreamingCallback
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong callback class name
Setting streaming to False or missing it
5fill in blank
hard

Fill all three blanks to create a HuggingFaceHub model with a specific repo_id, task, and model_kwargs.

LangChain
model = HuggingFaceHub(repo_id=[1], task=[2], model_kwargs=[3])
Drag options to blanks, or click blank then click option'
A'google/flan-t5-small'
B'text2text-generation'
C{'temperature': 0.7}
D'gpt2'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong repo_id or task strings
Passing model_kwargs as a string instead of dictionary