Cap sensitivity in query_knowledge_base

Hello everyone! I am using action_query knowledge base to make a search of several objects that I want to return to users. Let’s call these objects T-shirts.

I am trying to filter these objects by an attribute, say “color”. All colors in my knowledge-base are in caps-first, like so: “Red”, “Orange”, “Blue”.

What happens is, since the user often types with no caps, the bot cannot find the object the user is looking for because it cannot recognize the attribute without caps. The exact same search with “Red” and “red” does and doesn’t work, respectively.

I need to make queries work for attributes with no caps on the first letter. Learning how to make the query work for plurals of attributes would be awesome as well (e.g. Reds, blues, etc.)

Does anyone have any idea how to solve this? Pipeline below for context.

pipeline:

  • name: SpacyNLP case_sensitive: False
  • name: SpacyTokenizer
  • name: SpacyFeaturizer
  • name: RegexFeaturizer
  • name: LexicalSyntacticFeaturizer
  • name: CountVectorsFeaturizer
  • name: CountVectorsFeaturizer analyzer: “char_wb” min_ngram: 1 max_ngram: 4
  • name: DIETClassifier epochs: 100
  • name: EntitySynonymMapper
  • name: ResponseSelector epochs: 100

Hey @Kelmat-ai! Am I understanding right that you’re extracting the colours as entities? If so you can just add variations on the colours to your training examples, and then you could either add all variations on a colour as synonyms (so that the value you get back is Red or however) or just preprocess the value in your action. Or did you mean something else?

1 Like

That is absolutely right and it seems like both solutions will work. Synonym is likely the one I’ll go with, looks pretty sound. Many thanks for the help on this!

Glad it helps! You’d probably need to do both for synonym mapping to work - if there are no examples with lowercase/plurals it might not extract the word in the first place.

1 Like

Not to worry, I had done that already but overlooked the synonym option. Should be fine really

1 Like