Detecting Relevance on a Specific Topic

I want to catch if user’s message contains anything about specific topic. e.g: Fruits, Commercial collaboration. How can i achieve it?

Your question is extremely broad.

Without knowing anything else about your use case the best answer that anyone can give is to use prompt engineering, give it a few examples each time, etc.

If you can describe what you’re trying to accomplish we may be able to give some better suggestions.

I am building a chatbot on Instagram using GPT-4. I don’t know how to use function calls or any other tools to determine if the user’s message is related to the collaboration process (e.g: I would like to get in touch with you regarding advertising.).
For example if user’s message is about fruits i want to end conversation. if its not and its about collaboration, i want to proceed conversation

Hi @ibrahimakh47 - one way you could address this is by using a fine-tuned model (e.g. a fine-tuned gpt-3.5-turbo model) that you train to detect whether a user message is about a specific topic, such as collaboration. You can then build in the condition into your bot to end or proceed the conversation based on the model’s topic classification.

Based on experience, I can say that fine-tuned model are quite reliable at these tasks, provided you have a decent dataset you can train them on.

There are many ways to achieve what you want. Here is one using function calling.

{
  "name": "get_text_score",
  "description": "Get the score of the given text based on the following categories.",
  "parameters": {
    "type": "object",
    "properties": {
      "fruit": {
        "type": "number"
      },
      "hobby": {
        "type": "number"
      },
      "collaboration": {
        "type": "number"
      }
    },
    "required": [
      "fruit",
      "hobby",
      "collaboration"
    ]
  }
}

Sample usage:

I was thinking what is better for your use case, simply get user intent or give scores like sentiment analysis.

2 Likes

I’m not totaly aware of your use case however, I would keep it simple. Function seems to be useless at first sight. A good prompt will do it.