Skip to content
프로젝트

소개

llama_cpp.rb provides Ruby bindings for llama.cpp

AI 및 머신러닝

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

llama_cpp.rb

Gem Version License Documentation

llama_cpp.rb provides Ruby bindings for the llama.cpp.

Note: rllama is another Ruby binding for llama.cpp using FFI. It provides a high-level API for easier integration.

Installation

Install the llama.cpp. If you use homebrew, install it by executing:

$ brew install llama.cpp

Install the gem and add to the application's Gemfile by executing:

$ bundle config --local build.llama_cpp "--with-opt-dir=/opt/homebrew/"
$ bundle add llama_cpp

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install llama_cpp -- --with-opt-dir=/opt/homebrew

Usage

Prepare the quantized model by refering to the usage section on the llama.cpp README. For example, you could prepare the quatization model based on open_llama_7b or more useful in the context of Ruby might be a smaller model such as tiny_llama_1b:

$ cd ~/
$ brew install git-lfs
$ git lfs install
$ git clone https://github.com/ggerganov/llama.cpp.git
$ cd llama.cpp
$ python3 -m pip install -r requirements.txt
$ cd models
$ git clone https://huggingface.co/openlm-research/open_llama_7b
$ cd ../
$ python3 convert-hf-to-gguf.py models/open_llama_7b
$ make
$ ./llama-quantize ./models/open_llama_7b/ggml-model-f16.gguf ./models/open_llama_7b/ggml-model-q4_0.bin q4_0

An example of Ruby code that generates sentences with the quantization model is as follows:

require 'llama_cpp'

LlamaCpp.ggml_backend_load_all

model_params = LlamaCpp::LlamaModelParams.new
model = LlamaCpp::llama_model_load_from_file('/home/user/llama.cpp/models/open_llama_7b/ggml-model-q4_0.bin', model_params)

context_params = LlamaCpp::LlamaContextParams.new
context = LlamaCpp.llama_init_from_model(model, context_params)

puts LLaMACpp.generate(context, 'Hello, World.')

LlamaCpp.llama_free(context)
LlamaCpp.llama_model_free(model)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/llama_cpp.rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the LlamaCpp project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

관련 프로젝트 살펴보기

불러오는 중…