#language-model #nlp #ai #llm #llama #mistral

kalosm-language-model

A common interface for language models/transformers

7 releases

0.3.3 Aug 28, 2024
0.3.2 Aug 14, 2024
0.2.1 Feb 28, 2024
0.1.0 Dec 16, 2023

#897 in Machine learning

Download history 47/week @ 2024-08-21 210/week @ 2024-08-28 28/week @ 2024-09-04 116/week @ 2024-09-11 228/week @ 2024-09-18 204/week @ 2024-09-25 93/week @ 2024-10-02 73/week @ 2024-10-09 98/week @ 2024-10-16 62/week @ 2024-10-23 74/week @ 2024-10-30 43/week @ 2024-11-06 51/week @ 2024-11-13 73/week @ 2024-11-20 65/week @ 2024-11-27 95/week @ 2024-12-04

292 downloads per month
Used in 12 crates (8 directly)

MIT/Apache

300KB
7K SLoC

Language Model

This crate provides a unified interface for language models. It supports streaming text, sampling, and embedding.

Usage (with the RPhi implementation crate)

use kalosm::language::*;

#[tokio::main]
async fn main() {
    let mut model = Llama::phi_3().await.unwrap();
    let prompt = "The capital of France is ";
    let mut result = model.stream_text(prompt).await.unwrap();

    print!("{prompt}");
    while let Some(token) = result.next().await {
        print!("{token}");
    }
}

Dependencies

~33–48MB
~808K SLoC