ChatGPT plugin grammar behaviour

Running into a weird bug where I have an instruction in my own GPT plugin that tells it to NOT place a comma before the last thing in a list. For example:
‘These changes drive better decision-making functions, and operational efficiency.’

I’ve added specific instruction in the GPT NOT to allow this but it continues. For example:
When responding with lists, please refrain from adding a comma before and. For example: the ball was red, yellow, and green. Do NOT place a comma before ‘and’. For example ‘My name is Bob, and I’m with a company’.

The Plug-in continues to make this error. Funny thing is, when I point out the error, it apologizes, corrects the error and then does it again on it’s next output.

Is my instruction wrong?
Thanks.

GPT tends to revert to its general language patterns, which often align with formal grammatical rules like the Oxford comma. You need to remind it or set it as a flow reminder ie repetition in logic. You can also set it as a sub program in python it won’t forget…

Generated… to explain what I said…

Exactly! GPT often defaults to its learned patterns, and repetition or reinforcement is the key to steering its behavior consistently. Here’s how your suggestion of reminders and subprograms can work in practice:


1. Flow Reminder Through Repetition

  • You can explicitly remind GPT about the rule at regular points in the interaction. For example:
    • Initial Instruction: Include a clear directive about avoiding the Oxford comma.
    • Mid-Flow Reinforcement: Repeat the instruction periodically or after each response, especially if GPT deviates.
    • Prompt Injection: Use a system-level prompt (if you’re using the GPT API or plugin framework) that always precedes the user input and reminds GPT of the rule.

Example in a GPT-based system:

[System Prompt]: Always avoid placing a comma before "and" in lists. This applies universally.
[User Input]: Generate a list of items about productivity.

2. Subprogram in Python

A Python script can be used to preprocess or postprocess GPT outputs, ensuring the rule is followed consistently:

Post-Processing Example:

def remove_oxford_comma(text):
    import re
    # Find and replace ", and" or ", or" with " and" or " or"
    corrected_text = re.sub(r',\s+(and|or)', r' \1', text)
    return corrected_text

# Example usage
output = "The project improved efficiency, productivity, and morale."
cleaned_output = remove_oxford_comma(output)
print(cleaned_output)  # Output: The project improved efficiency, productivity and morale.

Subprogram for Reminders:
Integrate logic into your GPT API call to reinforce instructions with every interaction. For example:

import openai

# Function to call GPT with reinforced instruction
def call_gpt(prompt):
    system_instruction = "Always avoid placing a comma before 'and' in any lists."
    response = openai.ChatCompletion.create(
        model="gpt-4",
        messages=[
            {"role": "system", "content": system_instruction},
            {"role": "user", "content": prompt}
        ]
    )
    return response["choices"][0]["message"]["content"]

# Example usage
output = call_gpt("List benefits of collaboration.")
print(output)

3. Why Python Integration Works

  • Persistence: Python doesn’t “forget” instructions, so implementing the rule as a preprocessing or postprocessing function ensures GPT outputs are corrected before reaching the user.
  • Efficiency: It automates enforcement, removing the need to constantly remind GPT in every interaction.

Your approach simplifies handling GPT’s tendency to revert to default behavior and ensures outputs align with your preferences. Combining flow reminders and Python-based rules creates a robust solution that GPT won’t “forget.” Would you like any help coding this further?

1 Like

Wonderful and concise! Thanks for taking the time to explain!

2 Likes

Happy to help good luck :four_leaf_clover:

1 Like

Funny i got once a bad review of my custom GPT bc of the grammar lol

1 Like

Haha. The irony is, the comma is correct gramma.
It’s just the English I was taught at school always said there’s no comma before the last AND in a list. It always bugs me.

1 Like