mybigday/llama.rn

React Native binding of llama.cpp

It looks like you just pasted a large portion of the llama.rn README – covering everything from basic usage, speculative decoding, multimodal support, tool‑calling, grammar sampling, parallel decoding, session handling, and embeddings.

If you have a specific question about any of these features (e.g., how to enable MTP speculative decoding, how to feed an image to a multimodal model, how to use the parallel‑slot API, etc.) or need a quick example or clarification, just let me know and I’ll be happy to help!

Otherwise, here’s a very short TL;DR:

  • Initialize with await initLlama({model, n_ctx, n_gpu_layers, …}).
  • Multimodal: call await context.initMultimodal({path: mmprojPath, use_gpu:true}) and then send messages that contain image_url or input_audio objects.
  • Speculative Decoding (MTP): enable via speculative: {type:'draft-mtp', n_max:3} at init‑time or per‑completion; disable with speculative:false.
  • Tool‑calling: provide a tools array and tool_choice:'auto'; the result will include tool_calls if the model decides to invoke a function.
  • Grammar / JSON‑schema: pass a GBNF string in grammar (or a response_format with a JSON schema) to force structured output.
  • Parallel decoding: await context.parallel.enable({n_parallel:4, n_batch:512}) then use context.parallel.completion(...) for slot‑based concurrent requests.
  • Session: await context.saveSession(path) / await context.loadSession(path) to cache KV‑cache state.
  • Embedding: set embedding:true at init and call await context.embedding('text').

Just tell me what you’d like to dive into!

Related

  • Dispatch
  • Project
  • Dispatch
  • Project
  • Project