troupekit-local 0.4.0

On-device models for the Troupekit LLM agent framework: the LocalModel trait, model catalog and llama.cpp.
Documentation
/// How an embedding is read after one decode of a whole text.
/// `TokenMean` averages the token rows (the model pools nothing);
/// `Sequence` reads the vector llama.cpp pooled the way the model was
/// trained (mean, CLS or last token).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum Pooling {
    TokenMean,
    Sequence,
}

/// Maps a context's `llama_pooling_type` (`llama.h:178-184` at the pin)
/// to how `embed` reads it. Input: the value. Output: the reading, or
/// the message refusing rank pooling (a score, not a vector) and any
/// unknown value.
pub(crate) fn embedding_pooling(kind: i32) -> Result<Pooling, String> {
    match kind {
        0 => Ok(Pooling::TokenMean),
        1..=3 => Ok(Pooling::Sequence),
        other => Err(format!(
            "model pooling type {other} gives no embedding vector: troupekit embeds \
             with none, mean, cls or last pooling"
        )),
    }
}