YALS contains two components:
- TypeScript code: Universally buildable on any OS
- C++ bindings: Requires an OS-specific C++ compiler and additional setup
The C++ bindings need to be built to integrate the llama.cpp library and provide the necessary "glue" required by YALS.
To get started, install the following prerequisites:
- Deno
- A C++ compiler:
- Windows: Visual Studio 2022 build tools
- macOS: Xcode command-line tools (
xcode-select --install) - Linux: GCC (
sudo apt install build-essential)
- CMake:
- Windows: Installed with Visual Studio build tools
- macOS (homebrew):
brew install cmake - Linux:
sudo apt install cmake(For Ubuntu 22.04, follow this askubuntu answer to install the latest version)
- Ninja (Makes builds faster)
- Windows:
winget install -e --id Ninja-build.Ninja - macOS (homebrew):
brew install ninja - Linux:
sudo apt install ninja-build
- Windows:
- sccache (optional, but speeds up subsequent builds)
- Rust(Used for improved grammar parsing via LLGuidance)
Clone the repository and navigate to the project folder:
git clone https://github.com/theroyallab/YALS.git
cd YALSAll build commands are encapsulated in Deno tasks, similar to npm scripts in NodeJS.
Note
Unlike llama.cpp and its derivatives, YALS uses an extremely fast grammar tool called llguidance for JSON schemas, Regex, and lark grammars.
Due to an extra dependency being required for users systems, llguidance is off by default, but it is highly recommended to turn it on at build time for improved grammar handling.
To enable it, set LLGUIDANCE=1 in your shell before invoking the deno task.
To build the C++bindings:
- Windows:
deno task bindings-win - macOS/Linux:
deno task bindings
This will invoke CMake to build the bindings and copy the resulting shared libraries to the lib folder.
Optionally, environment variables can be set for certain architectures when building (ex. CUDA):
MAX_JOBS: Number of parallel jobs (defaults to the number of CPU cores)LLAMACPP_REPO: Point to a custom repository for llama.cpp (Here be dragons!)LLAMACPP_TAG: Set a specific tag for llama.cpp (Here be dragons!)GGML_CUDA=1: Enables CUDA supportCMAKE_CUDA_ARCHITECTURES: Specifies CUDA compute capabilities (defaults tonativeif using CMake > 3.24)GGML_VULKAN=1: Enables Vulkan SupportGGML_HIP=1: Enables HIP ROCM Support (Requires specifying DAMDGPU_TARGETS, Linux only)AMDGPU_TARGETS: Specify ROCM target (example:gfx1030)GGML_SYCL=1: Enables SYCL support for Intel ARC GPUs (Make sure to runsource /opt/intel/oneapi/setvars.shto setup the build environment)LLGUIDANCE=1: (Recommended) Enable llguidance for grammars. Requires Rust on the system. (default0)
To start the server with necessary permissions:
deno task startWith full permissions (useful for testing new features):
deno run -A main.tsNote
Note: All YALS commits are built via GitHub Actions, so manual packaging is typically unnecessary unless you need to distribute builds with a custom build configuration.
To create a distributable binary:
- Run:
deno task buildto package all TypeScript code into a standalone binary - Zip the following files and directories:
YALS(.exe)lib/models/templates/config_sample.yml
- Distribute the archive, and the recipient can simply extract and run it.