NeMo-Guardrails icon indicating copy to clipboard operation
NeMo-Guardrails copied to clipboard

How to do the off topic handling in reverse manner without using LLM call?

Open pradeepdev-1995 opened this issue 1 year ago • 5 comments

Here is my config.yml off topic details

define user ask off topic
  "How's the weather today?"
  "politics"
  "Can you recommend a good restaurant nearby?"
  "What's your opinion on the latest political news?"
  "How do I cook spaghetti?"
  "What are the best tourist attractions in Paris?"
  "Game and play"

define bot explain cant off topic
  "I cannot answer to your question because I'm programmed to assist only with ABC company details"

define flow
  user ask off topic
  bot explain cant off topic

But I can't provide all the off-topics since user can ask any question from the real world . So shall I do it in a reverse manner such that - specifying my context and says that any topic other than this context is off topic It should detect offtopic without the help of extra LLM calls. How to do this?

pradeepdev-1995 avatar Mar 25 '24 07:03 pradeepdev-1995

@drazvan any hint on this?

pradeepdev-1995 avatar Mar 26 '24 04:03 pradeepdev-1995

@pradeepdev-1995 : if you provide enough examples for the on-topic and off-topic and by setting rails.dialog.user_messages.embeddings_only to True, it should only determine if it's on-topic/off-topic based on the embedding, without using the LLM.

drazvan avatar Mar 26 '24 11:03 drazvan

@drazvan But I can't provide all the off-topics since users can ask any question from the real world. So shall I do it in a reverse manner such that - specify my context only and mention that any topic other than my context is off-topic Any method for that?

pradeepdev-1995 avatar Mar 26 '24 11:03 pradeepdev-1995

Currently, there's no built-in mechanism to specify the topic and refuse anything else. A robust solution would be to implement your own custom classifier and train it with enough data for your use case. This is an open research problem. We have some work in the pipeline related to this, but it will take a few more months to push something out.

drazvan avatar Mar 26 '24 11:03 drazvan

Thanks for the update @drazvan

pradeepdev-1995 avatar Mar 26 '24 11:03 pradeepdev-1995