Jump to content

llama.cpp

From Wikipedia, the free encyclopedia
(Redirected from GGUF)
llama.cpp
Original author(s)Georgi Gerganov
Developer(s)Georgi Gerganov and community
Initial releaseMarch 10, 2023; 20 months ago (2023-03-10)[1]
Repositorygithub.com/ggerganov/llama.cpp
Written inC++, C
TypeLibrary for large language models
LicenseMIT License[2]

llama.cpp is an open source software library written mostly in C++ that performs inference on various large language models such as Llama.[3] It is co-developed alongside the GGML project, a general-purpose tensor library.[4]

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

Background

[edit]

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.[7]

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

Gerganov has a background in medical physics, and was part of the Faculty of Physics in Sofia University.[9] In 2006 he won a silver medal in the International Physics Olympiad.[10][11] In 2008 he won a programming competition organized by the Bulgarian Association of Software Companies, PC Magazine and Musala Soft, a Bulgarian software services company.[12]

Development

[edit]

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.[3][13][14] llama.cpp gained traction with users who lacked specialized hardware as it could run on just a CPU including on Android devices.[13][15][16] While initially designed for CPUs, GPU inference support was later added.[17] As of November 2024 it has more than 67,000 stars on GitHub.[18]

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.[19] These improvements were committed upstream to llama.cpp.[19] 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.[19]

Architecture

[edit]

llama.cpp supports multiple hardware targets including x86 ARM, CUDA, Metal, Vulkan and SYCL.[20][21][22][23] These back-ends make up the GGML tensor library which is used by the front-end model-specific llama.cpp code.[24] llama.cpp supports ahead of time model quantization as opposed to on-the-fly quantization.[25] 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.[18][26] It supports grammar-based output formatting as JSON.[14]

GGUF file format

[edit]
GGUF
Filename extension.gguf
Magic number0x47 0x47 0x55 0x46
Developed byGeorgi Gerganov and community
Initial releaseAugust 22, 2023; 14 months ago (2023-08-22)[27]
Latest release
v3[28]
Type of formatMachine-learning tensors

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.[17][31] It succeeded previous formats used by the project such as GGML (GPT-Generated Model Language).

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

Design

[edit]

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.[32][31]

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

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.[34]

Supported models

[edit]

References

[edit]
  1. ^ "Initial release · ggerganov/llama.cpp@26c0846". GitHub. Retrieved 15 May 2024.
  2. ^ "llama.cpp/LICENSE at master · ggerganov/llama.cpp". GitHub.
  3. ^ a b Connatser, Matthew. "How this open source LLM chatbot runner hit the gas on x86, Arm CPUs". theregister.com. Retrieved 15 April 2024.
  4. ^ Gerganov, Georgi (17 May 2024). "ggerganov/ggml". GitHub.
  5. ^ a b Mann, Tobias (14 Jul 2024). "Honey, I shrunk the LLM! A beginner's guide to quantization – and testing it". theregister.
  6. ^ Alden, Daroc. "Portable LLMs with llamafile [LWN.net]". lwn.net. Retrieved 30 July 2024.
  7. ^ "Bringing Whisper and LLaMA to the masses with Georgi Gerganov (Changelog Interviews #532)". Changelog. 22 March 2023. Retrieved 28 July 2024.
  8. ^ "ggerganov/whisper.cpp". GitHub.
  9. ^ Mitev, Krasimir; Gerganov, Georgi; Kirov, Assen S.; Schmidtlein, C. Ross; Madzhunkov, Yordan; Kawrakow, Iwan (21 June 2012). "Influence of photon energy cuts on PET Monte Carlo simulation results: Influence of photon energy cuts". Medical Physics. 39 (7Part1): 4175–4186. doi:10.1118/1.4725168.
  10. ^ Tichy-Rács, Ádám (2015). LIST OF WINNERS IN 1ST – 45TH INTERNATIONAL PHYSICS OLYMPIADS. BME OMIKK. p. 246. ISBN 978-963-593-500-0.
  11. ^ Захариев, Боян (July 21, 2006). "България с 11 медала от международни олимпиади". sega bg.
  12. ^ Станева, Ирина (January 30, 2008). "Студенти от СУ спечелиха конкурса по програмиране на БАСКОМ". karieri.
  13. ^ a b 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.
  14. ^ a b 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). doi:10.1038/s41746-024-01233-2. PMC 11415382.{{cite journal}}: CS1 maint: multiple names: authors list (link)
  15. ^ Hood, Stephen. "llamafile: bringing LLMs to the people, and to your own computer". Mozilla Innovations. Retrieved 28 July 2024.
  16. ^ "Democratizing AI with open-source language models". lwn.net. Retrieved 28 July 2024.
  17. ^ a b 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.
  18. ^ a b "ggerganov/llama.cpp". GitHub.
  19. ^ a b c Connatser, Matthew. "Llamafile LLM driver project boosts performance on CPU cores". www.theregister.com. Retrieved 10 May 2024.
  20. ^ Gerganov, Georgi; Nguyen, Xuan Son; Slaren (August 13, 2024). "Introduction to ggml". Huggingface.
  21. ^ 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.
  22. ^ Fritts, Harold (30 October 2024). "AMD and LM Studio: Making AI Accessible and Fast on x86 Laptops". StorageReview.com.
  23. ^ 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.
  24. ^ Pounder, Les (25 March 2023). "How To Create Your Own AI Chatbot Server With Raspberry Pi 4". tomshardware.com. Retrieved 16 April 2024.
  25. ^ 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.
  26. ^ Larabel, Michael. "Llamafile 0.7 Brings AVX-512 Support: 10x Faster Prompt Eval Times For AMD Zen 4". www.phoronix.com.
  27. ^ "GGUF by ggerganov · Pull Request #2398 · ggerganov/llama.cpp". GitHub.
  28. ^ "ggml/docs/gguf.md at master · ggerganov/ggml". GitHub.
  29. ^ "ggerganov/llama.cpp/gguf-py/README.md". GitHub. Retrieved 10 November 2024.
  30. ^ a b "GGUF". huggingface.co. Retrieved 9 May 2024.
  31. ^ a b Mucci, Tim (3 July 2024). "GGUF versus GGML". www.ibm.com. Retrieved 26 July 2024.
  32. ^ Labonne, Maxime (29 November 2023). "Quantize Llama models with GGUF and llama.cpp". Medium. Towards Data Science. Retrieved 9 May 2024.
  33. ^ 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.
  34. ^ 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.