0
0
Prompt Engineering / GenAIml~20 mins

Document loaders in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Document Loader Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the main purpose of a document loader in AI?

Imagine you want to teach a computer to understand many documents. What does a document loader do in this process?

AIt reads and converts documents into a format the AI can process.
BIt evaluates the AI model's accuracy on document tasks.
CIt generates new documents based on existing ones.
DIt trains the AI model directly on raw text data.
Attempts:
2 left
💡 Hint

Think about the first step before teaching the AI anything.

Predict Output
intermediate
2:00remaining
Output of loading documents with a simple loader

Given this code snippet that loads text files, what will be the output?

Prompt Engineering / GenAI
documents = ['doc1.txt', 'doc2.txt']
loaded = [open(doc).read() for doc in documents]
print(len(loaded))
A0
B2
CError: File not found
D1
Attempts:
2 left
💡 Hint

How many files are being read?

Model Choice
advanced
2:00remaining
Choosing the best document loader for PDFs

You want to load text from PDF files for your AI project. Which document loader is best suited?

AA loader that extracts text from PDF structure and layout.
BA loader that reads plain text files line by line.
CA loader that loads audio files as text.
DA loader that only reads images without text extraction.
Attempts:
2 left
💡 Hint

PDFs have special formatting and structure.

Hyperparameter
advanced
2:00remaining
Effect of chunk size in document loading

When loading large documents, you can split them into chunks. What happens if you set chunk size too small?

AThe AI ignores the chunks and reads the whole document at once.
BThe AI merges chunks into one large text automatically.
CThe AI processes many small pieces, which may slow down training.
DThe AI crashes because chunk size must be large.
Attempts:
2 left
💡 Hint

Think about how many pieces the AI must handle.

🔧 Debug
expert
2:30remaining
Why does this document loader code raise an error?

Look at this code snippet and find why it raises an error:

docs = ['file1.txt', 'file2.txt']
loaded_docs = []
for doc in docs:
    with open(doc, 'r') as f
        loaded_docs.append(f.read())
print(len(loaded_docs))
AThe print statement is outside the loop causing indentation error.
BThe list 'docs' is empty, so no files to read.
CThe variable 'loaded_docs' is not defined before appending.
DMissing colon ':' after 'with open(doc, 'r') as f' causes SyntaxError.
Attempts:
2 left
💡 Hint

Check the syntax of the 'with' statement.