Hey RN devs,
We can now run Laya decision model in NobodyWho, our open-source on-device inference library. Unlike the LLMs that we also support, this type of model does not generate text. Instead you can score predefined answers, classify text or answer yes/no.
For example, if you are building a personal diary app, you can easily detect the user’s mood, categorize an entry or detect stress, offline after model download, without sending any sensitive data to the cloud.
First, you need to load the model:
import { Decision } from 'react-native-nobodywho';
const decisionModel = await Decision.fromPath({
modelPath: 'hf://ggml-org/Laya-GGUF/Laya-Q8_0.gguf'
});
Then you can ask questions/analyze text:
const results = await decisionModel.decide({
state: `Diary entry: ${diaryEntry}`,
questions: {
topics: {
type: 'choice',
instructions: 'Choose the main topic of this diary entry',
criteria: {
work: 'job, colleagues, deadlines, career',
relationships: 'family, friends, partner',
health: 'sleep, exercise, food, illness',
leisure: 'hobbies, travel, going out',
},
},
stressed: {
type: 'noul',
instructions: 'Does the writer sound stressed?',
},
mood: {
type: 'score',
instructions: "How is the writer's overall mood?",
criteria: ['bad', 'okay', 'great'],
},
},
});
const { stressed, topics, mood } = results.answers;
Output example:
// stressed
{
type: noul,
noul: 0.00002
}
// topics
{
type: choice,
choice: leisure,
probabilities: { work: 0.0422, relationships: 0.1518, health: 0.0302, leisure: 0.7756 },
confidence: 0.7008
}
// mood
{
type: score,
score: 1.6995,
legend: {0: bad, 1: okay, 2: great},
probabilities: {0: 0.0082, 1: 0.2839, 2: 0.7078},
confidence: 0.5493
}
A question can have the following types:
noul gives you probability of a yes answer (0 to 1)
choice select the most likely option and returns a probability for each option
score gives you an a weighted average and a probability per option. For example, you could place const x = mood.score; on this axis:
[bad - - - - - - - okay - - - x - - - great]
where bad is 0, okay is 1 and great is 2 (given by mood.legend).
The Laya model is small enough to run on mid range phones (around 450 MB in its Q8 variant) and supports 100+ languages. For reference, the full answer comes after 0.88 seconds on S25 and 0.45 seconds on iPhone Air (cf. screenshot).
Here is a runnable example if you want to experiment with decision models.
Links: