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), legend and probabilities
  • 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 probabilitiesChoice would sayScore says
medium 30 %, high 40 %, critical 30 %high2.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:

LevelNumberProbability
low01 %
medium117 %
high247 %
critical335 %
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

FieldDefaultDescription
Textmsg.textThe text or object Laya rates. In batch mode a list or an object of records.
QuestionHow urgent is the request?The question Laya answers on the scale. Phrase it as “How … is …?”.
Levels (Variable)emptyOptional. Levels as a list from a variable or JavaScript, lowest first. If filled, the Levels list below is ignored.
Levelsnot at all, slightly, moderately, very, extremelyThe scale, one level per row, from lowest to highest. Use Add Item for more rows. Empty rows are ignored.

Output

FieldDefaultDescription
Resultmsg.layaLaya’s answer, unchanged. See Result.

Options

OptionDefaultDescription
BatchoffOn: Text holds many records. See Batch mode.
Min Confidence (optional)emptyLaya’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
OptionDefaultDescription
ModelAutoLaya model. Auto picks by language.
Server URLhttp://127.0.0.1:8000Address of the Laya server.
API Key (optional)emptyVault item with the key, only if the server uses LAYA_API_KEY.
Timeout (sec)30Maximum 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 pressure
needs attention soon
blocking issue or hard deadline

You can also put an explanation after a colon:

none: ordinary request
minor: mildly inappropriate
serious: unsafe advice or abuse
severe: 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", "...": "…" }
}
FieldMeaning
scoreWeighted level number. 0 = first level, highest = last level.
legendTranslates level numbers into your level names.
probabilitiesProbability of every level, keyed by level number.
answer_confidenceProbability of the most likely level.
low_confidenceOnly 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 → escalate
msg.laya.score >= 1.5 // moderately urgent → normal queue
msg.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 IDs
msg.laya.T1.score
 
// list of records → result keeps the order
msg.laya[0].score

Min Confidence must be empty in batch mode. Compare answer_confidence yourself instead.

Errors

MessageCause and fix
Please enter between 2 and 32 levelsThe list has fewer than two filled rows or more than Laya accepts.
Levels: levels must be a list in ascending orderLevels (Variable) contains an object. Use a list, lowest level first.
Levels: "…" appears twiceTwo levels have the same name.
Levels (Variable) is empty. Fill it or clear the field to use the listLevels (Variable) points to a field without a value.
Laya returned no scoreUnexpected 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.


Was this article helpful?
© 2026 Robomotion Help by aeovi.com