How to prevent Chat GPT API from answering nonsense?

We’ve had great success implementing the Chat GPT API in our smart speaker to provide a conversation interface for users. But one issue we have is that Chat GPT ALWAYS responds with something even when the input is total nonsense.

Sometimes the smart speaker picks up TV noise or incomplete sentences that shouldn’t get a response. I’d like to be able to detect “nonsense” and either respond with “I don’t understand your question” or NULL.

For context, here are a couple of nonsensical phrases I sent to the API with the completions.

prompt: “run coffee but grass Christmas already”
completion: “No, it doesn’t sound like a good idea. Coffee and grass are two completely different things, and combining them would likely not result in a good flavor. Additionally, Christmas is a seasonal flavor, and it’s not likely that it would work well with either of the other two flavors.”

prompt: “hair thought sunshine upon sit bath tomorrow yellow”
completion: “My hair will shine in the sunshine tomorrow when I sit in the yellow bath.”

1 Like

Looks like a good opportunity to fine-tune a model for classifying as nonsense/not-nonsense.

1 Like