Quickstart with laya
To get started with laya.
Laya is a free, open-source AI model designed for fast, focused text classification. It makes simple decisions—such as routing emails, prioritising tickets, or identifying refund requests—by choosing from predefined options and providing a confidence score.
In short: Laya is built for fast, low-cost AI decisions rather than generating text.
To get started, we have to install laya and creating your python environment. Next we going to use it to decide if the ticket belongs to which department.
This is an approach where it uses the model with your local computing resources. There's another option for you use Laya studio which requires an API but you have to sign up first.
API approach
Here is example API approach using curl + API Key.
curl https://api.laya.studio/v1/systemone \
-H "Authorization: Bearer YOUR-API-KEY" \
-H "Content-Type: application/json" \
-d '{"state":"Hi, I was charged twice for order #4821 ($129.00). Please refund the duplicate charge before Friday, our books close then. This is the second billing mistake this quarter and we'\''re starting to look at other vendors.","questions":{"intent":{"type":"choice","instructions":"What does the customer want?","criteria":{"refund":"money back or a charge reversed","cancel":"to cancel or stop a subscription","delivery":"to know where an order is","technical_help":"help with a bug or a broken feature","question":"general information or how-to","other":"none of the above"}},"urgent":{"type":"noul","instructions":"Does the message need a reply today because of a deadline or time pressure?"},"churn":{"type":"noul","instructions":"Does the customer suggest they may leave or switch to a competitor?"}}}'
And as you can see here, we are downloading the model from hugging face and running the code. It is quite fast.
The only thing is not sure why it keep on reconstructing and takes 6 seconds to do that.
Let's try to understand the code and schema here - based on the documentation here (https://nandhakishorm.github.io/laya/structured/)
Here we have multiple questions and the model would look for look at the the ticket and answers all your questions.And the type should batch the decision primitives that is being defined. here :- https://nandhakishorm.github.io/laya/ and if you don't and lets say we get creative, then we will hit an error - notice that i have changed "type" to ratings.
This is a well formatted questions and anwers
Question 1 - which engineering team owns this ticket and based on the type which is "choice" here - we have the following outputs
{'model': 'laya-rl-agent', 'answers': {'queue': {'type': 'choice', 'choice': 'billing', 'probabilities': {'infrastructure': 0.0951, 'billing': 0.822, 'security': 0.0458, 'support': 0.0372}, 'confidence': 0.5322, 'answer_confidence': 0.822, 'action': {'act_probability': 1.0}},
Question 2 - urgency - 2.72 is the score where wew have 0 - low priorty and etc.... as you can see here:-
'urgency': {'type': 'score', 'score': 2.7296, 'legend': {'0': 'low priority', '1': 'medium', '2': 'high priority', '3': 'critical blocker'},
Question 3 - churn risk - where the type primitive is noul. And it give an very high confidence that the customer is going to cancel subscription.
'churn_risk': {'type': 'noul', 'noul': 0.1925, 'confidence': 0.8075, 'answer_confidence': 0.8075, 'action': {'act_probability': 1.0}}}
Comments