Socket
Socket
Sign inDemoInstall

intent-suggestions

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intent-suggestions

Early intent detection using n-gram language models


Maintainers
1

Intent suggestions

Early user intent detection using n-gram models

The idea behind intent suggestions is similar to autofill when we use words that were typed to make predictions. But instead of predicting the next word, we try to detect the user's intent.

The proposed approach uses n recursively initialised models. Each next model uses a smaller n. I.e. a model initialised with n=3 will include three models (with n=3, n=2 and n=1) This recursive approach allows to also take into account frequency counts from smaller n-grams in case there is no match for the parent model.

Usage

from model import IntentSuggester

model = IntentSuggester()

items = ["one two three four", "five six seven eight"]
labels = ["intent_1", "intent_2"]

model.fit(items, labels)

print(model.predict("zero two three four"))

Output:

{'intent_1': 0.9902, 'intent_2': 0.0098}

Notation

According to the common notation, an n-gram language model uses n-1 words to predict the next word. Given that we are trying to predict a user's intent rather the next word, we'll use a slightly different notation. n in our case will represent the number of words used to predict intent probabilities. So a 3-gram (or trigram) model will use three words to make predictions.

References

The approach was insipred by this work

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc