Skip to content

Commit 4b2a140

Browse files
committed
Update to use vendored llama.cpp submodule
1 parent b5d3aea commit 4b2a140

File tree

4 files changed

+23
-33
lines changed

4 files changed

+23
-33
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1010
set(GGML_USE_ACCELERATE 1)
1111
find_package(pybind11 REQUIRED)
1212

13-
add_library(llamacpp MODULE src/PyLlama.cpp ../llama.cpp ../ggml.c ../utils.cpp)
13+
add_subdirectory(vendor/llama.cpp)
14+
add_library(llamacpp MODULE src/PyLlama.cpp)
1415

15-
target_include_directories(llamacpp PRIVATE ../)
16-
17-
target_link_libraries(llamacpp PRIVATE pybind11::module pybind11::lto pybind11::windows_extras)
16+
target_include_directories(llamacpp PRIVATE vendor/llama.cpp)
17+
target_link_libraries(llamacpp PRIVATE pybind11::module pybind11::lto pybind11::windows_extras llamalib)
1818
add_link_options(-no_fixup_chains)
1919
pybind11_extension(llamacpp)
2020

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1+
## Python bindings for llama.cpp
2+
13
## Building the Python bindings
24

35
### macOS
46

5-
`brew install pybind11`
6-
7-
## Install python package
8-
9-
### From PyPI
10-
117
```
12-
pip install llamacpp
8+
brew install pybind11 # Installs dependency
9+
git submodule init && git submodule update
10+
poetry install
1311
```
14-
15-
### From source
12+
### From PyPI
1613

1714
```
18-
poetry install
15+
pip install llamacpp
1916
```
2017

2118
## Get the model weights
@@ -32,25 +29,16 @@ Convert the weights to GGML format using `llamacpp-convert`. Then use `llamacpp-
3229
```
3330
llamacpp-convert ./models/7B/ 1
3431
llamacpp-quantize ./models/7B/
32+
llamacpp-cli
3533
```
3634

37-
## Run this demo script
35+
## Command line interface
3836

39-
```
40-
import llamacpp
41-
import os
37+
The package installs the command line entry point `llamacpp-cli` that points to `llamacpp/cli.py` and should provide about the same functionality as the `main` program in the original C++ repository. There is also an experimental `llamacpp-chat` that is supposed to bring up a chat interface but this is not working correctly yet.
4238

43-
model_path = "./models/7B/ggml-model-q4_0.bin"
44-
params = llamacpp.gpt_params(model_path,
45-
"Hi, I'm a llama.",
46-
4096,
47-
40,
48-
0.1,
49-
0.7,
50-
2.0)
51-
model = llamacpp.PyLLAMA(model_path, params)
52-
model.predict("Hello, I'm a llama.", 10)
53-
```
39+
## Demo script
40+
41+
See `llamacpp/cli.py` for a detailed example. The simplest demo would be something like the following:
5442

5543
## ToDo
5644

build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from setuptools_cpp import CMakeExtension, ExtensionBuilder, Pybind11Extension
1+
from setuptools_cpp import CMakeExtension, ExtensionBuilder
22
from typing import Any, Dict
33

44

55
def build(setup_kwargs: Dict[str, Any]) -> None:
66
ext_modules = [
7-
CMakeExtension(f"llamacpp.llamacpp", sourcedir="./python"),
7+
CMakeExtension("llamacpp.llamacpp", sourcedir="."),
88
]
99

1010
setup_kwargs.update(

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ version = "0.1.5"
44
description = "Python bindings for @ggerganov's llama.cpp"
55
authors = ["Thomas Antony <[email protected]>"]
66
license = "MIT"
7-
readme = "python/README.md"
8-
packages = [{ include = "llamacpp", from = "python" }]
7+
readme = "README.md"
8+
homepage = "https://github.com/thomasantony/llamacpp-python"
9+
repository = "https://github.com/thomasantony/llamacpp-python"
10+
packages = [{ include = "llamacpp", from = "." }]
911

1012
[tool.poetry.dependencies]
1113
python = "^3.10"

0 commit comments

Comments
 (0)