![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
open-intent-classifier
Advanced tools
This library has two purposes: 1. allow to easily test semantic classification with open labels (not pre defined) for intent recognition. 2. allow to experiment with different n-shot classification components.
Closed intent classification uses a set of predefined labels to identify an intent. In comparison, open intent classification allows you to define as many labels you want, without fine tuning the model.
This project implements different components that support open intent classification such as an embedder, a T5 based fine tuned model for intent classification and a verbalizer. If you are interested in finer detailes you can read my blog post.
The goal of this library is to enable you test your assumptions about your data as fast as possible and to be a one stop shop for everything "classification like", similarly to how Bertopic is for clustering.
[!IMPORTANT]
open-intent-classification project is in Alpha stage.
- Expect API changes
- Milage may vary. Quality of classifiers have been tested on Atis and Banking77
$ pip install open-intent-classifier
A full example is under Atis Notebook
from open_intent_classifier.model import IntentClassifier
model = IntentClassifier()
labels = ["Cancel Subscription", "Refund Requests", "Broken Item", "And More..."]
text = "I don't want to continue this subscription"
predicted_label = model.predict(text, labels)
By default, the IntentClassifier is loading a small model with 80M parameters.
For higher accuracy you can initialize the model with:
from open_intent_classifier.model import IntentClassifier
from open_intent_classifier.consts import INTENT_CLASSIFIER_248M_FLAN_T5_BASE
model = IntentClassifier(INTENT_CLASSIFIER_248M_FLAN_T5_BASE)
This will increase model latency as well.
from open_intent_classifier.embedder import StaticLabelsEmbeddingClassifier
labels = ["Cancel Subscription", "Refund Requests", "Broken Item", "And More..."]
text = "I don't want to continue this subscription"
embeddings_classifier = StaticLabelsEmbeddingClassifier(labels)
predicted_label = embeddings_classifier.predict(text)
Using LLM for classification is a viable option that sometimes provides the highest quality. Currently we have implemented only Open AI based LLMs.
from open_intent_classifier.model import OpenAiIntentClassifier
labels = ["Cancel Subscription", "Refund Requests", "Broken Item", "And More..."]
text = "I don't want to continue this subscription"
model_name = "gpt-4o-mini"
classifier = OpenAiIntentClassifier(model_name)
result = classifier.predict(text=text, labels=labels)
from open_intent_classifier.model import OpenAiIntentClassifier, ClassificationExample
labels = ["Cancel Subscription", "Refund Requests", "Broken Item", "And More..."]
text = "I don't want to continue this subscription"
model_name = "gpt-4o-mini"
example = ClassificationExample(text="I want to abort my account", intent_labels=labels, intent="Cancel Subscription")
classifier = OpenAiIntentClassifier(model_name, few_shot_examples=[example])
result = classifier.predict(text=text, labels=labels)
Here's an example of using DSPy based classifier for both educational purposes and potential increase in quality.
from open_intent_classifier.model import DSPyClassifier
classifier = DSPyClassifier()
labels = ["Cancel subscription", "Refund request"]
text = "I want to cancel my subscription"
result = classifier.predict(text, labels)
Here's an example of using SmolLM2 based classifier
from open_intent_classifier.model import SmolLm2Classifier
classifier = SmolLm2Classifier()
labels = ["Cancel subscription", "Refund request"]
text = "I want to cancel my subscription"
result = classifier.predict(text, labels)
from open_intent_classifier.model import SmolLm2Classifier
from open_intent_classifier.model import SmolLm2Classifier, ClassificationExample
labels = ["Cancel subscription", "Refund request"]
example = ClassificationExample(text="I want to abort my account", intent_labels=labels, intent="Cancel Subscription")
classifier = SmolLm2Classifier(few_shot_examples=[example])
text = "I want to cancel my subscription"
result = classifier.predict(text, labels)
The details of training of the classifier is in another repository. I have separated training from inference in order to allow each repository to be focused and extended.
You can read about the training in the training repo: https://github.com/SerjSmor/intent_classification
FAQs
This library has two purposes: 1. allow to easily test semantic classification with open labels (not pre defined) for intent recognition. 2. allow to experiment with different n-shot classification components.
We found that open-intent-classifier demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.