Skip to content

localLLM

1.3.0Package record

Running Local LLMs with 'llama.cpp' Backend

0packages depend
3.3Kdownloads / year
35.3%test coverage
13/13flavors OK

Overview

About

Provides R bindings to the 'llama.cpp' library for running large language models. The package uses a lightweight architecture where the C++ backend library is downloaded at runtime rather than bundled with the package. Package features include text generation, reproducible generation, and parallel inference.

Changes in 1.3.0

New Functions

  • **model_metadata(model)** — returns all GGUF key-value metadata as a named character vector. Useful for inspecting model architecture, quantization type, and embedded chat template. Example: model_metadata(model)["tokenizer.chat_template"].

Bug Fixes

  • **Fixed apply_chat_template() failing for Gemma 4 models** — Gemma 4 uses a <|turn> / <turn|> chat format not recognized by llama_chat_apply_template() (returns -1). The fallback now calls common_chat_templates_apply() from common/chat.cpp, which executes the Jinja2 template embedded in the model's GGUF directly. This works for any model with a valid Jinja2 template regardless of the C API whitelist. enable_thinking defaults to true, so Gemma 4 generates thinking content naturally without a pre-closed thought block. Tool calls and multimodal content are not handled.
  • **Fixed stop token leaking in generate() and generate_parallel() for ChatML models (OLMo, Llama 3)** — Two separate issues fixed:
  • *Windowed find*: OLMo tokenizes <|im_end|> as 6 separate pieces, with the last piece being >\n (merging > and newline). The previous exact-suffix check failed because the response ended with <|im_end|>\n instead of exactly <|im_end|>. Changed to a windowed find() that searches within the last stop.size() + 4 bytes and truncates at the match position. Applied to both generate() and generate_parallel().
  • *<|start_header_id|> loop*: Llama 3.2 3B sometimes omits <|eot_id|> and jumps directly to <|start_header_id|> to begin a new turn, causing infinite repetition. Added <|start_header_id|> to text_stop_strings in both functions.
  • generate()'s stop list also expanded from {"<turn|>", "<end_of_turn>"} to {"<turn|>", "<end_of_turn>", "<|eot_id|>", "<|im_end|>", "<|start_header_id|>"} to match generate_parallel().

Backend

  • **Upgraded llama.cpp backend from b8664 → b8766** — 102 builds of improvements. Gemma 4 audio conformer encoder support, various bug fixes. The Gemma 4 template issue is not fixed upstream in this version; our local fallback is the active workaround.

Bug Fixes

  • **Fixed verbosity not forwarded in quick_llama()** — verbosity parameter was accepted but silently dropped when passed through to .generate_single() and .generate_multiple(), so backend logging level had no effect during quick_llama() calls. Now correctly forwarded to generate() and generate_parallel().
Show all changes in 1.3.0Hide the rest of the changes in 1.3.0
  • **Fixed backend errors crashing R instead of being catchable** — All Rcpp::stop() calls in src/interface.cpp replaced with Rf_error(). stop() throws a C++ exception which crosses the C boundary (.Call() registration) and triggers std::terminate(), killing the R process. Rf_error() uses longjmp which R's condition system can intercept, so tryCatch() now works correctly for all backend errors including the OOM guard.
  • **Fixed model-loading progress dots leaking to stderr with verbosity = 0** — llama_model_load_from_file() has its own progress_callback that prints dots to stderr independently of the log callback system. Now set to a no-op when verbosity < 2 in localllm_model_load_safe(). Model loading is fully silent at the default generation verbosity.

Behavior Changes

  • **generate_parallel(progress) now defaults to interactive()** — previously defaulted to TRUE, which printed carriage-return-based progress bars to log files and R CMD check output. The new default shows the progress bar only in interactive R sessions and suppresses it in scripts and automated checks.
  • **quick_llama(progress) now defaults to interactive()** — same rationale as above; no effect on single-prompt calls.

API Changes

  • **Removed quick_llama(stream) parameter** — the stream argument was present in the function signature but was never passed to any downstream function (it was placeholder code with a comment "available for future use"). Removed to avoid user confusion.

Backend

  • **New localllm_set_verbosity() C API** — added to the backend binary and wired through the proxy layer (proxy.h/cpp, interface.cpp, init.cpp). Enables per-call verbosity control at the C level (integer 0–3, negative = fully silent). Called automatically by generate(), generate_parallel(), model_load(), and context_create() before each C invocation.
  • **C-layer OOM crash guard in localllm_model_load_safe()** — added a last-resort memory check that fires even when check_memory = FALSE. If the model file is larger than total physical RAM, the function now returns a clean error ("Model file (X.X GB) exceeds total physical RAM (Y.Y GB)...") instead of proceeding to llama_model_load_from_file() and letting macOS OOM-kill the R process silently. The guard only blocks provably-impossible loads (file size > total RAM) and does not interfere with the existing R-layer check. Supported on macOS (sysctl hw.memsize), Linux (/proc/meminfo MemTotal), and Windows (GlobalMemoryStatusEx).

Known Issues

  • **R-layer model_load() messages not suppressed by verbosity = 0** — Two R-level message() calls in api.R ("Using cached model: ..." and the GPU/unified-memory info line) print unconditionally regardless of verbosity. The verbosity parameter controls only the C backend log level; these R-layer informational messages are a separate code path not yet gated on verbosity. Confirmed against Gemma 4 26B-A4B (IQ2_XXS) on 2026-04-12.

Documentation

  • **Verbosity dual-default design now documented** — generate() and generate_parallel() roxygen entries now explain why they default to 0L (called in loops, per-call logs would be noisy) and cross-reference model_load()/context_create() (default 1L, run once per session, warnings should be visible).

---

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 3.4 min · r-devel-windows-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK14 OK2026-04-22
  • ERROR13 OK, 1 ERROR2026-04-18
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 1.3.0
READMEYes · 165 wordsVignettesYes · 7 · staticNEWSYes · 100% structured · mentions 1.3.0Citation fileNo
Help pages
34 (1 internal)includes a package overview page
Examples that run
13%2 run in a plain check · 1 only when donttest examples are enabled (R CMD check --as-cran) · 13 never run
Exported functions with examples
50%
Documented parameters
96%
Return-value docs
100%
Help pages citing references
3%

Downloads

3.3K
CRAN downloads in the past year
Rank #12,634 · ~9/day · ~275/mo
Daily download trend is not available in this view yet.
33330 days
88390 days
3.3K1 year
Compare downloads with other packages →
Also on405 r2u5 autocran

Repository

10Stars
1Forks
0Open issues
1Open PRs
6Releases
109Commits
5Commit identities
109 commits · Last activity 2026-05-15 · 0% stars, 30d
Responsiveness
How these are sampled
PRs merged (all time)
100%
Median days to close, 50 most recently updated closed issues
18
Median days to close, 50 most recently updated closed PRs
2

Stars over time

2025-10-21 · 22026-07-21 · 10
PracticesBeta

7 development-tooling and community-health practices detected across 5 families in the upstream repository

Checks run against github.com/eddieyang211/localllm on 2026-10-18.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Docs source (2)

GitHub Pages site last deployed 2026-04-13 · The repository has a site deploy workflow

Coverage (1)
Coverage reporting (Codecov)
Lint, format, editor (1)
VS Code
Show all practicesHide 1 practice
Git structural (1)
Submodules
How this is detected·Detection ruleset v3 (2026-09-26)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • GitHub Copilotfirst seen 2026-01-28
    Pull request: opened by its own account
  • Claude Codefirst seen 2026-02-16
    Named in .gitignore: .claude
    Commits: at least 3 crediting it in the message
Models named in its commits
  • Claude Sonnet 4.63 commits · Apr 2026
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
11 external dependencies (excludes base and recommended)

Installing localLLM adds 7 packages (4 with compiled code, 4.5 MB of source tarballs). Heaviest: Rcpp 1.8 MB, jsonlite 1.0 MB, curl 714 KB.

Depends (1)
R >= 3.6.0
Imports (7)
LinkingTo (1)
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

Datasets

People & History

People (2)
Author, Maintainer since 1.0.1 (2025)
Author
Releases (5)

Pick two releases to compare their code metrics.

  • 1.3.0Latest
    record
    2026-05-05 · current release · diff ↗
  • R
    R 4.6.0 released · 2026-04-24
  • 1.2.1
    record
    2026-02-26 · diff ↗
  • 1.2.0
    record
    2026-02-17 · diff ↗
  • 1.1.0
    record
    2025-12-17 · diff ↗ ·
    added 9 exports
    hardware_profile, list_ollama_models, explore, annotation_sink_csv, document_start, document_end, compute_confusion_matrices, intercoder_reliability, validate
  • 1.0.1
    record
    2025-10-15
  • R
    R 4.5.0 released · 2025-04-11

Package metadata

First published
2025-10-15
Total releases
5 / 1 yrs
License
MIT + file LICENSE OSI
Minimum R
≥ 3.6.0
Bundled data
11 KB / 1 file
Download size
187 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("localLLM")
Xu, Y., & Yang, E. (2026). localLLM: Running Local LLMs with 'llama.cpp' Backend (Version 1.3.0) [Computer software]. https://doi.org/10.32614/CRAN.package.localLLM

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for localLLM version 1.3.0 [Data set]. HJJB, LLC. Data release v2026-10-21. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-21, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy