0
0
Agentic AIml~10 mins

Document loading and chunking strategies in Agentic AI - Interactive Code Practice

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

Complete the code to load a document from a file path.

Agentic AI
loader = TextLoader('[1]')
docs = loader.load()
Drag options to blanks, or click blank then click option'
Aimage.png
Bdata.txt
Cdocument.pdf
Daudio.mp3
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-text file types like images or audio files.
Providing a file path that does not exist.
2fill in blank
medium

Complete the code to split documents into chunks of 1000 characters.

Agentic AI
text_splitter = CharacterTextSplitter(chunk_size=[1], chunk_overlap=0)
texts = text_splitter.split_documents(docs)
Drag options to blanks, or click blank then click option'
A50
B500
C1000
D2000
Attempts:
3 left
💡 Hint
Common Mistakes
Using too small chunk sizes causing too many chunks.
Using too large chunk sizes causing memory issues.
3fill in blank
hard

Fix the error in the code to correctly chunk documents with 20 characters overlap.

Agentic AI
text_splitter = CharacterTextSplitter(chunk_size=500, chunk_overlap=[1])
texts = text_splitter.split_documents(docs)
Drag options to blanks, or click blank then click option'
A100
B0
C10
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Setting overlap to zero loses context between chunks.
Setting overlap larger than chunk size causes errors.
4fill in blank
hard

Complete the code to create a dictionary of chunk lengths for chunks longer than 50 characters.

Agentic AI
chunk_lengths = {chunk.page_content: len(chunk.page_content) for chunk in texts if len(chunk.page_content) [1] 50}
Drag options to blanks, or click blank then click option'
A:
B>
C<
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of ':' in dictionary comprehension.
Using '<' instead of '>' in the condition.
5fill in blank
hard

Fill both blanks to create a list of chunk summaries using a summarizer function.

Agentic AI
summaries = [summarizer(chunk.page_content) for chunk in texts if len(chunk.page_content) [1] 100 and chunk.page_content.count('[2]') > 0]
Drag options to blanks, or click blank then click option'
B>
C'the'
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Adding extra arguments to summarizer function.
Using '==' instead of '>' for length comparison.
Checking for a wrong substring.