Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Embed libmir

libmir is the model-neutral Rust inference library used by MiRMiR. It discovers Hugging Face-style checkpoints, loads a native accelerator backend, creates independent inference sessions, and exposes generation, embeddings, reranking, progress, cancellation, metrics, and memory information.

It deliberately does not contain:

  • CLI argument or environment parsing;
  • an HTTP, gRPC, or WebSocket server;
  • a terminal or browser interface;
  • Hugging Face search and download policy;
  • application configuration files.

Those responsibilities belong to an embedding application such as MiRMiR.

Public lifecycle

ModelDescriptor::inspect(path)
        |
        v
Library::new(RuntimeConfig)
        |
        v
Library::load(path) -> Model
        |
        +-- Model::generate(...)
        +-- Model::embed(...)
        +-- Model::rerank(...)
        +-- Model::session() -> prefill / decode
        +-- Model::unload()

Applications should depend on the top-level libmir package. Its internal workspace crates are implementation details, even when they expose useful low-level types during repository development.

Choose an entry point

NeedAPI
Inspect without allocating accelerator weightsModelDescriptor::inspect
Load a checkpointLibrary::load
High-level chat generationModel::generate
Cooperative cancellationModel::generate_cancellable
Single-image generationModel::generate_image_cancellable
Dense vectorsModel::embed
Document scoringModel::rerank
Manual token loopModel::session, Session::prefill, Session::decode
Capacity planningModelDescriptor::memory_estimate, Library::memory_snapshot

Start with Add libmir to a project.