Creating coherent book-length articles with GPT-4 Turbo

Creating coherent book-length articles with GPT-4 Turbo

The first day of last year marked a significant milestone for the CyberSEO Pro plugin, as it introduced support for OpenAI GPT, becoming the first in the market to use AI for autoblogging. As the year unfolded, the AI domain continued to evolve, culminating in the release of the OpenAI GPT-4 Turbo, Google Gemini Pro and Anthropic Claude 2.1 models. These models are distinguished by their capacity to generate extensive texts, reaching up to 128K tokens for GPT-4 Turbo (equivalent to about 85,000 words or 300 pages in English), up to 200K tokens for Claude 2.1 and up to 30K tokens for Gemini Pro.

The breakthrough feature of this technology is its ability to produce not just isolated snippets of text, but comprehensive, contextually unified articles. Through the [gpt_article] shortcode, the plugin now offers a powerful tool to generate complete, book-length articles that are seamlessly integrated and contextually coherent, all centered around the specified topic:

[gpt_article engine="AI engine: openai-gpt4-turbo (default), google-gemini-pro, or anthropic-claude" topic="article topic" sections="number of sections" structure="article section structure" directives="specific instructions" language="desired language" heading="heading tag" max_tokens="maximum tokens per section" temperature="creativity level"]

The shortcode doesn’t just string together separate sections on a topic; it creates a fully cohesive article where each part is written in a consistent context. It also ensures that all sections are tightly connected and woven into a single, unified narrative, providing a fluid, well-structured reading experience that maintains a continuous and coherent storyline throughout the article.

The topic parameter is the key element of this shortcode, intended to hold the title of the article to be generated. Typically, it can include the %post_title% placeholder, which, during shortcode processing, will be replaced with the title of the current WordPress post. This makes the most sense when generating articles from a text dump or a CVS file containing article titles. It can also be used with titles from imported RSS feeds, which is particularly relevant in conjunction with the RSS Retriever plugin:

[gpt_article topic="%post_title%"]

Additionally, remember that the CyberSEO Pro plugin allows the use of Spintax in the parameter values of all shortcodes used in post HTML templates (Parse Spintax must be enabled). The topic parameter is no exception:

[gpt_article topic="{Traveling to|Life in|Restaurants in|Sights of|Climate in|Work in} {Paris|London|Warsaw|Berlin|New York|Tokyo}"]

This feature allows you to create post templates with randomly modifiable rules for content generation, an indispensable tool for autoblogging that you should definitely learn to use.

The directives parameter allows you to give additional instructions. If omitted, the default directive applied will be:

“Format the text for embedding in a WordPress post, using only the <p> tag. Exclude any other HTML tags.”

For instance, if you want the generated text to include bullet lists, set the directives parameter as follows:

[gpt_article topic="the article topic" directives="Format the text for embedding in a WordPress post, using only <p>, <ul>, <li> tags. Exclude any other HTML tags."]

Use the directives parameter to specify specific directives and information, text formatting, a writing style, and so on. Similarly, you can specify any HTML tags you wish to see in the generated article. Moreover, you can set desired keywords and provide recommendations on the article’s style and content. For example:

[gpt_article topic="the article topic" structure="article section structure" directives="Write as {an expert-ecologist|a typical urban dweller}. Format the text for embedding in a WordPress post, using only <p>, <strong> tags. Exclude any other HTML tags. Use <strong> for the 'global warming' keyword. The text should cover the problems of environmental protection and be written in an analytical style."]

Note that double quotes ".." cannot be used within parameter values – use single quotes '..' instead. Otherwise, WordPress will not be able to parse your shortcode correctly, as double quotes within double quotes would confuse the parsing algorithm.

If you don’t want to rely on the AI, you can explicitly define the section structure of the article using the structure parameter. For example:

[gpt_article topic="Using ChatGPT to get recommendations for my health care" sections="3" directives="Format the text for embedding in a WordPress post, using only <p>, <em>, <ul>, <li> tags. Exclude any other HTML tags. Write in a simple and entertaining style." structure="The overall semantic structure of the article should be as follows: Section 1: an entertaining introduction; Section 2: the main body of the article; Section 3: FAQ. Give the first 2 sections some creative names, and use 'FAQ' for the name of the 3rd section."]

By default, the shortcode [gpt_article] generates articles in English. To specify a different language, use the language parameter. Note that all parameter values for the [gpt_article] shortcode should be in English or in the target language – both variants are acceptable. Therefore, to get an article in Spanish, your shortcode should look like this:

[gpt_article topic="the article topic" language="Spanish"]

The sections parameter determines the number of text sections in the article, with the default being 4. Changing this value allows you to increase or decrease the length of the generated article. Keep in mind that using the OpenAI GPT-4 Turbo model API can be costly, so adjust the article size based on your budget. You can also use Spintax to create CyberSEO Pro articles of varying lengths. For instance, the following shortcode will generate articles with 3 to 7 text sections:

[gpt_article topic="the article topic" sections="{3|4|5|6|7}"]

You can specify your own tag for headings with the heading parameter. By default, each text section starts with its title enclosed in an <h2> HTML tag (heading=”h2″). Here are some examples of using this parameter:

[gpt_article topic="the article topic" heading="h3"]


[gpt_article topic="the article topic" heading="strong"]


[gpt_article topic="the article topic" heading="div class='heading' id='article'"]

If you don’t want each text section to have a heading, set the heading parameter to an empty string:

[gpt_article topic="the article topic" heading=""]

The max_tokens and temperature parameters allow you to adjust the maximum number of tokens in each generated article section (default is 4096, the maximum for both OpenAI GPT-4 Turbo and Athropic Claude 2.1) and the GPT model’s creativity (default is 1), respectively.

Keep in mind that while the [gpt_article] shortcode can generate a large, multi-page article, you are not limited to using just this shortcode in your post template. Firstly, you can use multiple [gpt_article] shortcodes (e.g., with different settings for different parts of the article). Secondly, your template can include other shortcodes, as you might need to insert graphic illustrations or blocks of HTML code, like a navigation block, advertising block, etc.

The above describes the simplest way to use the [gpt_article] shortcode. Remember, that you can use additional parameters by using all available placeholders. For example, when importing a CSV dump and configuring its format (in the “Dump Format” drop-down box section), you can designate certain CSV fields as “Custom” fields. These will then be converted by the plugin into XML tags like <custom1>, <custom2>, etc.

The values of these “Custom CSV Fields” will be accessible in your template through placeholders like %xml_tags[custom1]%, %xml_tags[custom2]%, and so on. This feature allows you to use these fields as additional parameters or as part of the “directives” string in your shortcode. The video below demonstrates an example of using the %post_excerpt% and %post_tags% placeholders.

It’s important to monitor the token usage in your OpenAI account after setting up your content source using the [gpt_article] shortcode. Currently, the cost of using the GPT-4 Turbo model is $0.01 per 1K incoming and $0.03 per 1K outgoing (generated) tokens. Therefore, assess your expenses for generating each typical article according to your settings to determine the optimal number of generated article sections and the optimal size of each section in tokens, which should not exceed 4096.

Below is an example of a 4-section text generated using the following shortcodes (one for an image and another for the article):

[pixabay q="Solar System" orientation="horizontal" name="%post_title%"]

[gpt_article topic="%post_title%" directives="Format the text for embedding in a WordPress post, using only <p>, <em>, <blockquote>, <ul>, <li> tags. Exclude any other HTML tags. The article should tell about known facts reviving the mysterious secrets."]

Introducing AI Autoblogger