How to use AI to create a PowerPoint presentation?

Sascha Gstir
Pondhouse Data
Published in
11 min readMay 16, 2024

AI and especially LLMs have been tremendously successful in generating text. In this blog post, we will show you how to use AI to create a PowerPoint presentation. And even how to tell AI to respect your PowerPoint template

Creating effective PowerPoint presentations is an important skill for professionals and students alike. Well-designed slides can help engage your audience and clearly communicate your message. While it still takes careful planning and an understanding of your audience to make a great presentation, AI might be able to help with the more time consuming, but less important aspects of the process.

Large Language Models (LLMs) like GPT-4, developed by companies like OpenAI, are one example of an AI technology that could potentially assist with presentation creation. These models can generate human-like text based on prompts, which might be useful for brainstorming content ideas or fleshing out speaker notes.

While these Use-Cases are quite mainstream — using ChatGPT to generate presentation ideas, it’s ability to generate code snippets might be useful to not only create the text snippets for a presentation — but the full presentation itself.

In this blog post we are going to explore the capabilities of using GPT-4 to create a fully-fledged PowerPoint presentation. Not only that — we are also showing you how to leverage GPT-4 to use your company’s PowerPoint template and therefore stick to your company’s design guidelines.

How to use GPT-4 to create a PowerPoint presentation

What we are going to build

To demonstrate and validate GPT-4s capabilities in creating PowerPoint presentations and even using corporate design guidelines, we are going to build a small python script that generates a PowerPoint presentation based on given prompts.

While this might already impress some of our readers, the more experienced AI professionals might rightfully ask: “How do you make sure that the PowerPoint presentation is about the right topic?”. This is a more than valid question — as GPT-4 in general might not know the specifics of your company or topic — and therefore might hallucinate some content.

To mitigate this risk — and in general provide GPT-4 with the information it needs — we are going to connect our PowerPoint generator with a small Retrieval Augmented Generation pipeline. As the latter allows us to safely and reliably connect GPT-4 with our company’s data.

Outline for using GPT-4 to create PowerPoint presentations

The system we are going to implement is summarized in the following steps:

  1. We create a small python script that connects to the OpenAI API and allows us to get answers from GPT-4 by providing a prompt.
  2. We create a small Retrieval Augmented Generation pipeline which allows us to retrieve relevant information and data from our company’s data sources.
  3. We create a prompt that asks GPT-4 to generate a PowerPoint presentation based on provided information. We ask GPT-4 to use a package called python-pptx to create the PowerPoint presentation.

python-pptx is a python package that allows you to create PowerPoint presentations programmatically. It is a great tool to create PowerPoint presentations from scratch or to modify existin presentations.

4. We connect the 3 previous components as follows:

a. We use the user prompt — so the specification of what the presentation should be about — to query the Retrieval Augmented Generation pipeline.

b. We use the output of the Retrieval Augmented Generation pipeline and send it to GPT-4. We use a prompt asking to generate a python-pptx-powered python script that creates a PowerPoint presentation.

c. We execute the generated python script and create the PowerPoint presentation.

5. As an add-on, we’ll evaluate, whether we are able to use existing PowerPoint templates to create the presentation — and stick to corporate design guidelines.

Retrieval Augmented Generation enhanced PowerPoint creation with AI

Preparation

As we make use of the programming capabilities of GPT-4, we require a working python 3.11 environment. We recommend using a virtual environment to keep your dependencies clean.

Other then that, you just need:

  • A PowerPoint 2007 or newer installation
  • A PowerPoint template file
  • An OpenAI api key

Install the required python packages by running:

pip install python-pptx llama_index

Implementation of the PowerPoint generator

As creating the presentation itself is the most critical part, we are going to start with that aspect.

To not overwhelm the AI with too many tasks in one go, we divide the challenge into two parts:

  • Structuring the information into presentation material
  • Using that material to create the presentation
  1. Import the required packages:
from llama_index.core import PromptTemplate
from llama_index.llms.openai import OpenAI
from llama_index.core import SimpleDirectoryReader
from llama_index.core import VectorStoreIndex
import json
import re

2. Create a prompt template that asks GPT-4 to structure the provided information into presentation material:

prompt = """
You are a power point presentation specialist. You are asked to create
the content for a presentation about {topic}.
You have been given the following information to create a presentation:
---
{information}.
---
Structure the information in a way that it can be put in a power point
presentation. Each slide should have a title and content, with the content
being a summary of the information provided. Each slide should have one or
more sentences that capture the key points of the information.
Return the structured information as a JSON as follows.
Your answer should only contain the JSON - no markdown formatting.
"""
prompt_template = PromptTemplate(prompt)
prompt_examples = """
Example:
{"slides": [
{"title": "Slide 1", "content": "Content for slide 1"},
{"title": "Slide 2", "content": "Content for slide 2"},
{"title": "Slide 3", "content": "Content for slide 3"},
]}
"""

NOTE: There are several ways for asking GPT-4 to return JSON objects. One of them would be function calling or llama_index' structured prediction functionalities. However, as of time of this writing, there was a problem with GPT-4 where function calling was not working reliably, that's why we opted for the few-shot prompt above.

3. Let’s create some test information and test topic to test the prompt. We will change this later on to use the output of the retrieval augmented generation pipeline.

test_topic = "the benefits of exercise"
test_information = """
Exercise plays a crucial role in maintaining both physical and mental health.
Engaging in regular physical activity can significantly reduce the risk of
chronic diseases such as heart disease, diabetes, and obesity. It also enhances
muscular strength, flexibility, and endurance. Beyond physical benefits, exercise
contributes to improved mental health by reducing symptoms of depression and anxiety,
boosting mood through the release of endorphins, and improving cognitive function.
It fosters a sense of well-being and can be a great way to manage stress.
Overall, incorporating exercise into one's daily routine is a key factor in
achieving a healthier and more balanced lifestyle.
"""

content_prompt = (
prompt_template.format(topic=test_topic, information=test_information)
+ prompt_examples
)

4. Create the LLM inference code

api_key = os.getenv("OPENAI_API_KEY")
llm = OpenAI(model="gpt-4o", api_key=api_key)
llm.complete(content_prompt, True)

The output of this call should be a JSON formatted text, containing a list of slides with titles and content.

5. Create another LLM inference pipeline, that uses these information to create a PowerPoint slide-deck.

powerpoint_prompt = """
You are a PowerPoint presentation specialist. You'll get a list of slides, each
slide containing a title and content. You need to create a PowerPoint presentation
based on the provided slides.
But there is a catch: Instead of creating the presentation, provide python code
that generates the PowerPoint presentation based on the provided slides.
Use the package python-pptx to create the PowerPoint presentation.
The presentation should be visually appealing and professionally designed.

If the slides content contains more than one information, make bullet points.
Save the presentation as 'presentation.pptx'.

Your answer should only contain the python code, no explanatory text.

Slides:

"""

presentation_code = llm.complete(powerpoint_prompt + str(slides), True).text

match = re.findall(r"python\n(.*?)\n```", presentation_code, re.DOTALL)
python_code = match[0]

6. Execute the generated python code to create the PowerPoint presentation.

exec(python_code)

This will create a file called presentation.pptx in the current working directory. Have a look at the file to see the generated presentation.

Quite impressive right? We are able to generate PowerPoint presentations based on a given topic and information — all automatically from an AI.

So far so good, up until now we know how to utilize GPT-4 to create a PowerPoint presentation, when presented with a topic and some information.

Next, instead of providing hard-coded information, let’s use the retrieval augmented generation pipeline to provide the information to GPT-4.

Implement the retrieval augmented generation pipeline

In this next section, we are going to simulate our companies data repository by using a simple directory. We assume, our companies documents are all stored there.

We are going to use the llama_index package to index the documents and retrieve the relevant information for the topic we want to create presentations for.

As example document we are using a very well-known Paul Graham essay about his life — and ask GPT-4 to create a presentation on Paul Graham.

  1. Download the sample document
mkdir -p 'data/paul_graham/'
wget 'https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/paul_graham/paul_graham_essay.txt' -O 'data/paul_graham/paul_graham_essay.txt'

2. Load all files in our directory

reader = SimpleDirectoryReader(
input_files=["./data/paul_graham/paul_graham_essay.txt"]
)
docs = reader.load_data()
index = VectorStoreIndex.from_documents(docs)

3. Now that we created our vector store, we can use it to retrieve information relevant for our presentation. For that, let’s set up our embedding model as well as our vector retriever.

NOTE: In this guide we assume you know how RAG works. For a primer to what RAG is and how it works, see here

 docs = reader.load_data()
embed_model = OpenAIEmbedding(api_key=api_key)
Settings.embed_model = embed_model
index = VectorStoreIndex.from_documents(docs)

retriever = index.as_retriever(similarity_top_k=5)

4. And finally, we can define our topic, and find all relevant information for it.

 topic = "Paul Grahams life and what he worked on"
relevant_information = retriever.retrieve(topic)

relevant_information contains information related to the specified topic about Paul Grahams life.

Combining the RAG pipeline with PowerPoint creation

We are getting somewhere, aren’t we? We know, how to create presentations and we know how to efficiently retrieve information for this presentation. Let’s stick it together. This is rather easy, as we can reuse code from the previous sections.

# Continue from previous chapter
information = "\n---\n".join([res.text for res in response])

content_prompt = (
prompt_template.format(topic=topic, information=information) + prompt_examples
)

slides = json.loads(llm.complete(content_prompt, True).text)


powerpoint_prompt = """
You are a PowerPoint presentation specialist. You'll get a list of slides, each
slide containing a title and content. You need to create a PowerPoint presentation
based on the provided slides.
But there is a catch: Instead of creating the presentation, provide python code
that generates the PowerPoint presentation based on the provided slides.
Use the package python-pptx to create the PowerPoint presentation.
The presentation should be visually appealing and professionally designed.

If the slides content contains more than one information, make bullet points.

Your answer should only contain the python code, no explanatory text.

Slides:

"""

presentation_code = llm.complete(powerpoint_prompt + str(slides), True).text

match = re.findall(r"python\n(.*?)\n```", presentation_code, re.DOTALL)
python_code = match[0]

exec(python_code)

Isn’t that amazing? We just created a quite monumental presentation about Paul Grahams life in about 10 seconds.

I’ll give you that — it’s not the most enticing presentation of all time and it probably needs some minor refinements. But — it’s definitely incredibly helpful to get a presentation with all relevant (and factual correct!) information as a starting point.

One thing however which is kinda annoying and hinders further productive use is the lack of styling and corporate design. Let’s fix this quickly.

Use GPT-4 to create PowerPoint presentation with corporate design

So, the holy grail, creating PowerPoint presentation with corporate design. First things first, we will now convince GPT-4 to design a PowerPoint presentation based on our written input.

However, we will be able to use a PowerPoint template as base presentation — GPT-4 then adds the content to this template. This is factually the same result — a presentation designed in our corporate design language.

  1. Create a PowerPoint template and save it in your current working directory as ‘template.pptx’.
  2. Slighly change the PowerPoint creation prompt as follows
powerpoint_prompt = """
You are a PowerPoint presentation specialist. You'll get a list of slides, each
slide containing a title and content. You need to create a PowerPoint presentation
based on the provided slides.
But there is a catch: Instead of creating the presentation, provide python code
that generates the PowerPoint presentation based on the provided slides.
Use the package python-pptx to create the PowerPoint presentation.
In your code, use a file called 'template.pptx' as the template for the presentation
and stick to the template's design.

If the slides content contains more than one information, make bullet points.

Your answer should only contain the python code, no explanatory text.

Slides:

"""

presentation_code = llm.complete(powerpoint_prompt + str(slides), True).text

match = re.findall(r"python\n(.*?)\n```", presentation_code, re.DOTALL)
python_code = match[0]

exec(python_code)

3. Run the code again.

That’s it. All we needed was to tell GPT-4 to actually use our template — and it happily obliged. I like it when life’s that simple.

And the output looks absolutely stunning. We have a presentation about Paul Graham in our corporate design language. And all of that in less than 10 seconds.

Paul Graham presentation in corporate design

NOTE: If you get an error “Package not found” when running the last line in the code example, its because the “template.pptx” is not in the same location as where you run the script. Make sure to move the template to the correct location.

Interested in how to train your very own Large Language Model?

We prepared a well-researched guide for how to use the latest advancements in Open Source technology to fine-tune your own LLM. This has many advantages like:

  • Cost control
  • Data privacy
  • Excellent performance — adjusted specifically for your intended use

Conclusion

In summary, using AI tools like GPT-4 to create PowerPoint presentations can save time and ensure that slides follow your company’s design templates. This blog post showed a reliable way to use GPT-4 to automatically make presentations that look good and have relevant content, based on your company’s slide templates. By using AI to help make presentations, you can spend more time on delivering your message instead of manually putting together slides. AI can generate content that fits the context and, when combined with fact-checking against reliable sources, will produce slides that are not only visually appealing but also accurate and on-topic. This method saves time and uses AI’s capabilities to improve the overall quality of business presentations. As AI keeps advancing, using it for common work tasks like making PowerPoint slides is changing how we create and share information, making AI a valuable tool for professional communication.

As AI keeps getting better, it will keep being used for everyday tasks like this. It will make things more efficient and also give us new ways to be creative and personalize how we share ideas through presentations.

Further Reading

--

--