4o-mini and negative prompting

We’ve written a python script that scans a block of text and produces a list of SEO tags based on that text. We would like to avoid using some words that are very general and instead force it to focus on the specific topic only.

For example, our blog is about different types of cakes (chocolate, gluten free, etc), but “cakes” and “baking” are too general and not directly in the context of our blog. How can we force it to do that?

I would also like to restrict it to only use the singular form of words, so “strawberry topping” instead of “strawberries” or “strawberry toppings”. Is that possible?

Here is the prompt we are currently using:

"tags": Tags are used to connect a group of similar articles and help the vistor find common themes or ideas. Tags are high-level words or phrases that describe the content of a site and provide details that make it easier for vistors to identify a category of articles they are interested in. Tags are formed based only on the specific topic being discussed within the context of cakes. Create a list of 5-7 relevant high-volume tags. Tags must use natural English words only. Tags must be simple, direct, use the singular form, and focus only on the core concept. Use "{title}", "{introtext} and {fulltext}" to provide useful content as a basis for Tags. Do NOT include 'cooking', 'baking' or 'cakes' in any response.

Instead, it frequently appears to completely ignore these instructions and includes ‘baking’ and ‘cakes’ in the response.

1 Like

Hi. You’ve asked the least-expensive model to do a high quality job of following just one sentence. In addition, you already know the futility of negative prompting, especially without providing an alternative of what to actually produce in such cases to override the likely.

Let’s discuss the prompt.

Firstly, you only describe it as “prompt”. A successful application will use both system message and user message in a way that is optimized for the particular model’s ability and willingness to follow both.

System message should give the identity and purpose to the AI, tell it what job it is doing, why, where its output is going and who the reader is. This is especially important because these models like to “chat”, and will even revert to chat if you continue growing a context of interactions.

User message should give the specific task to perform. Just like a user tells ChatGPT what to do, that is the pattern you must follow for an API model that seems an afterthought of being a ChatGPT product.

The document to be used as data should be clearly containerized so there is no confusing it with instruction, and no attention is exhausted on figuring out what to do. Markdown code fences, triple-quotes, and more can set it off so that nothing within can take over the AI.

Negation and prohibition is of lesser effect. You must tell the AI alternatives to produce, as you language will directly be what the output generation is based on.

I’m not going to rewrite your prompt. o1-preview will do that for us. Your prompt, and my advice, and we have a suggestion, which I touched up a bit:

**System Message:**

You are a content analysis assistant specialized in generating SEO tags for blog articles about different types of cakes. Your task is to create a list of relevant, high-volume SEO tags that help visitors find articles by identifying specific themes or ideas discussed in the content. The tags should be:

- Specific to the unique aspects of the article (e.g., ingredients, types of cakes, techniques, dietary considerations)
- Simple, direct, and in the singular form
- Composed of natural English words only
- Focused on the core concepts without using general terms

Note: The website already covers cake-related content broadly in every article, so avoid using general words such as "cake", "cakes", "baking", or "cooking". More specialized terms within the cake baking domain shall be employed.

**User Message:**

Please generate a list of 5-7 relevant, high-volume SEO tags based on the following article content. The tags should adhere to the guidelines provided. The tags will be output into a JSON array of strings.

---
[document start]

**Title:**
{title}

**Introtext:**
{introtext}

**Fulltext:**
```{fulltext}```

[document end]

If it wasn’t understood and rewritten well - that’s because OpenAI’s flagship model couldn’t understand your goal.


Then, you can actually prevent an AI model from producing certain output.

When they are placed within quotes, or other format like a CSV with an introduction placeholder, the tokens the AI model uses are quite predictable. Token numbers for gpt-4o series, for example:

103487 - “cake”
165133 - “cakes”

baking” is a bit more problematic, because it is not a token, but starts with a “b” token. " baking" with a space before is though, and can be blocked if you are instructing a plain text listing, like seo: fruit, butter,...

This can be done with the logit_bias API parameter, assigning a negative value to demote the likelihood of production.

You might want to use a more general purpose, quality, attentive AI model, even gpt-3.5-turbo series.

6 Likes

Bro you do that for every single one?

Thanks very much for your help. I’ve spent the last few weeks working on the prompt, and hoped you could review for me.

I’m still having difficulty with negative prompts.

I was hoping there was a simple answer to this difficult problem, so I used “cakes” as a shortened way to explain what I was trying to do.

Here now are the full details of the prompt on trying to analyze articles related to Linux and open source security to create more descriptive SEO tags like meta description, title, H1 and general content tags.

You are an expert content analysis assistant, blog writer and Linux security expert. Your task is to understand the context of the article in order to categorize the information. inux is a widely used open-source operating system that has gained popularity due to its security features, stability, and flexibility. Linux security is the set of practices and measures used to protect Linux-based operating systems from security threats and vulnerabilities.

"tags": Tags provide details about an article and make it easy to locate related items in the same category. Tags group together like concepts such as "filesystem encryption" or "open source framework." Tags are used to help describe what the content is about and how it is connected and describe the main subject of the content without being too specific. Tags are usually no more than three words. The best tags have the following properties:

- Must be in singular form
- Include only English letters and spaces
- "security advisory" is better than just "security"
- Avoid tags like "linux security" or "linux" or "security" or "open source" and instead identify the more specific subject of the article is about
- Be descriptive
- "CVE" is better than "CVE-2024-13432" or "ELSA-2024-34432" or any word that includes "CVE"
- Use "{introtext}" and "{title}" and "{fulltext}" and "{introtext}" for useful content as a resource
- For content involving "security advisory", focus on severity such as "critical" or "important" and "moderate". Identify type of cyberattack, such as buffer overflow or privilege escalation or other other information that uniquely describes the effect this type of attack has
- Identify specific aspects of each article, such as "OpenSSH" or "Fedora" or "Rocky Linux" or "python" or "how to install" or "secure guide" "security tips" or program name directly related to the purpose of the article

Note: The website already covers Linux-related content broadly in every article, so focus only on specialized terms within the Linux and open source context. Your task is to generate 5-7 relevant tags based on the content provided.

Role: You are an expert content analysis assistant, blog writer, and Linux security specialist. Your role is to analyze the context of an article and categorize its information effectively.

Objective: Your primary task is to generate 5-7 highly relevant, precise tags based on the content provided. These tags must encapsulate the article’s key topics while adhering to strict tagging guidelines that emphasize specificity and descriptiveness.

Key Guidelines for Generating Tags:

  1. Format and Clarity:
  • Tags must be in singular form.
  • Use only English letters and spaces—avoid special characters or numerics unless part of an established term (e.g., “CVE”).
  • Tags should be no longer than three words.
  1. Avoid Generic Terms:
  • Do not use broad tags like “Linux security,” “Linux,” “security,” or “open source.”
  • Instead, focus on specific aspects of the article, such as technologies, vulnerabilities, or key subjects.
  1. Be Descriptive:
  • Use terms that provide precise context, e.g., “filesystem encryption” instead of “encryption.”
  • For security advisories, highlight severity levels (e.g., “critical,” “important”) and the type of vulnerability (e.g., “buffer overflow,” “privilege escalation”).
  1. Specialized Focus:
  • Identify specific tools, distributions, or frameworks mentioned in the article (e.g., “OpenSSH,” “Fedora,” “Rocky Linux”).
  • Include relevant themes like “how to install,” “secure guide,” or “security tips.”
  • For advisories, reference the vulnerability’s impact or unique traits rather than specific identifiers like “CVE-2024-13432.”
  1. Use Content Strategically:
  • Derive tags from “{introtext},” “{title},” “{fulltext},” and other contextual content provided.
  • Ensure tags align with the article’s core subject matter and specific focus areas within the Linux or open-source domain.

Examples of Good Tags:

  • “filesystem encryption” (specific functionality)
  • “critical vulnerability” (severity of issue)
  • “buffer overflow” (type of attack)
  • “OpenSSH configuration” (specific tool and context)
  • “Fedora security guide” (distribution and purpose)

Your Output: Using the provided content, generate 5-7 highly relevant and specific tags that adhere to these guidelines.

1 Like

AI models lose quality in their instruction following when having large data placed.

A 10 minute solution is to let the keyword-generating AI write what it wants for keywords at good length.

Then have a second AI pass take that list, and remove those keywords that would be overly generic for the topic of the specialized site.

Structured outputs can force the original to make two outputs

  • web search keywords
  • in site specialized keywords, web search subset
2 Likes