llama_cpp_rs

Crates.iollama_cpp_rs
lib.rsllama_cpp_rs
version0.3.0
sourcesrc
created_at2023-07-10 13:47:50.632865
updated_at2023-10-12 08:08:24.191773
descriptionRust bindings for LLAMA.CPP inference
homepage
repositoryhttps://github.com/mdrokz/rust-llama.cpp
max_upload_size
id913024
size14,019,684
mdrokz (mdrokz)

documentation

README

rust_llama.cpp

Docs Crates.io

LLama.cpp rust bindings.

The rust bindings are mostly based on https://github.com/go-skynet/go-llama.cpp/

Building Locally

Note: This repository uses git submodules to keep track of LLama.cpp.

Clone the repository locally:

git clone --recurse-submodules https://github.com/mdrokz/rust-llama.cpp
cargo build

Usage

[dependencies]
llama_cpp_rs = "0.2.0"
use llama_cpp_rs::{
    options::{ModelOptions, PredictOptions},
    LLama,
};

fn main() {
    let model_options = ModelOptions::default();

    let llama = LLama::new(
        "../wizard-vicuna-13B.ggmlv3.q4_0.bin".into(),
        &model_options,
    )
    .unwrap();

    let predict_options = PredictOptions {
        token_callback: Some(Box::new(|token| {
            println!("token1: {}", token);

            true
        })),
        ..Default::default()
    };

    llama
        .predict(
            "what are the national animals of india".into(),
             predict_options,
        )
        .unwrap();
}

Examples

The examples contain dockerfiles to run them

see examples

TODO

  • Implement support for cublas,openBLAS & OpenCL #7
  • Implement support for GPU (Metal)
  • Add some test cases
  • Support for fetching models through http & S3
  • Sync with latest master & support GGUF
  • Add some proper examples https://github.com/mdrokz/rust-llama.cpp/pull/7

LICENSE

MIT

Commit count: 84

cargo fmt