Crate kalosm_language_model

source ·
Expand description

§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}");
    }
}

Re-exports§

Structs§

Enums§

  • An error that can occur when loading or saving a cache.
  • The type of embedding the model should output. For models that output different embeddings for queries and documents, this
  • Feedback to give to the model when generating text.

Traits§

  • An extension trait for models that can be converted into a trait object.
  • A model that can be used to embed text. This trait is generic over the vector space that the model uses to help keep track of what embeddings came from which model.
  • An extension trait for Embedder that allows for caching embeddings.
  • An extension trait for Embedder with helper methods for iterators, and types that can be converted into a string.
  • Convert a type into an embedding with an embedding model.
  • Text Generation Models
  • A builder that can create a model asynchronously.
  • Text Generation Models
  • A session for a model.
  • An extension trait for Streams that provides a variety of convenient combinator functions.
  • A raw interface for a model that can be used to generate text synchronously. This provides a very low level interface to a model’s session:
  • An extension trait for sync models.
  • The type of a vector space marks what model the vector space is from. You should only combine vector spaces that come from the same model.

Type Aliases§