Skip to main content

A simple custom LLM wrapper for llama.cpp with LangChain compatibility.

Project description

real-llama-cpp-python

A simple custom wrapper for llama.cpp models in Python, support seamlessly interaction with LangChain. As the name suggests, it is truly a wrapper for llama.cpp, you should have installed llama.cpp into your machine prior to this.

Background

While it might seem intuitive that llama-cpp-python would seamlessly integrate with llama.cpp, the reality is that installing llama-cpp-python is a pain in the bum. It is NOT simple as described pip install llama-cpp-python.

Langchain, by default, supports llama-cpp-python. If you have a pipeline that works with Langchain, it would be very difficult to run the latest quantized model (gguf files downloaded from HuggingFace) from llama.cpp. The real-llama-cpp-python is a simplified and an alternative library designed to seamlessly integrate with LangChain while avoiding the pain of installing the library llama-cpp-python.

llama.cpp can be installed or built easily. (If you are facing the challenge by the time you install llama.cpp, the llama.cpp community is also very active that any issue can be resolved in a few days (unlike llama-cpp-python).

Installation

As the name said, it is truly a wrapper for llama.cpp, you should first install llama.cpp into your machine.

1 Install llama.cpp first

After successfully built/installed llama.cpp. You want to add llama.cpp directory to your PATH permanently by editing your shell configuration file:

vim ~/.bashrc 

or

source ~/.zshrc

Add the following line:

export PATH=$PATH:/path/to/your/llama.cpp/build/bin

Save and run source ~/.bashrc or source ~/.zshrc You should be able to run llama-cli and llama-server from any directory. Verify the accessibility, run the following commands in any directory

llama-cli --help
llama-server --help

2 Install llama.cpp

Now, you can install real-llama-cpp-python by either install the stable version through pip install

pip install real-llama-cpp-python

or clone the github repository for the developing features.

git clone https://github.com/minhtran1309/real-llama-cpp-python.git
cd real-llama-cpp-python
pip install -e .

3 Running the tests

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

real_llama_cpp_python-0.1.4.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

real_llama_cpp_python-0.1.4-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file real_llama_cpp_python-0.1.4.tar.gz.

File metadata

  • Download URL: real_llama_cpp_python-0.1.4.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for real_llama_cpp_python-0.1.4.tar.gz
Algorithm Hash digest
SHA256 057a311463b1d428674c09cee2facad8e371ffa9b1f309c9837d0a2933565537
MD5 7bce43be7b65d2194a601bf977549495
BLAKE2b-256 69014d47ec688e6bcf545fe3653a3c4a10ed0adda30c6c0f8a8e655585e519ee

See more details on using hashes here.

File details

Details for the file real_llama_cpp_python-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for real_llama_cpp_python-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e6788b40954615c551b963b3ca1990d7ab81dd91b58c6f6f347a4a7446cc9e30
MD5 9c04b36cd275f03c9d1449746765601c
BLAKE2b-256 fdd50651fefdcd250b2c04bf4d26fe5db1b746bc83e6f1e8b9954b2fb70b7f77

See more details on using hashes here.

Supported by

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