AI Chatbot for WordPress.

For the past few months, we’ve been experimenting with AI to create innovative tools for WordPress. One of our recent projects, QuickWP, an AI-powered WordPress site builder, was one such project. Building on the things that we learned while making QuickWP, we are excited to introduce something totally new, but related!

In this post, I want to tell you all about Hyve, an AI chatbot for WordPress. Hyve leverages your WordPress content to respond to user inquiries intelligently, providing accurate and context-aware answers directly from your site’s existing materials. Okay, that’s a mouthful, so let’s break it down:

In a sentence, Hyve works with your existing content, uses it as its Knowledge Base, and responds to user questions based on the data provided.

We launched the initial version of Hyve at the end of April, and since then, we have listened to a lot of feedback from our users to improve the plugin to address any possible issues and make it more usable for our users in version 1.1. Today, we are happy to announce that we are making Hyve 1.0.3 free to use for all our users. Hyve is open-source and licensed under GPLv3.

👉 If you want to give Hyve a try, you can download the plugin by clicking the link here..

“But what’s the catch?” you might ask. In this article, I will answer all your questions, share the journey of creating Hyve, explain why we are making this version publicly available, and more.

But first, let’s start from the beginning:

What is Hyve?

Interface for Hyve: AI Chatbot for WordPress
Hyve: AI Chatbot for WordPress

Again, in simple terms, Hyve is an AI chatbot for WordPress that uses OpenAI APIs in combination with your site’s data to answer your users’ questions. You can train Hyve on your website’s content, and it will use that information to provide accurate and relevant responses. With Hyve, you can leverage your posts, pages, and even custom data as your source of knowledge, which we refer to as the Knowledge Base.

All the data stays in your WordPress and OpenAI account. You do not need to connect to any additional services to use Hyve. For the 1.1 version update, we created this video to give our users a walk-through of Hyve:

Apart from the Knowledge Base, you also have more options to customize your chatbot and learn what questions your users are asking that go unanswered. This feature helps you ensure you are adding the right questions to your Knowledge Base.

A failed hackathon project

Let me tell you the story of how Hyve was born.

It’s not the story you asked for, but the story you needed, nonetheless.

Back in March 2023, just a few months after ChatGPT was released and AI projects were taking over Twitter (yes, it was still called Twitter in March 2023); we decided to have a two-day remote hackathon in the company centered around AI.

One developer picked a project to create an AI chatbot for WordPress using OpenAI APIs and data scrapped from company docs. Much to his frustration, he struggled with the task, and ultimately, the project failed.

At this point, I should point out that I was the developer.

In case you are interested, I ended up submitting a last-minute automatic spam comment maker using OpenAI that was barely 50 lines of code.

A slide from the hackathon project presentation

While the idea died down after that hackathon, the team discussed it earlier this year, and this time, we did more research and preparation before writing the first line of code. And that is how Hyve was born.

So why did it fail the first time and not the second?

Prompt engineering, RAG, and fine-tuning

Prompt engineering, Retrieval-Augmented Generation (RAG), and fine-tuning are techniques used in the development of AI tools. When used correctly, each of these methods significantly enhances accuracy, relevance, and overall performance.

But it is also important to know exactly when not to use them. The first time for the hackathon project, we (or more specifically, I) made the mistake of thinking fine-tuning was the answer.

As a novice, I understood that fine-tuning was the way to “train” an AI model to perform the task by showing it hundreds of examples of how to respond to each question. But I was so wrong.

In theory, the chatbot did exactly what it was trained to do. It took a question from the user and replied with some mostly incorrect information in the writing style and tone of our company docs. To explain why, let us dive into the meaning of all these techniques real quick:

Prompt engineering

Perhaps the most famous technique that everyone working with ChatGPT and other AI tools is aware of. We give our AI model some instructions on what to do and specify how it should respond. For example, we might give it a list of data from 20 emails and ask it to summarize them in one line each. It will take the data and reply with something sounding like this:

  • On Tuesday, Jeff emailed you about the printing shipment.
  • On Friday, you received birthday wishes from Jeff and Matt.
  • …and so on

This approach is great for simple tasks when we know exactly what information to give to our AI when asking questions, but it fails when tasks are much more complex.

Retrieval-Augmented Generation (RAG)

As mentioned, prompt engineering is effective for simple tasks but can struggle with more complex queries. This is where Retrieval-Augmented Generation (RAG) comes into play. RAG enhances AI capabilities by combining retrieval-based methods with generative models. Instead of relying solely on the given prompt, RAG searches through a large database of documents to find relevant information, which it then uses to generate a more accurate and contextually rich response.

For example, the user might ask, “Do you offer bike tours in Nice?” With RAG, the AI will first retrieve articles relevant to this question and then base its reply on the information provided in those articles.

Or imagine asking AI for weather updates or stock prices. All of it requires it to fetch access information from some other source.

This approach is particularly useful when dealing with vast amounts of data or when the required information is not directly provided in the initial prompt.

In Hyve, we cannot provide all the data from the Knowledge Base with every single query. It would be too impractical, so we need to use the RAG technique to first gather what information is relevant to the user’s query and then pass it to the AI along with the user’s question.

Fine-tuning

Fine-tuning involves taking a pre-trained AI model and training it further on a specific dataset to make it more adept at particular tasks or domains. Fine-tuning is less about telling the AI exactly what to say and more about helping it understand how to reply.

For example, consider the earlier case from the prompt engineering section, where the AI summarizes emails:

  • On Tuesday, Jeff emailed you about the printing shipment.
  • On Friday, you received birthday wishes from Jeff and Matt.

In this scenario, if the AI wasn’t fine-tuned, it might produce responses that vary in tone or format, making the summaries inconsistent or less useful for particular use cases. Fine-tuning can standardize the AI’s responses, ensuring they follow a consistent style and tone. After fine-tuning, the AI might provide more uniform summaries like this:

  • On Tuesday, Jeff informed you about the status of the printing shipment.
  • On Friday, both Jeff and Matt sent you birthday greetings.

Similarly, in the hackathon project, fine-tuning accomplished what it was intended to do. While it always replied with a wrong answer, it always replied in the same format and tone that we use in our company docs. Fine-tuning worked well; the fault lay more in the technique we chose for the task.

Fine-tuning, when used right, can be a very powerful tool for building AI models for very specific tasks. In fact, it can be trained on lower-ranking models and yet produce much better results than a higher-ranking model.

Choosing the right technique

All of the mentioned techniques are highly useful when used correctly. But when used wrong, they can just as much make your AI tools worse at accomplishing what it addresses to do.

Fine-tuning was not the right approach for our hackathon project. If we had limited ourselves to prompt engineering with RAG, the results would have been much better.

As a rule of thumb, always start with only prompt engineering. If it does exactly what you want it to do, then you do not need to use RAG or fine-tuning.

A chart on ideal optimization flow from OpenAI

If it is not producing the result you want it to produce, see if it needs more contextual information or if the format/tone is consistent. Based on that, it can be decided if it requires RAG, fine-tuning, or both.

I really recommend watching this talk on OpenAI’s YouTube account if you want to learn more about choosing the right technique.

How Hyve works

Now that we have discussed some techniques for building AI tools, let’s explore how we used these in developing an AI chatbot for WordPress.

OpenAI offers multiple ways to build conversational AIs. For this project, we chose the Assistant API over the Chat Completions API. Both APIs have their pros and cons, but we preferred the Assistant API as it allows users to easily view chat history and maintain context by treating each conversation as a thread. This was particularly useful when building QuickWP, so we decided to stick with it. Others might prefer the Chat Completions API, and that is fine too.

With the Assistant API, we create an Assistant when the user connects their OpenAI account and set up the prompt there. This way, we do not have to send the prompt with each request, as OpenAI manages it.

When users send their query to the chatbot, we convert the question into embeddings using OpenAI’s Embeddings API, and run an algorithm to compare them to the site’s knowledge base for the closest matches. We then send the top match alongside the user’s question to the Assistant, ensuring the AI only considers the provided context when responding to the query.

We considered using fine-tuning to improve response quality, but we decided against it for now to keep things simple for the user. However, we may fine-tune a model in the future to ensure it strictly follows the prompt as intended. For now, prompt engineering works well enough without adding complexity.

And now Hyve v1.0 is free

We released Hyve in April, and since then, many customers have provided valuable feedback on how to enhance its functionality. Based on it, last month, we launched Hyve v1.1, which includes advanced features such as detailed insights for site admins on unanswered questions, greater customization options for the Assistant, and numerous other improvements.

Now, we’re excited to announce that Hyve v1.0.3 is free for all users who want to give it a try. This version is a one-off release, meaning it won’t receive updates or customer support. Hyve v1.0.3 includes all the features of the original version, along with fixes for all known bugs.

By offering this free version, we hope more people will try Hyve, providing us with additional feedback and insights into different use cases. This will help us continue to improve and give back to the community.

Who knows, you might love Hyve, too, and decide to subscribe for updates. If you do, simply enter the license key, and you’ll start receiving updates.

We also used this opportunity to share our journey of building an AI chatbot for WordPress with the community. The makers among you might find something useful, or it might help you in explaining how AI chatbots work under the hood.

We hope you give Hyve a try and enjoy using it as much as we enjoy building it. If you face any issues downloading/installing Hyve or have any questions for us, leave a comment below. And again, you can download Hyve v1.0.3 by clicking the link here. And if you want to check out the latest version, you can find it on the product page of Hyve.

Yay! 🎉 You made it to the end of the article!

2 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Marius
August 1, 2024 4:56 pm

We stumbled on the same problem as yourself by using fine tunning instead of completions. Thanks for sharing this!

Editor
Martin Dubovic
July 10, 2024 1:21 am

Great read. Thanks for sharing Hardeep!

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!