llama_cpp_dart icon indicating copy to clipboard operation
llama_cpp_dart copied to clipboard

LlamaParent.init() is taking a very long time

Open mnawazshah opened this issue 8 months ago • 2 comments

After 2 days finally I managed to configure the project according to this package but when I called LlamaParent.init() it is taking soooo much time.

here is my code snippet:

`
Future _initLlama() async { final modelPath = await copyAssetToFile('assets/models/small.gguf');

Llama.libraryPath = "assets/libllama.so";
final load = LlamaLoad(
  path: modelPath,
  modelParams: ModelParams()..useMemorymap = false,
  contextParams: ContextParams(),
  samplingParams: SamplerParams(),
  format: ChatMLFormat(),
);

try {
  _llamaParent = LlamaParent(load);
  log("model loaded");
  log("model init called at ${DateTime.now().hour}:${DateTime.now().minute}");
  await _llamaParent.init();
  log("model init completed at ${DateTime.now().hour}:${DateTime.now().minute}");

  _sub = _llamaParent.stream.listen((token) {
    log('stream message: $token');
    setState(() => _botText += token);
  });
} catch (e) {
  _showError('Failed to initialize LLM:\n$e');
}

}

`

mnawazshah avatar Apr 29 '25 10:04 mnawazshah

I used a button to send Prompt and then init was completed as soon as I hit the button for sending the prompt. But now I am getting error inside stream Here are my logs:

[log] process prompt called: Hi [log] response: 1745924511840 [log] stream message: ERROR: Null check operator used on a null value

Also please @netdur can you guide me how to run large models of sizes like 2 3 GB on any user device ? Because we can not build app with such large models inside assets

mnawazshah avatar Apr 29 '25 11:04 mnawazshah

@mnawazshah on play store you can deliver model using Play Asset Delivery also check code in examples

netdur avatar Jun 25 '25 00:06 netdur