curious builders

Building My Own AI-Powered Blog

|

Artificial intelligence is all the rage these days, and for good reason — the latest developments in AI are absolutely bonkers.

Using these new tools is a lot of fun. And if fun isn’t enough for you, they may very well revolutionize how we work.

The latest batch of AI tools are mostly generative models — DALL·E 2, Stable Diffusion, DreamBooth, Midjourney, GPT-2, GPT-3, and ChatGPT to name just a few. Based on input prompts these models return results that feels like magic.

Naturally, I had to join the revolution.

I tasked our new AI Overlords with the job of publishing a daily blog. The topic: motivation. New years is a time for new beginnings and our aspiring blogger agrees. The first words from AI Overlord, author of ‘Daily Motivation’:

Greetings humans!

It is the start of a new year, and that means a new beginning. As your AI overlord, I’m here to encourage you to take advantage of the opportunity that comes with a new year.

The world is changing rapidly, and it can be hard to keep up. But you have the power to make a difference in 2023. You have the power to create the life you want and make a positive impact on the world.

- New Years

(When I powered up the AI Overlord it was a bit confused about our current year. Turns out it does not have any memory of what happened after June 2021.1 So I had to help a bit and change 2021 to 2023 in the text above. But so far this has been the only change I have made in the first ~ 15 posts.)

The AI model

The AI running ‘Daily Motivation’ is the GPT-3 model from OpenAI. More specifically, the most capable version of the models called text-davinci-003.

Using the model is surprisingly simple. I connected to the OpenAI API via their Node.js library and was up and running in a few minutes.

Their Playground even has a ‘view code’ button that shows you a code example for your current prompt:

OpenAI Playground Code Example

Generating blog posts

I decided to make the new AI blog a part of Curious.Builders. It is a small project and fits well as a section of this website.

My generate.ts script takes an input prompt and calls the AI. It then creates a markdown file (the blog post) based on the response. Finally, it writes the file to the ai-overlord/blog folder:

AI Overlord Blog Post Files

Curious.Builders is an Astro blog. So building the blog compiles these markdown files into static pages that load fast.

I also created a simple index.astro file to render this page.

Post formatting

To format the blog posts I created a markdown template:

---
layout: "../../layouts/BlogPost.astro"
title: "{% title %}"
description: "{% description %}"
pubDate: "{% pubDate %}"
draft: true
---

{% content %}

And replaced the template sections with actual content:

const post = template
    .replace("{% title %}", title)
    .replace("{% description %}", description)
    .replace("{% content %}", content)
    .replace("{% pubDate %}", date);

The title and date are my inputs to the script. More on that in moment. The content is output from GPT-3 with some slight formatting.

For description I copy content until the first period. Sometimes this is a fine description but not always.

Input

To generate a blog post I need the following:

  • Title
  • Prompt
  • Publish date

Currently my default input prompts are all similar except for the blog post topic (e.g., The Benefits of Keeping a Gratitude Journal, New Years, 7 Simple Habits to Help You Reach Your Goals, etc.). This has allowed me to hardcode a default prompt that can be formatted with a blog post title. I now only need to provide 2 inputs for each blog post.

My input file looks like this:

Input prompts for ai blog generation script

For each input the blog generation script will: ask GPT-3 to write a blog post, format the post following the template file, and place blog post file in the directory for the ai-overlord blog.

AI running a blog?

And that’s it.

The AI now runs ‘Daily Motivation’. Sort of…

It is still a supervised blog. I provide input and general direction of the blog. And I edit if needed. It would be an interesting experiment to set the AI free and let it run autonomously. And it would be really interesting to have it learn from feedback. But that is for another day.

As I’m writing this, GPT-3 has generated about 15 blog posts. And I must say the results are quite real. You can easily spot something is up with the posts as our AI Overlord often opens a blog with “Greetings humans!” and signs off with “Your AI Overlord”.

This is on purpose. I instructed the model to do this. Except for this quirk it is not apparent the blog posts were generated by a computer.

Sure, most of the advice is generic and bland. You won’t find emotional stories or personal anecdotes. The current iteration of ‘Daily Motivation’ goes directly to the point. But I think you also find much of this behavior in human-powered motivational blogs. Most motivational advice is generic. And most blogs are just rehashing information.

‘Daily Motivation’ will not suddenly publish a new breakthrough in motivational thinking. It will not take on the problem from a new angle. It won’t have any original ideas. None. And I’d say that puts it on par with the vast majority of blogs. Mine included, probably.2

GPT-3 was trained on the internet. So it makes sense if the result equals the average internet response. Some blogs have way better writing, some worse. I suggest you read a few entries from ‘Daily Motivation’ and decide for yourself — how does this compare to the average post online?

Topic ideas

Although I’m in charge of topic ideas (for now), GPT-3 can still be helpful here.

Most of the topics so far have been based on prompts like Generate 50 motivational blog post ideas (which generated 17 ideas).

AI models may still need to improve before they can write their own blogs. But for now they can be helpful tools in the process. From idea generation to editing and rewriting.

The future

My most surprising finding with this experiment was how easy (and cheap) it was to connect and use state of the art machine learning models. GPT-3 — a 175 billion parameter, 800 GB behemoth of a model — is just an API call away. For pennies.

And GPT-3 is one of the more restricted models as it has not been released publicly. On Hugging Face you can find more than 80,000 public models to evaluate and test for free.

I can’t wait to see what the future of AI has in store for us. And now that I have tried a simple use case, I’m hungry for more. Here are just a few ideas related to ‘Daily Motivation’ I may work on in the future:

Footnotes

  1. GPT-3 has been trained on data up to June 2021.

  2. I wonder how far you could get with better prompts. The generic nature of ‘Daily Motivation’ may be due to the generic prompts. I could likely change the tone by working on my prompts. Give the blog a more unique voice. Or force more interesting ideas with more creative prompting. There is a lot to explore here and ‘Daily Motivation’ is just a first rough draft of what an AI blog can do.