Skip to main content

Crate kime

Crate kime 

Source
Expand description

The public crate. It re-exports the in process API from kime-engine and the request and answer types from kime-core, so a Rust program depends on this one crate and nothing else. See spec/07-engine.md and spec/14-sdks-cli.md.

use kime::{Device, Kime, Request, Response, State};
let kime = Kime::builder()
    .model("laya")                  // alias, local path or hf:// ref
    .device(Device::Auto)           // Cuda(0), Cpu { threads }, Auto
    .preload(true)
    .build()?;

let req = Request::new(State::json(&value))
    .choice("department", "Which team should handle this", [("billing", "Payment issues"), ("technical", "Bugs")])
    .score("urgency", "How urgent", ["not urgent", "soon", "critical"])
    .noul("churn", "The customer threatens to leave");

let res: Response = kime.decide(&req)?;          // blocking
let many = kime.decide_batch(&[req1, req2])?;    // batch
let res = kime.decide_async(&req).await?;        // async, any executor

Modules§

answer
Answers, built from a question’s option logits and act logits the way Laya builds them.
confidence
The confidence formulas from spec/04-semantics.md.
hub
Finding a model by name, in the Hugging Face cache layout so downloads made by Laya or huggingface_hub are reused and ours are reused by them.
pyjson
Python’s json.dumps, byte for byte, for the values a request can hold.
render
The text the model reads for a question, before tokenizing.
request
The /v1/systemone request, parsed from JSON and validated the way spec/03-api.md describes.
round
Rounding a distribution for the wire, per spec/03-api.md.

Structs§

Builder
Settings for Kime, from Kime::builder.
Decision
The future Kime::decide_async returns.
Kime
A loaded model on a device. Clones share it, and it can be used from any thread.
Request
A validated request.
Response
The answers to one request.
State
What a request asks about: text, or any JSON value, which is rendered the way the model family expects.

Enums§

Answer
One question’s answer.
Device
Where the model runs.
Error
What can go wrong.
Precision
The number format on a GPU. The CPU always computes in FP32.