0
0
LangChainframework~10 mins

RecursiveCharacterTextSplitter 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 create a RecursiveCharacterTextSplitter with a chunk size of 100.

LangChain
from langchain.text_splitter import RecursiveCharacterTextSplitter
splitter = RecursiveCharacterTextSplitter(chunk_size=[1])
Drag options to blanks, or click blank then click option'
A100
B200
C50
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using a chunk size too small or too large for the example.
Forgetting to import RecursiveCharacterTextSplitter.
2fill in blank
medium

Complete the code to split the text variable using the splitter.

LangChain
texts = splitter.[1](text)
Drag options to blanks, or click blank then click option'
Ajoin
Bsplit_text
Cmerge
Dcombine
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods that do not exist on the splitter object.
Confusing splitting with joining or merging.
3fill in blank
hard

Fix the error in the code by completing the parameter to set the chunk overlap to 20.

LangChain
splitter = RecursiveCharacterTextSplitter(chunk_size=100, chunk_overlap=[1])
Drag options to blanks, or click blank then click option'
A30
B10
C20
D40
Attempts:
3 left
💡 Hint
Common Mistakes
Setting overlap larger than chunk size.
Using invalid parameter names.
4fill in blank
hard

Fill both blanks to create a splitter with chunk size 150 and chunk overlap 30.

LangChain
splitter = RecursiveCharacterTextSplitter(chunk_size=[1], chunk_overlap=[2])
Drag options to blanks, or click blank then click option'
A150
B100
C30
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping chunk size and overlap values.
Using values that are too close or equal.
5fill in blank
hard

Fill all three blanks to create a splitter with chunk size 120, chunk overlap 15, and separators set to newline and space.

LangChain
splitter = RecursiveCharacterTextSplitter(chunk_size=[1], chunk_overlap=[2], separators=[3])
Drag options to blanks, or click blank then click option'
A100
B15
C["\n", " "]
D120
Attempts:
3 left
💡 Hint
Common Mistakes
Using separators as a string instead of a list.
Mixing up chunk size and overlap values.