Skip to main content

Unofficial python bindings for llama-rs. 🐍❤️🦀

Project description

llama-rs-python

Unofficial python bindings for llama-rs created with PyO3. 🐍❤️🦀

This package gives access to the basic functionality of the llama-rs project.

GGML converted models can be loaded and executed.

Installation

Simply install it via pip: pip install llama-rs-python

Usage

The package is typehinted for easy usage.

A usage example could look like this:

from llama_rs_python import Model

#load the model
model = Model("path/to/model.bin")

#generate
print(model.generate("The meaning of life is"))

The package also supports callbacks to get each token as it is generated. The callback-function also supports canceling the generation by returning a True value from the pytohn side.

from llama_rs_python import Model
import sys
from typing import Optional

#load the model
model = Model("path/to/model.bin")

#define the callback
def callback(token:str)->Optional[bool]:
    print(token,end="")
    sys.stdout.flush()
    # (return True here to cancel the generation)

#start generation
model.generate("The meaning of life is",callback=callback)

The configuration of the generation is handled by the GenerationConfig class.

from llama_rs_python import Model, GenerationConfig

#load the model
model = Model("path/to/model.bin")

#create a config
config = GenerationConfig(top_p=0.9,seed=1441,max_new_tokens=1024)

#generate
print(model.generate("The meaning of life is",generation_config=config))

To configure model specific settings the SessionConfig class can be used.

from llama_rs_python import Model, SessionConfig

#define the session
session_config = SessionConfig(threads=8,context_length=512)

#load the model
model = Model("path/to/model.bin",session_config=session_config)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_rs_python-0.0.2.tar.gz (12.8 kB view hashes)

Uploaded Source

Built Distributions

llama_rs_python-0.0.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

llama_rs_python-0.0.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

llama_rs_python-0.0.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

llama_rs_python-0.0.2-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

llama_rs_python-0.0.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

llama_rs_python-0.0.2-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

llama_rs_python-0.0.2-cp311-none-win_amd64.whl (265.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

llama_rs_python-0.0.2-cp311-none-win32.whl (246.2 kB view hashes)

Uploaded CPython 3.11 Windows x86

llama_rs_python-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

llama_rs_python-0.0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

llama_rs_python-0.0.2-cp311-cp311-macosx_11_0_arm64.whl (393.7 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

llama_rs_python-0.0.2-cp311-cp311-macosx_10_7_x86_64.whl (417.2 kB view hashes)

Uploaded CPython 3.11 macOS 10.7+ x86-64

llama_rs_python-0.0.2-cp310-none-win_amd64.whl (265.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

llama_rs_python-0.0.2-cp310-none-win32.whl (246.2 kB view hashes)

Uploaded CPython 3.10 Windows x86

llama_rs_python-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

llama_rs_python-0.0.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ i686

llama_rs_python-0.0.2-cp310-cp310-macosx_11_0_arm64.whl (393.7 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

llama_rs_python-0.0.2-cp310-cp310-macosx_10_7_x86_64.whl (417.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

llama_rs_python-0.0.2-cp39-none-win_amd64.whl (265.6 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

llama_rs_python-0.0.2-cp39-none-win32.whl (246.6 kB view hashes)

Uploaded CPython 3.9 Windows x86

llama_rs_python-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

llama_rs_python-0.0.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

llama_rs_python-0.0.2-cp38-none-win_amd64.whl (265.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

llama_rs_python-0.0.2-cp38-none-win32.whl (246.1 kB view hashes)

Uploaded CPython 3.8 Windows x86

llama_rs_python-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

llama_rs_python-0.0.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ i686

llama_rs_python-0.0.2-cp37-none-win_amd64.whl (265.4 kB view hashes)

Uploaded CPython 3.7 Windows x86-64

llama_rs_python-0.0.2-cp37-none-win32.whl (246.1 kB view hashes)

Uploaded CPython 3.7 Windows x86

llama_rs_python-0.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

llama_rs_python-0.0.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.5+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page