Score – rate on a scale
The Score node lets Laya rate a text on a scale of ordered levels, for example from “not at all” to “extremely” urgent. Laya returns one number, score, that can lie between two levels, plus the probability of every level.
At a glance
- Question type: rate on a scale of 2 to 32 levels
- Laya returns:
score(0 = first level, highest = last level),legendandprobabilities - Default levels: not at all slightly moderately very extremely
- Batch mode: supported
When to use Score
- The answers go from “little” to “a lot”: urgency, anger, satisfaction, risk, complexity, politeness.
- You want a number to compare against thresholds, for example “escalate from 3 upwards”.
Are the answers different things without an order (department, topic)? Use Choice instead.
Score vs. Choice
Choice picks exactly one answer. Score understands that the levels build on each other, and its result shows where between the levels the text lies. Example with the levels low, medium, high, critical:
| Laya’s probabilities | Choice would say | Score says |
|---|---|---|
| medium 30 %, high 40 %, critical 30 % | high | 2.0 – clearly “high” |
| low 45 %, critical 46 % | critical (just) | ≈ 1.5 – Laya is torn between two very different levels |
In the second case Choice would report “critical” although Laya leans almost as much towards “low”. The Score value and the probabilities make this visible.
How the score is calculated
Each level gets a number by its position: the first level is 0, the second 1, and so on. Laya assigns a probability to every level. score is the average of the level numbers, weighted by these probabilities:
| Level | Number | Probability |
|---|---|---|
| low | 0 | 1 % |
| medium | 1 | 17 % |
| high | 2 | 47 % |
| critical | 3 | 35 % |
0 × 0.01 + 1 × 0.17 + 2 × 0.47 + 3 × 0.35 = 2.15
The result 2.15 is a bit above “high”, leaning towards “critical”. With five levels the score lies between 0 and 4. With two levels it lies between 0 and 1.
Settings
Input
| Field | Default | Description |
|---|---|---|
| Text | msg.text | The text or object Laya rates. In batch mode a list or an object of records. |
| Question | How urgent is the request? | The question Laya answers on the scale. Phrase it as “How … is …?”. |
| Levels (Variable) | empty | Optional. Levels as a list from a variable or JavaScript, lowest first. If filled, the Levels list below is ignored. |
| Levels | not at all, slightly, moderately, very, extremely | The scale, one level per row, from lowest to highest. Use Add Item for more rows. Empty rows are ignored. |
Output
| Field | Default | Description |
|---|---|---|
| Result | msg.laya | Laya’s answer, unchanged. See Result. |
Options
| Option | Default | Description |
|---|---|---|
| Batch | off | On: Text holds many records. See Batch mode. |
| Min Confidence (optional) | empty | Laya’s own threshold. If the probability of the most likely level is below it, Laya adds "low_confidence": true. Not available in batch mode. |
Connection options: Model, Server URL, API Key, Timeout
| Option | Default | Description |
|---|---|---|
| Model | Auto | Laya model. Auto picks by language. |
| Server URL | http://127.0.0.1:8000 | Address of the Laya server. |
| API Key (optional) | empty | Vault item with the key, only if the server uses LAYA_API_KEY. |
| Timeout (sec) | 30 | Maximum wait for Laya. |
These options are the same for all Laya nodes. Details in the overview.
Choosing good levels
The level names tell Laya what “low” and “high” mean, so they matter a lot.
The default intensity scale fits most questions of the form “How … is …?”: not at all, slightly, moderately, very, extremely. In our tests it gave sensible answers for urgency, anger and satisfaction.
Avoid bare words like low / medium / high / critical for general questions. In a test, an angry refund e-mail was rated “critical” even for “How satisfied is the customer?”, because the levels describe intensity, not the asked property.
Describe the levels in words for important decisions, like Laya’s own templates do. Two examples for the Levels list, one row per line:
no time pressureneeds attention soonblocking issue or hard deadline
You can also put an explanation after a colon:
none: ordinary requestminor: mildly inappropriateserious: unsafe advice or abusesevere: dangerous or illegal
The whole row, including the explanation, is the level name that Laya sees and returns in legend. Laya does not support a separate description field for levels. That is why the list has only one column.
Levels from a variable
Levels from a variable must be a list, because the order matters:
msg.levels = ["calm and neutral", "concerned but civil", "clearly annoyed", "very angry"];
Result
{ "type": "score", "score": 1.6157, "legend": { "0": "low", "1": "medium", "2": "high", "3": "critical" }, "probabilities": { "0": 0.05, "1": 0.4815, "2": 0.33, "3": 0.14 }, "confidence": 0.3, "answer_confidence": 0.4815, "action": { "act_probability": 1.0 }, "model": "laya-rl-agent", "usage": { "truncated": false, "...": "…" }, "routing": { "model": "english", "...": "…" }}
| Field | Meaning |
|---|---|
score | Weighted level number. 0 = first level, highest = last level. |
legend | Translates level numbers into your level names. |
probabilities | Probability of every level, keyed by level number. |
answer_confidence | Probability of the most likely level. |
low_confidence | Only present when Min Confidence is set and the answer is below it. |
Getting the name of the level
Quick way: round the score. This gives the level closest to the average:
msg.laya.legend[Math.round(msg.laya.score)]
Most likely level: when Laya is torn, the rounded score can differ from the level with the highest probability. To get that one, use this in a Function node:
var a = msg.laya;var best = null; Object.keys(a.probabilities).forEach(function (k) { if (best === null || a.probabilities[k] > a.probabilities[best]) { best = k; }}); msg.level = a.legend[best]; // for example "medium"return msg;
Branching with a Switch node
Order the conditions from strictest to loosest:
msg.laya.score >= 3 // very or extremely urgent → escalatemsg.laya.score >= 1.5 // moderately urgent → normal queuemsg.laya.score < 1.5 // not or slightly urgent → low priority
Tip: To catch torn answers, add msg.laya.answer_confidence < 0.4 at the top and send these to a human.
Batch mode
With Batch on, every record in Text is rated on the same scale in one request (up to 64 per request, more are split automatically).
// object of records → result keeps the IDsmsg.laya.T1.score // list of records → result keeps the ordermsg.laya[0].score
Min Confidence must be empty in batch mode. Compare answer_confidence yourself instead.
Errors
| Message | Cause and fix |
|---|---|
Please enter between 2 and 32 levels | The list has fewer than two filled rows or more than Laya accepts. |
Levels: levels must be a list in ascending order | Levels (Variable) contains an object. Use a list, lowest level first. |
Levels: "…" appears twice | Two levels have the same name. |
Levels (Variable) is empty. Fill it or clear the field to use the list | Levels (Variable) points to a field without a value. |
Laya returned no score | Unexpected answer from the server. Check the Laya server log. |
Connection, timeout, API key and batch errors are the same for all nodes. See Laya package – overview and setup.