Bird
0
0

Given the following code snippet, what will be the length of the first two chunks?

medium📝 component behavior Q4 of 15
LangChain - Text Splitting
Given the following code snippet, what will be the length of the first two chunks?
splitter = RecursiveCharacterTextSplitter(chunk_size=50, chunk_overlap=10, separators=[" "])
text = 'a' * 100
chunks = splitter.split_text(text)
first_chunk = chunks[0]
second_chunk = chunks[1]
ABoth chunks length 60
BFirst chunk length 40, second chunk length 50
CFirst chunk length 50, second chunk length 50
DFirst chunk length 50, second chunk length 40
Step-by-Step Solution
Solution:
  1. Step 1: Understand chunk size and overlap effect

    Each chunk is 50 characters long. The second chunk starts 40 characters after the first chunk start (50 - 10 overlap).
  2. Step 2: Calculate chunk lengths

    Both chunks have length 50 because chunk_size defines chunk length; overlap only affects start position of next chunk.
  3. Final Answer:

    First chunk length 50, second chunk length 50 -> Option C
  4. Quick Check:

    Chunk length = chunk_size = 50 [OK]
Quick Trick: Chunk length equals chunk_size, overlap shifts next chunk start [OK]
Common Mistakes:
  • Confusing overlap as reducing chunk length
  • Assuming overlap adds to chunk length
  • Ignoring chunk_size parameter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes