Prev Next

AI / LangGraph LangChain Interview questions II

What are document loaders and splitters?

Document loaders ingest content from various sources and return a list of Document objects (each containing page_content and metadata). Text splitters then divide those documents into smaller chunks suitable for embedding and retrieval.

Common document loaders:

  • PyPDFLoader — extracts text from PDF files, one page per Document
  • WebBaseLoader — scrapes a web page, returns its text content
  • CSVLoader — each row becomes a Document
  • DirectoryLoader — recursively loads all files in a directory
  • UnstructuredFileLoader — handles Word, PowerPoint, HTML, email, and more
  • GitHubLoader — loads files from a GitHub repository

Common text splitters:

  • RecursiveCharacterTextSplitter — splits on paragraphs, then sentences, then words until chunks fit the target size. Most commonly used.
  • CharacterTextSplitter — splits on a single character separator
  • TokenTextSplitter — splits by token count, precise for context window budgeting
  • MarkdownHeaderTextSplitter — splits Markdown by header sections, preserving structure
from langchain.text_splitter import RecursiveCharacterTextSplitter

splitter = RecursiveCharacterTextSplitter(
    chunk_size=1000,    # max chars per chunk
    chunk_overlap=200,  # overlap to preserve context at boundaries
    length_function=len,
)
chunks = splitter.split_documents(documents)
Why is RecursiveCharacterTextSplitter preferred over CharacterTextSplitter?
What does the chunk_overlap parameter in a text splitter do?

Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!

Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!

Earn passively and while sleeping

Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.

Invest now!!! Get Free equity stock (US, UK only)!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.


Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

Show more question and Answers...

Database

Comments & Discussions