0
0
LangChainframework~10 mins

Overlap and chunk boundaries 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 set the chunk size for text splitting.

LangChain
text_splitter = RecursiveCharacterTextSplitter(chunk_size=[1], chunk_overlap=20)
Drag options to blanks, or click blank then click option'
A500
B50
C1000
D2000
Attempts:
3 left
💡 Hint
Common Mistakes
Using too small chunk size like 50 which creates too many chunks.
Setting chunk size larger than the text length.
2fill in blank
medium

Complete the code to set the chunk overlap for text splitting.

LangChain
text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=[1])
Drag options to blanks, or click blank then click option'
A0
B100
C50
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Setting overlap equal to chunk size, which causes full repetition.
Setting overlap to zero, losing context between chunks.
3fill in blank
hard

Fix the error in the code to correctly split text with overlap.

LangChain
chunks = text_splitter.split_text([1])
Drag options to blanks, or click blank then click option'
Achunks
Btext
Csplit_text
Dtext_splitter
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the splitter object instead of the text string.
Passing the chunks list which is the output, not input.
4fill in blank
hard

Fill both blanks to create a text splitter with chunk size 400 and overlap 100.

LangChain
text_splitter = RecursiveCharacterTextSplitter(chunk_size=[1], chunk_overlap=[2])
Drag options to blanks, or click blank then click option'
A400
B100
C200
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Setting overlap larger than chunk size.
Using very small chunk size causing many chunks.
5fill in blank
hard

Fill all three blanks to split text and print the number of chunks.

LangChain
text_splitter = RecursiveCharacterTextSplitter(chunk_size=[1], chunk_overlap=[2])
chunks = text_splitter.split_text([3])
print(len(chunks))
Drag options to blanks, or click blank then click option'
A600
B150
Ctext
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Passing wrong variable to split_text.
Setting overlap larger than chunk size.