LangChain OpenTutorial
  • 🦜️🔗 The LangChain Open Tutorial for Everyone
  • 01-Basic
    • Getting Started on Windows
    • 02-Getting-Started-Mac
    • OpenAI API Key Generation and Testing Guide
    • LangSmith Tracking Setup
    • Using the OpenAI API (GPT-4o Multimodal)
    • Basic Example: Prompt+Model+OutputParser
    • LCEL Interface
    • Runnable
  • 02-Prompt
    • Prompt Template
    • Few-Shot Templates
    • LangChain Hub
    • Personal Prompts for LangChain
    • Prompt Caching
  • 03-OutputParser
    • PydanticOutputParser
    • PydanticOutputParser
    • CommaSeparatedListOutputParser
    • Structured Output Parser
    • JsonOutputParser
    • PandasDataFrameOutputParser
    • DatetimeOutputParser
    • EnumOutputParser
    • Output Fixing Parser
  • 04-Model
    • Using Various LLM Models
    • Chat Models
    • Caching
    • Caching VLLM
    • Model Serialization
    • Check Token Usage
    • Google Generative AI
    • Huggingface Endpoints
    • HuggingFace Local
    • HuggingFace Pipeline
    • ChatOllama
    • GPT4ALL
    • Video Q&A LLM (Gemini)
  • 05-Memory
    • ConversationBufferMemory
    • ConversationBufferWindowMemory
    • ConversationTokenBufferMemory
    • ConversationEntityMemory
    • ConversationKGMemory
    • ConversationSummaryMemory
    • VectorStoreRetrieverMemory
    • LCEL (Remembering Conversation History): Adding Memory
    • Memory Using SQLite
    • Conversation With History
  • 06-DocumentLoader
    • Document & Document Loader
    • PDF Loader
    • WebBaseLoader
    • CSV Loader
    • Excel File Loading in LangChain
    • Microsoft Word(doc, docx) With Langchain
    • Microsoft PowerPoint
    • TXT Loader
    • JSON
    • Arxiv Loader
    • UpstageDocumentParseLoader
    • LlamaParse
    • HWP (Hangeul) Loader
  • 07-TextSplitter
    • Character Text Splitter
    • 02. RecursiveCharacterTextSplitter
    • Text Splitting Methods in NLP
    • TokenTextSplitter
    • SemanticChunker
    • Split code with Langchain
    • MarkdownHeaderTextSplitter
    • HTMLHeaderTextSplitter
    • RecursiveJsonSplitter
  • 08-Embedding
    • OpenAI Embeddings
    • CacheBackedEmbeddings
    • HuggingFace Embeddings
    • Upstage
    • Ollama Embeddings With Langchain
    • LlamaCpp Embeddings With Langchain
    • GPT4ALL
    • Multimodal Embeddings With Langchain
  • 09-VectorStore
    • Vector Stores
    • Chroma
    • Faiss
    • Pinecone
    • Qdrant
    • Elasticsearch
    • MongoDB Atlas
    • PGVector
    • Neo4j
    • Weaviate
    • Faiss
    • {VectorStore Name}
  • 10-Retriever
    • VectorStore-backed Retriever
    • Contextual Compression Retriever
    • Ensemble Retriever
    • Long Context Reorder
    • Parent Document Retriever
    • MultiQueryRetriever
    • MultiVectorRetriever
    • Self-querying
    • TimeWeightedVectorStoreRetriever
    • TimeWeightedVectorStoreRetriever
    • Kiwi BM25 Retriever
    • Ensemble Retriever with Convex Combination (CC)
  • 11-Reranker
    • Cross Encoder Reranker
    • JinaReranker
    • FlashRank Reranker
  • 12-RAG
    • Understanding the basic structure of RAG
    • RAG Basic WebBaseLoader
    • Exploring RAG in LangChain
    • RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval
    • Conversation-With-History
    • Translation
    • Multi Modal RAG
  • 13-LangChain-Expression-Language
    • RunnablePassthrough
    • Inspect Runnables
    • RunnableLambda
    • Routing
    • Runnable Parallel
    • Configure-Runtime-Chain-Components
    • Creating Runnable objects with chain decorator
    • RunnableWithMessageHistory
    • Generator
    • Binding
    • Fallbacks
    • RunnableRetry
    • WithListeners
    • How to stream runnables
  • 14-Chains
    • Summarization
    • SQL
    • Structured Output Chain
    • StructuredDataChat
  • 15-Agent
    • Tools
    • Bind Tools
    • Tool Calling Agent
    • Tool Calling Agent with More LLM Models
    • Iteration-human-in-the-loop
    • Agentic RAG
    • CSV/Excel Analysis Agent
    • Agent-with-Toolkits-File-Management
    • Make Report Using RAG, Web searching, Image generation Agent
    • TwoAgentDebateWithTools
    • React Agent
  • 16-Evaluations
    • Generate synthetic test dataset (with RAGAS)
    • Evaluation using RAGAS
    • HF-Upload
    • LangSmith-Dataset
    • LLM-as-Judge
    • Embedding-based Evaluator(embedding_distance)
    • LangSmith Custom LLM Evaluation
    • Heuristic Evaluation
    • Compare experiment evaluations
    • Summary Evaluators
    • Groundedness Evaluation
    • Pairwise Evaluation
    • LangSmith Repeat Evaluation
    • LangSmith Online Evaluation
    • LangFuse Online Evaluation
  • 17-LangGraph
    • 01-Core-Features
      • Understanding Common Python Syntax Used in LangGraph
      • Title
      • Building a Basic Chatbot with LangGraph
      • Building an Agent with LangGraph
      • Agent with Memory
      • LangGraph Streaming Outputs
      • Human-in-the-loop
      • LangGraph Manual State Update
      • Asking Humans for Help: Customizing State in LangGraph
      • DeleteMessages
      • DeleteMessages
      • LangGraph ToolNode
      • LangGraph ToolNode
      • Branch Creation for Parallel Node Execution
      • Conversation Summaries with LangGraph
      • Conversation Summaries with LangGraph
      • LangGrpah Subgraph
      • How to transform the input and output of a subgraph
      • LangGraph Streaming Mode
      • Errors
      • A Long-Term Memory Agent
    • 02-Structures
      • LangGraph-Building-Graphs
      • Naive RAG
      • Add Groundedness Check
      • Adding a Web Search Module
      • LangGraph-Add-Query-Rewrite
      • Agentic RAG
      • Adaptive RAG
      • Multi-Agent Structures (1)
      • Multi Agent Structures (2)
    • 03-Use-Cases
      • LangGraph Agent Simulation
      • Meta Prompt Generator based on User Requirements
      • CRAG: Corrective RAG
      • Plan-and-Execute
      • Multi Agent Collaboration Network
      • Multi Agent Collaboration Network
      • Multi-Agent Supervisor
      • 08-LangGraph-Hierarchical-Multi-Agent-Teams
      • 08-LangGraph-Hierarchical-Multi-Agent-Teams
      • SQL-Agent
      • 10-LangGraph-Research-Assistant
      • LangGraph Code Assistant
      • Deploy on LangGraph Cloud
      • Tree of Thoughts (ToT)
      • Ollama Deep Researcher (Deepseek-R1)
      • Functional API
      • Reflection in LangGraph
  • 19-Cookbook
    • 01-SQL
      • TextToSQL
      • SpeechToSQL
    • 02-RecommendationSystem
      • ResumeRecommendationReview
    • 03-GraphDB
      • Movie QA System with Graph Database
      • 05-TitanicQASystem
      • Real-Time GraphRAG QA
    • 04-GraphRAG
      • Academic Search System
      • Academic QA System with GraphRAG
    • 05-AIMemoryManagementSystem
      • ConversationMemoryManagementSystem
    • 06-Multimodal
      • Multimodal RAG
      • Shopping QnA
    • 07-Agent
      • 14-MoARAG
      • CoT Based Smart Web Search
      • 16-MultiAgentShoppingMallSystem
      • Agent-Based Dynamic Slot Filling
      • Code Debugging System
      • New Employee Onboarding Chatbot
      • 20-LangGraphStudio-MultiAgent
      • Multi-Agent Scheduler System
    • 08-Serving
      • FastAPI Serving
      • Sending Requests to Remote Graph Server
      • Building a Agent API with LangServe: Integrating Currency Exchange and Trip Planning
    • 08-SyntheticDataset
      • Synthetic Dataset Generation using RAG
    • 09-Monitoring
      • Langfuse Selfhosting
Powered by GitBook
On this page
  • Overview
  • Table of Contents
  • References
  • Environment Setup
  • Converting PPTX to Langchain Documents Using Unstructured
  • Converting PPTX to Langchain Documents Using MarkItDown
  • Extracting Text from PPTX Using MarkItDown
  • Convert markdown format to Langchain Document format
  1. 06-DocumentLoader

Microsoft PowerPoint

PreviousMicrosoft Word(doc, docx) With LangchainNextTXT Loader

Last updated 28 days ago

  • Author:

  • Design:

  • Peer Review: , ,

  • Proofread :

  • This is a part of

Overview

is a presentation program developed by Microsoft.

This tutorial demonstrates two different approaches to process PowerPoint documents for downstream use:

  1. Using Unstructured to load and parse PowerPoint files into document elements

  2. Using MarkItDown to convert PowerPoint files into markdown format and LangChain Document objects

Both methods enable effective text extraction and processing, with different strengths for various use cases.

Table of Contents

References


Environment Setup

[Note]

  • langchain-opentutorial is a package that provides a set of easy-to-use environment setup, useful functions and utilities for tutorials.

%%capture --no-stderr
%pip install langchain-opentutorial 
# Install required packages
from langchain_opentutorial import package

package.install(
    [
        "langchain-community",
        "langchain-core",
        "unstructured",
        "markitdown"
    ],
    verbose=False,
    upgrade=False,
)

Converting PPTX to Langchain Documents Using Unstructured

Unstructured is a robust document processing library that excels at converting various document formats into clean, structured text. It is well integrated with LangChain's ecosystem and provides reliable document parsing capabilities.

The library includes:

  • Local processing with open-source package

  • Remote processing via Unstructured API

  • Comprehensive document format support

  • Built-in OCR capabilities

from langchain_community.document_loaders import UnstructuredPowerPointLoader

# Initialize UnstructuredPowerPointLoader
loader = UnstructuredPowerPointLoader("data/07-ppt-loader-sample.pptx")

# Load PowerPoint document
docs = loader.load()

# Print number of loaded documents
print(len(docs))
1
print(docs[0].page_content[:100])
Natural Language Processing with Deep Learning
    
    CS224N/Ling284
    
    Christopher Manning
    
    Lecture 2: Word

Unstructured generates various "elements" for different chunks of text.

By default, they are combined and returned as a single document, but elements can be easily separated by specifying mode="elements".

# Create UnstructuredPowerPointLoader with elements mode
loader = UnstructuredPowerPointLoader("data/07-ppt-loader-sample.pptx", mode="elements")

# Load PowerPoint elements
docs = loader.load()

# Print number of elements extracted
print(len(docs))
498
docs[0]
Document(metadata={'source': 'data/07-ppt-loader-sample.pptx', 'category_depth': 0, 'file_directory': 'data', 'filename': '07-ppt-loader-sample.pptx', 'last_modified': '2025-01-16T21:42:19', 'page_number': 1, 'languages': ['eng'], 'filetype': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'category': 'Title', 'element_id': 'bb6cdc142e5062b564541bfbc10f7f8c'}, page_content='Natural Language Processing with Deep Learning')
# Get and display the first element
first_element = docs[0]
print(first_element)

# To see its metadata and content separately, you could do:
print("Content:", first_element.page_content)
print("Metadata:", first_element.metadata)
page_content='Natural Language Processing with Deep Learning' metadata={'source': 'data/07-ppt-loader-sample.pptx', 'category_depth': 0, 'file_directory': 'data', 'filename': '07-ppt-loader-sample.pptx', 'last_modified': '2025-01-16T21:42:19', 'page_number': 1, 'languages': ['eng'], 'filetype': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'category': 'Title', 'element_id': 'bb6cdc142e5062b564541bfbc10f7f8c'}
    Content: Natural Language Processing with Deep Learning
    Metadata: {'source': 'data/07-ppt-loader-sample.pptx', 'category_depth': 0, 'file_directory': 'data', 'filename': '07-ppt-loader-sample.pptx', 'last_modified': '2025-01-16T21:42:19', 'page_number': 1, 'languages': ['eng'], 'filetype': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'category': 'Title', 'element_id': 'bb6cdc142e5062b564541bfbc10f7f8c'}
# Print elements with formatted output and enumerate for easy reference
for idx, doc in enumerate(docs[:3], 1):
    print(f"\nElement {idx}/{len(docs)}")
    print(f"Category: {doc.metadata['category']}")
    print("="*50)
    print(f"Content:\n{doc.page_content.strip()}")
    print("="*50)
    Element 1/498
    Category: Title
    ==================================================
    Content:
    Natural Language Processing with Deep Learning
    ==================================================
    
    Element 2/498
    Category: Title
    ==================================================
    Content:
    CS224N/Ling284
    ==================================================
    
    Element 3/498
    Category: Title
    ==================================================
    Content:
    Christopher Manning
    ==================================================

Converting PPTX to Langchain Documents Using MarkItDown

Supporting formats like PDF, PowerPoint, Word, Excel, images (with EXIF/OCR), audio (with transcription), HTML, and more, MarkItDown preserves semantic structure and handles complex data, such as tables, with precision. This ensures high retrieval quality and enhances LLMs' ability to extract insights from diverse content types.

⚠️Note: MarkItDown does not interpret the content of images embedded in PowerPoint files. Instead, it extracts the images as-is, leaving their semantic meaning inaccessible to LLMs.

For example, an object in the slide would be processed like this:

![object #](object#.jpg)

Installation is straightforward:

# %pip install markitdown

Extracting Text from PPTX Using MarkItDown

In this section, we'll use MarkItDown to:

  • Convert PowerPoint slides to markdown format

  • Preserve the semantic structure and visual formatting

  • Maintain slide numbers and titles

  • Generate clean, readable text output

First, we need to initialize MarkItDown and run convert function to load the .pptx from local.

from markitdown import MarkItDown

md = MarkItDown()
result = md.convert("data/07-ppt-loader-sample.pptx")
result_text = result.text_content
print(result_text[:500])

    
    ![object 2](object2.jpg)
    # Natural Language Processing with Deep Learning
    CS224N/Ling284
    Christopher Manning
    Lecture 2: Word Vectors, Word Senses, and Neural Classifiers
    
    
    # Lecture Plan
    10
    Lecture 2: Word Vectors, Word Senses, and Neural Network Classifiers
    Course organization (3 mins)
    Optimization basics (5 mins)
    Review of word2vec and looking at word vectors (12 mins)
    More on word2vec (8 mins)
    Can we capture the essence of word meaning more ef

Convert markdown format to Langchain Document format

The code below processes PowerPoint slides by splitting them into individual Document objects. Each slide is converted into a Langchain Document object with metadata including the slide number and title.

from langchain_core.documents import Document
import re

# Initialize document processing for PowerPoint slides
# Format: <!-- Slide number: X --> where X is the slide number

# Split the input text into individual slides using HTML comment markers
slides = re.split(r'<!--\s*Slide number:\s*(\d+)\s*-->', result_text)

# Initialize list to store Document objects
documents = []

# Process each slide:
# - Start from index 1 since slides[0] is empty from the initial split
# - Step by 2 because the split result alternates between:
#   1. slide number (odd indices)
#   2. slide content (even indices)
# Example: ['', '1', 'content1', '2', 'content2', '3', 'content3']
for i in range(1, len(slides), 2):
    # Extract slide number and content
    slide_number = slides[i]
    content = slides[i + 1].strip() if i + 1 < len(slides) else ""
    
    # Extract slide title from first markdown header if present
    title_match = re.search(r'#\s*(.+?)(?=\n|$)', content)
    title = title_match.group(1).strip() if title_match else ""
    
    # Create Document object with slide metadata
    doc = Document(
        page_content=content,
        metadata={
            "source": "data/07-ppt-loader-sample.pptx",
            "slide_number": int(slide_number),
            "slide_title": title
        }
    )
    documents.append(doc)

documents[:2]
[Document(metadata={'source': 'data/07-ppt-loader-sample.pptx', 'slide_number': 1, 'slide_title': 'Natural Language Processing with Deep Learning'}, page_content='![object 2](object2.jpg)\n# Natural Language Processing with Deep Learning\nCS224N/Ling284\nChristopher Manning\nLecture 2: Word Vectors, Word Senses, and Neural Classifiers'),
     Document(metadata={'source': 'data/07-ppt-loader-sample.pptx', 'slide_number': 2, 'slide_title': 'Lecture Plan'}, page_content='# Lecture Plan\n10\nLecture 2: Word Vectors, Word Senses, and Neural Network Classifiers\nCourse organization (3 mins)\nOptimization basics (5 mins)\nReview of word2vec and looking at word vectors (12 mins)\nMore on word2vec (8 mins)\nCan we capture the essence of word meaning more effectively by counting? (12m)\nEvaluating word vectors (10 mins)\nWord senses (10 mins)\nReview of classification and how neural nets differ (10 mins)\nIntroducing neural networks (10 mins)\n\nKey Goal: To be able to read and understand word embeddings papers by the end of class')]

MarkItDown efficiently handles tables in PowerPoint slides by converting them into clean Markdown table syntax.

This makes tabular data easily accessible for LLMs while preserving the original structure and formatting.

print(documents[15].page_content)
# Example: Window based co-occurrence matrix
    10
    Window length 1 (more common: 5–10)
    Symmetric (irrelevant whether left or right context)
    
    Example corpus:
    I like deep learning
    I like NLP
    I enjoy flying
    
    | counts | I | like | enjoy | deep | learning | NLP | flying | . |
    | --- | --- | --- | --- | --- | --- | --- | --- | --- |
    | I | 0 | 2 | 1 | 0 | 0 | 0 | 0 | 0 |
    | like | 2 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
    | enjoy | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
    | deep | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
    | learning | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
    | NLP | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 |
    | flying | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
    | . | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |

Set up the environment. You may refer to for more details.

You can checkout the for more details.

is an open-source library by Microsoft that converts unstructured documents into structured Markdown, a format that LLMs can easily process and understand. This makes it particularly valuable for RAG (Retrieval Augmented Generation) systems by enabling clean, semantic text representation.

Unstructured: official documentation
MarkItDown: GitHub Repository
Environment Setup
langchain-opentutorial
MarkItDown
Kane
Kane
architectyou
jhboyo
fastjw
Youngjun cho
LangChain Open Tutorial
Microsoft PowerPoint
Overview
Environment Setup
Converting PPTX to Langchain Documents Using Unstructured
Converting PPTX to Langchain Documents Using MarkItDown