A Python package for creating Gradio applications with llama.cpp models
Project description
llama-cpp-python-gradio
is a Python package that makes it easy for developers to create machine learning apps powered by llama.cpp models using Gradio.
Installation
You can install llama-cpp-python-gradio directly using pip:
pip install llama-cpp-python-gradio
Basic Usage
First, you'll need a GGUF model file for llama.cpp. Then in a Python file, write:
import gradio as gr
import llama_cpp_python_gradio
gr.load(
model_path='path/to/your/model.gguf',
src=llama_cpp_python_gradio.registry,
).launch()
Run the Python file, and you should see a Gradio Interface connected to your local llama.cpp model!
Customization
You can customize the interface by passing additional arguments to the Llama constructor:
import gradio as gr
import llama_cpp_python_gradio
gr.load(
model_path='path/to/your/model.gguf',
src=llama_cpp_python_gradio.registry,
n_ctx=2048, # context window size
n_gpu_layers=1 # number of layers to offload to GPU
).launch()
Under the Hood
The llama-cpp-python-gradio library has two main dependencies: llama-cpp-python and gradio. It provides a "registry" function that creates a Gradio ChatInterface connected to your local llama.cpp model.
The interface supports both text and image inputs (for multimodal models), with automatic handling of file uploads and base64 encoding.
Note: Make sure you have a compatible GGUF model file before running the interface. You can download models from sources like Hugging Face or convert existing models to GGUF format.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_cpp_python_gradio-0.0.1.tar.gz.
File metadata
- Download URL: llama_cpp_python_gradio-0.0.1.tar.gz
- Upload date:
- Size: 110.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b879f480ed0495c2be3f584e2b8968712a4b24469e9428813544eec6e23f28e
|
|
| MD5 |
a57e4abef76c681d0234a4b6aae2ee32
|
|
| BLAKE2b-256 |
c64629136963105f1d990995b2258ef072d1187c261d70a0400b81f86d5b8812
|
File details
Details for the file llama_cpp_python_gradio-0.0.1-py3-none-any.whl.
File metadata
- Download URL: llama_cpp_python_gradio-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2a0979049b8e31b669995000fa28df721da44b93644da5e801fdf2c65b8a27f
|
|
| MD5 |
970a5c8d377ea4c2d01d827cda896f47
|
|
| BLAKE2b-256 |
c26ef7e695e76afb1592cf26f198f342bdc566780dafc612527f78854e5a3f0b
|