Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
llama.cpp
Software library for LLM inference

llama.cpp is an open source software library that performs inference on various large language models such as Llama. It is co-developed alongside the GGML project, a general-purpose tensor library.

Command-line tools are included with the library, alongside a server with a simple web interface.

Related Image Collections Add Image
We don't have any YouTube videos related to llama.cpp yet.
We don't have any PDF documents related to llama.cpp yet.
We don't have any Books related to llama.cpp yet.
We don't have any archived web articles related to llama.cpp yet.

Background

Towards the end of September 2022, Georgi Gerganov started work on the GGML library, a C library implementing tensor algebra. Gerganov developed the library with the intention of strict memory management and multi-threading. The creation of GGML was inspired by Fabrice Bellard's work on LibNC.6

Before llama.cpp, Gerganov worked on a similar library called whisper.cpp which implemented Whisper, a speech to text model by OpenAI.7

Development

llama.cpp began development in March 2023 by Georgi Gerganov as an implementation of the Llama inference code in pure C/C++ with no dependencies. This improved performance on computers without GPU or other dedicated hardware, which was a goal of the project.8910 llama.cpp gained traction with users who lacked specialized hardware as it could run on just a CPU including on Android devices.111213 While initially designed for CPUs, GPU inference support was later added.14 As of November 2024 it has more than 67,000 stars on GitHub.15

In March 2024 Justine Tunney introduced new optimized matrix multiplication kernels for x86 and ARM CPUs, improving prompt evaluation performance for FP16 and 8-bit quantized data types.16 These improvements were committed upstream to llama.cpp.17 Tunney also created a tool called llamafile that bundles models and llama.cpp into a single file that runs on multiple operating systems via the Cosmopolitan Libc library also created by Tunney which allows C/C++ to be more portable across operating systems.18

Architecture

llama.cpp supports multiple hardware targets including x86, ARM, CUDA, Metal, Vulkan (version 1.2 or greater) and SYCL.19202122 These back-ends make up the GGML tensor library which is used by the front-end model-specific llama.cpp code.23 llama.cpp supports ahead of time model quantization as opposed to on-the-fly quantization.24 llama.cpp makes use of several CPU extensions for optimization: AVX, AVX2 and AVX-512 for X86-64, and Neon on ARM. Apple silicon is an important target for the project.2526 It supports grammar-based output formatting as JSON.27 It also supports speculative decoding.28

GGUF file format

The GGUF (GGML Universal File)29 file format is a binary format that stores both tensors and metadata in a single file, and is designed for fast saving, and loading of model data.30 It was introduced in August 2023 by the llama.cpp project to better maintain backwards compatibility as support was added for other model architectures.3132 It superseded previous formats used by the project such as GGML.

GGUF files are typically created by converting models developed with a different machine learning library such as PyTorch.33

Design

The format focuses on quantization, the act of reducing precision in the model weights. This can lead to reduced memory usage, and increased speed at the expense of lower model accuracy.3435

GGUF supports 2-bit to 8-bit quantized integer types;36 common floating-point data formats such as float32, float16, and bfloat16; and 1.56 bit quantization.37

This file format contains information necessary for running a GPT-like language model such as the tokenizer vocabulary, context length, tensor info and other attributes.38

Supported models

References

  1. Connatser, Matthew. "How this open source LLM chatbot runner hit the gas on x86, Arm CPUs". theregister.com. Retrieved 15 April 2024. https://www.theregister.com/2024/04/03/llamafile_performance_gains/

  2. Gerganov, Georgi (17 May 2024). "ggerganov/ggml". GitHub. https://github.com/ggerganov/ggml

  3. Mann, Tobias (14 Jul 2024). "Honey, I shrunk the LLM! A beginner's guide to quantization – and testing it". theregister. https://www.theregister.com/2024/07/14/quantization_llm_feature/

  4. Alden, Daroc. "Portable LLMs with llamafile [LWN.net]". lwn.net. Retrieved 30 July 2024. https://lwn.net/Articles/971195/

  5. Mann, Tobias (15 December 2024). "Intro to speculative decoding: Cheat codes for faster LLMs". theregister. https://www.theregister.com/2024/12/15/speculative_decoding/

  6. "Bringing Whisper and LLaMA to the masses with Georgi Gerganov (Changelog Interviews #532)". Changelog. 22 March 2023. Retrieved 28 July 2024. https://changelog.com/podcast/532

  7. "ggerganov/whisper.cpp". GitHub. https://github.com/ggerganov/whisper.cpp

  8. Connatser, Matthew. "How this open source LLM chatbot runner hit the gas on x86, Arm CPUs". theregister.com. Retrieved 15 April 2024. https://www.theregister.com/2024/04/03/llamafile_performance_gains/

  9. Edwards, Benj (13 March 2023). "You can now run a GPT-3-level AI model on your laptop, phone, and Raspberry Pi". arstechnica.com. Retrieved 15 April 2024. https://arstechnica.com/information-technology/2023/03/you-can-now-run-a-gpt-3-level-ai-model-on-your-laptop-phone-and-raspberry-pi/

  10. Wiest, Isabella Catharina; Ferber, Dyke; Zhu, Jiefu; van Treeck, Marko; Meyer, Meyer, Sonja K.; Juglan, Radhika; Carrero, Zunamys I.; Paech, Daniel; Kleesiek, Jens; Ebert, Matthias P.; Truhn, Daniel; Kather, Jakob Nikolas (2024). "Privacy-preserving large language models for structured medical information retrieval". npj Digital Medicine. 7 (257): 257. doi:10.1038/s41746-024-01233-2. PMC 11415382. PMID 39304709.{{cite journal}}: CS1 maint: multiple names: authors list (link) https://www.ncbi.nlm.nih.gov/pmc/articles/PMC11415382

  11. Edwards, Benj (13 March 2023). "You can now run a GPT-3-level AI model on your laptop, phone, and Raspberry Pi". arstechnica.com. Retrieved 15 April 2024. https://arstechnica.com/information-technology/2023/03/you-can-now-run-a-gpt-3-level-ai-model-on-your-laptop-phone-and-raspberry-pi/

  12. Hood, Stephen. "llamafile: bringing LLMs to the people, and to your own computer". Mozilla Innovations. Retrieved 28 July 2024. https://future.mozilla.org/builders/news_insights/introducing-llamafile/

  13. "Democratizing AI with open-source language models". lwn.net. Retrieved 28 July 2024. https://lwn.net/Articles/931853/

  14. Rajput, Saurabhsingh; Sharma, Tushar (4 June 2024). "Benchmarking Emerging Deep Learning Quantization Methods for Energy Efficiency". 2024 IEEE 21st International Conference on Software Architecture Companion (ICSA-C). pp. 238–242. doi:10.1109/ICSA-C63560.2024.00049. ISBN 979-8-3503-6625-9. 979-8-3503-6625-9

  15. "ggerganov/llama.cpp". GitHub. https://github.com/ggerganov/llama.cpp

  16. Connatser, Matthew. "Llamafile LLM driver project boosts performance on CPU cores". www.theregister.com. Retrieved 10 May 2024. https://www.theregister.com/2024/04/03/llamafile_performance_gains/

  17. Connatser, Matthew. "Llamafile LLM driver project boosts performance on CPU cores". www.theregister.com. Retrieved 10 May 2024. https://www.theregister.com/2024/04/03/llamafile_performance_gains/

  18. Connatser, Matthew. "Llamafile LLM driver project boosts performance on CPU cores". www.theregister.com. Retrieved 10 May 2024. https://www.theregister.com/2024/04/03/llamafile_performance_gains/

  19. Gerganov, Georgi; Nguyen, Xuan Son; Slaren (August 13, 2024). "Introduction to ggml". Huggingface. https://huggingface.co/blog/introduction-to-ggml

  20. Kluska, Piotr; Castell´o, Adri´an; Scheidegger, Florian; I. Malossi, A. Cristiano; Quintana-Ort´ı, Enrique (June 2024). "QAttn: Efficient GPU Kernels for mixed-precision Vision Transformers" (PDF). Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops. https://openaccess.thecvf.com/content/CVPR2024W/ELVM/papers/Kluska_QAttn_Efficient_GPU_Kernels_for_Mixed-precision_Vision_Transformers_CVPRW_2024_paper.pdf

  21. Jianyu, Zhang; Hengyu, Meng; Ying, Hu; Yu, Luo; Xiaoping, Duan; Corporation, Majumder Abhilash Intel (July 2024). "Run LLMs on Intel GPUs Using llama.cpp". The Parallel Universe. No. 57. Intel. pp. 34–37. https://www.intel.com/content/www/us/en/developer/articles/technical/run-llms-on-gpus-using-llama-cpp.html

  22. Bolz, Jeff (February 11–13, 2025). "Machine Learning in Vulkan with Cooperative Matrix 2" (PDF). Cambridge, UK: The Khronos Group/Nvidia. https://vulkan.org/user/pages/09.events/vulkanised-2025/T47-Jeff-Bolz-NVIDIA.pdf

  23. Pounder, Les (25 March 2023). "How To Create Your Own AI Chatbot Server With Raspberry Pi 4". tomshardware.com. Retrieved 16 April 2024. https://www.tomshardware.com/how-to/create-ai-chatbot-server-on-raspberry-pi

  24. Walkowiak, Bartosz; Walkowiak, Tomasz (2024). "Implementation of language models within an infrastructure designed for Natural Language Processing" (PDF). International Journal of Electronics and Telecommunications. 70 (1): 153–159. doi:10.24425/ijet.2024.149525. Retrieved 8 May 2024. https://journals.pan.pl/Content/130704/18_4466_Walkowiak_L_sk.pdf

  25. "ggerganov/llama.cpp". GitHub. https://github.com/ggerganov/llama.cpp

  26. Larabel, Michael. "Llamafile 0.7 Brings AVX-512 Support: 10x Faster Prompt Eval Times For AMD Zen 4". www.phoronix.com. https://www.phoronix.com/news/Llamafile-0.7

  27. Wiest, Isabella Catharina; Ferber, Dyke; Zhu, Jiefu; van Treeck, Marko; Meyer, Meyer, Sonja K.; Juglan, Radhika; Carrero, Zunamys I.; Paech, Daniel; Kleesiek, Jens; Ebert, Matthias P.; Truhn, Daniel; Kather, Jakob Nikolas (2024). "Privacy-preserving large language models for structured medical information retrieval". npj Digital Medicine. 7 (257): 257. doi:10.1038/s41746-024-01233-2. PMC 11415382. PMID 39304709.{{cite journal}}: CS1 maint: multiple names: authors list (link) https://www.ncbi.nlm.nih.gov/pmc/articles/PMC11415382

  28. Mann, Tobias (15 December 2024). "Intro to speculative decoding: Cheat codes for faster LLMs". theregister. https://www.theregister.com/2024/12/15/speculative_decoding/

  29. "ggerganov/llama.cpp/gguf-py/README.md". GitHub. Retrieved 10 November 2024. https://github.com/ggerganov/llama.cpp/blob/master/gguf-py/README.md

  30. "GGUF". huggingface.co. Retrieved 9 May 2024. https://huggingface.co/docs/hub/gguf

  31. Rajput, Saurabhsingh; Sharma, Tushar (4 June 2024). "Benchmarking Emerging Deep Learning Quantization Methods for Energy Efficiency". 2024 IEEE 21st International Conference on Software Architecture Companion (ICSA-C). pp. 238–242. doi:10.1109/ICSA-C63560.2024.00049. ISBN 979-8-3503-6625-9. 979-8-3503-6625-9

  32. Mucci, Tim (3 July 2024). "GGUF versus GGML". www.ibm.com. Retrieved 26 July 2024. https://www.ibm.com/think/topics/gguf-versus-ggml

  33. "GGUF". huggingface.co. Retrieved 9 May 2024. https://huggingface.co/docs/hub/gguf

  34. Labonne, Maxime (29 November 2023). "Quantize Llama models with GGUF and llama.cpp". Medium. Towards Data Science. Retrieved 9 May 2024. https://towardsdatascience.com/quantize-llama-models-with-ggml-and-llama-cpp-3612dfbcc172

  35. Mucci, Tim (3 July 2024). "GGUF versus GGML". www.ibm.com. Retrieved 26 July 2024. https://www.ibm.com/think/topics/gguf-versus-ggml

  36. Cabezas, Darío; Fonseca-Delgado, Rigoberto; Reyes-Chacón, Iván; Vizcaino-Imacaña, Paulina; Morocho-Cayamcela, Manuel (2024). "Integrating a LLaMa-based Chatbot with Augmented Retrieval Generation as a Complementary Educational Tool for High School and College Students". Proceedings of the 19th International Conference on Software Technologies. pp. 395–402. doi:10.5220/0012763000003753. ISBN 978-989-758-706-1. 978-989-758-706-1

  37. Mann, Tobias (14 Jul 2024). "Honey, I shrunk the LLM! A beginner's guide to quantization – and testing it". theregister. https://www.theregister.com/2024/07/14/quantization_llm_feature/

  38. Dong, Bo; Lin, Jun; Yu, Zhentao; Xu, Zhenzhong; Luo, Yu; Chang, Hanwen; Shen, Haihao (July 2024). "Accelerating GGUF Models with Transformers". The Parallel Universe. No. 57. Intel. pp. 28–33. https://www.intel.com/content/www/us/en/developer/articles/technical/accelerate-gguf-models-with-transformers.html