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
| Need | API |
|---|---|
| Inspect without allocating accelerator weights | ModelDescriptor::inspect |
| Load a checkpoint | Library::load |
| High-level chat generation | Model::generate |
| Cooperative cancellation | Model::generate_cancellable |
| Single-image generation | Model::generate_image_cancellable |
| Dense vectors | Model::embed |
| Document scoring | Model::rerank |
| Manual token loop | Model::session, Session::prefill, Session::decode |
| Capacity planning | ModelDescriptor::memory_estimate, Library::memory_snapshot |
Start with Add libmir to a project.