Challenge - 5 Problems
Recursive Splitter Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
How does RecursiveCharacterTextSplitter split text?
Given a long string input, how does RecursiveCharacterTextSplitter split the text when the chunk size is smaller than the input length?
LangChain
from langchain.text_splitter import RecursiveCharacterTextSplitter text = "This is a long text that needs to be split into smaller chunks for processing." splitter = RecursiveCharacterTextSplitter(chunk_size=20, chunk_overlap=5) chunks = splitter.split_text(text) print(chunks)
Attempts:
2 left
💡 Hint
Think about how the splitter uses chunk size and overlap to create smaller pieces.
✗ Incorrect
RecursiveCharacterTextSplitter splits the text into chunks of the specified size with overlap. It tries to split at natural boundaries recursively, resulting in chunks like option A.
📝 Syntax
intermediate1:30remaining
Identify the syntax error in RecursiveCharacterTextSplitter usage
Which option contains a syntax error when creating a RecursiveCharacterTextSplitter instance?
LangChain
from langchain.text_splitter import RecursiveCharacterTextSplitter splitter = RecursiveCharacterTextSplitter(chunk_size=100 chunk_overlap=20)
Attempts:
2 left
💡 Hint
Check the commas between arguments.
✗ Incorrect
Option D is missing a comma between chunk_size and chunk_overlap arguments, causing a syntax error.
❓ state_output
advanced2:00remaining
What is the number of chunks produced?
Using RecursiveCharacterTextSplitter with chunk_size=10 and chunk_overlap=2, how many chunks will be produced from the text "Hello world! This is LangChain."?
LangChain
from langchain.text_splitter import RecursiveCharacterTextSplitter text = "Hello world! This is LangChain." splitter = RecursiveCharacterTextSplitter(chunk_size=10, chunk_overlap=2) chunks = splitter.split_text(text) print(len(chunks))
Attempts:
2 left
💡 Hint
Consider chunk size and overlap to count chunks.
✗ Incorrect
The text length is 31 characters. With chunk size 10 and overlap 2, chunks start every 8 characters: positions 0,8,16,24. This results in 4 chunks.
🔧 Debug
advanced2:00remaining
Why does this RecursiveCharacterTextSplitter code raise an error?
What error does the following code raise and why?
from langchain.text_splitter import RecursiveCharacterTextSplitter
splitter = RecursiveCharacterTextSplitter(chunk_size=5, chunk_overlap=10)
chunks = splitter.split_text("Short text")
Attempts:
2 left
💡 Hint
Check the relationship between chunk_size and chunk_overlap.
✗ Incorrect
chunk_overlap must be less than chunk_size. Here chunk_overlap=10 is larger than chunk_size=5, causing a ValueError.
🧠 Conceptual
expert2:30remaining
How does RecursiveCharacterTextSplitter decide split points?
Which best describes how RecursiveCharacterTextSplitter chooses where to split text into chunks?
Attempts:
2 left
💡 Hint
Think about how the splitter tries to keep chunks readable and natural.
✗ Incorrect
RecursiveCharacterTextSplitter tries to split text at natural boundaries like newlines or spaces recursively, ensuring chunks do not exceed chunk_size and overlap is respected.