Microsoft PowerPoint

Open in ColabOpen in GitHub

Overview

Microsoft PowerPoint 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

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

[Note]

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

  • You can checkout the langchain-opentutorial for more details.

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

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".

Converting PPTX to Langchain Documents Using MarkItDown

MarkItDown 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.

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:

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.

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.

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.

Last updated