MyNixOS website logo
Description

Haskell FFI bindings to the llama.cpp LLM inference library.

Haskell bindings for llama.cpp, a performant, C++-based inference engine for running large language models (LLMs) like LLaMA, Mistral, Qwen, and others directly on local hardware.

llama-cpp-hs

Haskell bindings over llama.cpp

This package provides both low-level and high-level interfaces to interact with the LLaMA C++ inference engine via Haskell FFI. It allows you to run LLMs locally in pure C/C++, with support for GPU acceleration and quantized models.

Features

  • Low-level access to the full LLaMA C API using Haskell FFI.
  • Higher-level convenience functions for easier model interaction.
  • Examples provided for quickly getting started.

Example Usage

Check out the /examples directory to see how to load and query models directly from Haskell.


Setup

1. Using Nix (Recommended)

Ensure that Nix is installed on your system.

Then, enter the development shell:

nix-shell

Build the project using Stack:

stack build

2. Using Stack (Manual Setup)

If you prefer not to use Nix, follow these steps:

  1. Clone and install llama.cpp manually.
  2. Make sure llama.h is available at /usr/local/include/ and compiled libllama.a or libllama.so at /usr/local/lib/.
  3. Install Stack if you haven’t already: https://docs.haskellstack.org/en/stable/install_and_upgrade/
  4. Then proceed with:
stack build

Models

To use this library, you'll need to download one of the many open-source GGUF models available on Hugging Face

Search for compatible GGUF models:


Current State

The codebase is still under active development and may undergo breaking changes. Use it with caution in production environments.

Pull requests, issues, and community contributions are highly encouraged!


Contributing

Contributions are welcome!


License

This project is licensed under MIT.


Thank You

Thanks to ggml-org/llama.cpp for making local LLM inference fast, lightweight, and accessible!

Metadata

Version

0.1.0.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows