An OpenVINO conversion of the typed-decisions checkpoint of
convaiinnovations/laya (Apache-2.0), made as an optional small model
for AI Linux Assistant (a local voice assistant for Linux), where it picks the tool for a voice command on an Intel
integrated GPU so the NVIDIA GPU can stay asleep.
Laya reads a state, a question and a menu of options given at request time, and returns a calibrated probability per
option. This copy keeps that behaviour for the choice question type and needs only openvino, tokenizers and
numpy: no PyTorch, no transformers.
Not an official release of Laya. All credit for the model goes to Convai Innovations; please cite and use the original.
convaiinnovations/laya, subfolder typed-decisions, revision 7b928d828b7b0e022f929d9bd2e44165aa270148
(Laya 0.4.15).DecisionModel (ModernBERT-large encoder plus Laya's typed head) converted with openvino.convert_model,
traced at batch 2 so the batch and length axes stay dynamic. Weights stored as fp16. 0.84 GB.tokenizer.json, tokenizer_config.json and LICENSE are the original files, unchanged. decision_config.json
holds the original's max_len, head_max_len and calibration temperatures, plus max_options.logits (one per option marker) and act_logits (Laya's act/escalate head, unused here).297 requests (177 hand-written decisions, 120 tool-routing requests with a 27-option menu), original on CPU in PyTorch
fp32 through laya.Agent.predict:
| This copy, CPU | This copy, Intel Iris Xe | |
|---|---|---|
| Same token ids and option positions | 297 / 297 | 297 / 297 |
| Same top answer | 297 / 297 | 297 / 297 |
| Probability difference | median 0.0001, max 0.0018 | median 0.0019, max 0.026 |
In AI Linux Assistant's tool-routing test (528 requests, 26-tool menu) the original and this copy both picked the right tool 60.8 % of the time, at 713 ms (PyTorch, CPU) vs 148 ms (this copy, Iris Xe). jiwo-0.8b scored 84.5 % on the same test, so the assistant keeps jiwo as its default and offers Laya as a quicker option.
import json
import numpy as np
import openvino as ov
from tokenizers import Tokenizer
d = "laya-typed-decisions-openvino"
cfg = json.load(open(f"{d}/decision_config.json"))
tok = Tokenizer.from_file(f"{d}/tokenizer.json")
tok.no_truncation()
tok.no_padding()
req = ov.Core().compile_model(f"{d}/openvino_model.xml", "GPU").create_infer_request() # or "CPU"
CLS, SEP, MASK = (tok.token_to_id(t) for t in ("[CLS]", "[SEP]", "[MASK]"))
def enc(text, n=None):
ids = tok.encode(text.replace("[MASK]", " "), add_special_tokens=False).ids
return ids[:n] if n else ids
def bucket(k):
return "choice:" + ("2" if k <= 2 else "3-5" if k <= 5 else "6-10" if k <= 10 else "11+")
def ask(state, question, options): # options: {name: description}, 2 to max_options entries
opts = [[MASK] + enc(" " + (f"{n}: {d}" if d else n), 48) for n, d in options.items()]
budget = cfg["head_max_len"] - sum(map(len, opts))
if budget < 16:
per = max(4, (cfg["head_max_len"] - 16) // len(opts))
opts = [o[:per] for o in opts]
budget = cfg["head_max_len"] - sum(map(len, opts))
ids = [CLS] + enc(f"choice question: {question}")[: max(8, budget)] + [SEP]
markers = []
for o in opts:
markers.append(len(ids))
ids += o
ids += [SEP]
ids = (ids + enc(state)[: max(0, cfg["max_len"] - len(ids) - 1)] + [SEP])[: cfg["max_len"]]
mpos = np.array([markers], dtype=np.int64)
out = req.infer([np.array([ids]), np.ones((1, len(ids)), dtype=np.int64), mpos,
np.ones_like(mpos, dtype=bool), np.zeros(1, dtype=np.int64)])
k = len(options)
t = cfg["temperature_by_options"].get(bucket(k), cfg["temperature"][0])
z = out[0][0, :k].astype(np.float64) / min(5.0, max(0.5, t)) # Laya clamps temperatures to [0.5, 5]
p = np.exp(z - z.max())
return dict(zip(options, p / p.sum()))
print(ask("User said: turn it up a bit", "Which tool fits?",
{"set_volume": "change the sound volume", "set_brightness": "change screen brightness",
"none": "none of these fits"}))
The sequence layout follows Laya's own common.py (build_head, build_sequence). OpenVINO runs on Intel GPUs and
any x86-64 CPU; it has no NVIDIA backend.
Apache-2.0, as the original. See LICENSE. Changes from the original are listed above.
convaiinnovations/laya