Relm – local LLMs as base-R objects, with interpretability
Comments
R-ebirth aims to make R a first-class environment for scientific research on data and AI - mechanistic interpretability ("AI neuroscience"), machine learning including topic modelling, and the life sciences - while staying simple for researchers.
It is delivered as relm: an R package with a Rust native core that embeds a patched llama.cpp, exposing local LLMs (loading, generation, embeddings, activation tracing, steering, and ablation) as base-R-idiom functions returning plain data.frames and matrixes.
Topic modelling with no Python: llm_embed() → UMAP → HDBSCAN → the model names each cluster. One of two runnable demos - see the package README.
Using the package? Start with the package README (quickstart, examples, the two demos) and docs/getting-started.md (install options - binaries or from source - a first run, and troubleshooting). This page is the repository/developer overview. The first public release is here.
Features
relm loads local GGUF models and exposes, as base-R objects:
llm()model loadingllm_tokens()tokenizationllm_generate()text generationllm_logits()next-token distributionsllm_embed()text embeddingsllm_trace()activation tracingllm_steer()steeringllm_ablate()ablation - the mechanistic-interpretability corellm_download()checksum-verified fetch of pinned models
Every numerical feature is validated value-for-value against an independent reference (harness B).
Vision (image inputs) is the next release (v0.2.0); v0.1.0 is text-only. The full plan is in ROADMAP.md.
Repository Structure
rebirth/the R package (R/,src/+src/rust/extendr crate,tests/,vignettes/)rust/Cargo workspace:rebirth-ffi(R Rust boundary),rebirth-llm(engine)rebirth/src/llama.cpp/pinned, patchedllama.cpp(vendored; see itsVENDORING.md)tests/llm-golden/Harness B numerical goldenstests/demos/the two reference demos (anatomy lab; topics without Python)CLAUDE.md,SOLO-PHASE-PLAN.md,ROADMAP.md,API-GRAMMAR.md,ARCHITECTURE.md,DECISIONS.md, andTHESIS-PLAN.md
If anything else disagrees with these files, the files win.
Installation
End users install prebuilt binaries from r-universe (no toolchain required).
Building from source requires:
- R (>= 4.5)
- A C toolchain
- A Rust toolchain (
rustup; the pinned channel is inrust-toolchain.toml) - CMake (>= 3.28) for the vendored engine
# native workspace
cd rust && cargo test && cargo clippy --all-targets -- -D warnings
# R package
R CMD build rebirth && R CMD check relm_0.1.0.tar.gz
License
Dual-licensed MIT OR Apache-2.0 - see LICENSE.md. The vendored llama.cpp is MIT (see NOTICE). The name is protected: modified redistributions must rename (see TRADEMARK.md).
Comments
No comments yet. Start the discussion.