How to make a bot which detects product names from the nlu?

How can I make a bot which detects product names. for example, if a user types - I want to buy classmate notebooks…I want my bot to detect ‘classmate notebooks’ from the sentence. Since the list of product names can be very big, how can I efficiently detect the product names? I have tried to use entities and i have included some similar training examples, but not all the products get detected. Has anyone done such similar thing? If yes then can you help me. I am new to rasa.

Hi,

I’ve done that with lookups and synonyms once, it was working okay, as I remember it:


nlu:

# Have some examples in your intent(s):
- intent: find_product
  examples: |
    - Where can I find [classmate notebooks](product)
    - I want to buy [foil](product)
# etc

# If the product name is in the list, it'll be captured as an entity
- lookup: product
  examples: |
    - aluminium foil
    - aluminum
    - foil
    - batteries
    - battery
    - bicycles
    - bike
    - books
    - book
    - textbooks
# etc

# Change the value of your entity "product" into something standardized
- synonym: "Aluminium foil"
  examples: |
    - aluminium foil
    - aluminum
    - foil

- synonym: "Batteries"
  examples: |
    - batteries
    - battery

- synonym: "Bicycles"
  examples: |
    - bicycles
    - bike

- synonym: "Books"
  examples: |
    - books
    - book
    - textbooks
# etc

You might want to generate and/or update these lists automatically, though.

Hope that helps

1 Like

Thanks for replying. I had actually read about using lookup tables for that, but since I have more than a million products to detect, will using lookup tables be a good idea? By that I mean will that affect my model’s performance

It might affect performance, I’m not sure…

You could try with a subset of the products, see how it’s behaving, etc.

If you run into performance issues, you could still capture the entity product, but do the standardization with an action, for example calculating edit distances to figure out the closest standard form. This way you can optimize as much as you want.

Then you can use the action in the appropriate stories.