Skip to content

markcda/llama-cpp-rs

 
 

Repository files navigation

llama-cpp-rs

LLama.cpp rust bindings.

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

The original repo

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/markcda/llama-cpp-rs
cargo build

Usage

[dependencies]
llama_cpp_rs = { path = "../llama-cpp-rs" }
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

LICENSE

MIT

Releases

No releases published

Packages

No packages published

Languages

  • Rust 51.6%
  • C++ 48.2%
  • C 0.2%