gguf
Library Listed
GGUF file parser
- Downloads
- 2,472
- Dependents
- 4
- Stars
- 25
- Forks
- 5
- Contributors
- 5
- Commits
- 94
- Latest release
- 0.1.8 ·
About
GGUF-RS
A Rust library for parsing and reading GGUF (GGML Universal Format) files. GGUF files are binary files that contain key-value metadata and tensors, commonly used for storing quantized machine learning models.
Features
- ✅ Decode GGUF files (v1, v2, v3)
- ✅ Access key-value metadata
- ✅ Access tensor information
- ✅ Support for little-endian and big-endian files
- ✅ CLI tool for quick inspection
- ✅ Zero-copy metadata access
- ✅ Memory-mapped file support (optional
mmapfeature) - ✅ Async I/O support (optional
asyncfeature) - ✅ Write GGUF files
Installation
Add to your Cargo.toml:
[dependencies]
gguf-rs = "0.1"
Or install the CLI tool:
cargo install gguf-rs
Usage
Library
Basic usage:
use gguf_rs::get_gguf_container;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Open a GGUF file
let mut container = get_gguf_container("model.gguf")?;
let model = container.decode()?;
// Print model info
println!("GGUF version: {}", model.get_version());
println!("Architecture: {}", model.model_family());
println!("Parameters: {}", model.model_parameters());
println!("File type: {}", model.file_type());
println!("Number of tensors: {}", model.num_tensor());
Ok(())
}
Read the full README
Access specific metadata:
use gguf_rs::get_gguf_container;
let mut container = get_gguf_container("model.gguf")?;
let model = container.decode()?;
// Get specific metadata values
let metadata = model.metadata();
if let Some(arch) = metadata.get("general.architecture") {
println!("Architecture: {}", arch);
}
// Check context length
if let Some(ctx_len) = metadata.get("llama.context_length") {
println!("Context length: {}", ctx_len);
}
Work with tensors:
use gguf_rs::get_gguf_container;
let mut container = get_gguf_container("model.gguf")?;
let model = container.decode()?;
// List all tensors
for tensor in model.tensors() {
println!("{}: shape={:?}, offset={}, size={}",
tensor.name, tensor.shape, tensor.offset, tensor.size);
}
// Find specific tensor
let embed_tensor = model.tensors()
.iter()
.find(|t| t.name.contains("token_embd"));
if let Some(tensor) = embed_tensor {
println!("Embedding tensor shape: {:?}", tensor.shape);
}
Read full tokenizer vocabulary:
use gguf_rs::get_gguf_container_array_size;
// Use get_gguf_container_array_size to read full arrays
// (default get_gguf_container truncates arrays to 3 elements)
let mut container = get_gguf_container_array_size("model.gguf", u64::MAX)?;
let model = container.decode()?;
// Now you can access full tokenizer arrays
let metadata = model.metadata();
if let Some(tokens) = metadata.get("tokenizer.ggml.tokens") {
println!("Vocabulary size: {:?}", tokens);
}
CLI
Show model metadata:
gguf path_to_your_model.gguf
Show tensors:
gguf path_to_your_model.gguf --tensors
Supported GGML Types
| Type | Description |
|---|---|
| F32 | 32-bit float |
| F16 | 16-bit float |
| Q4_0 | 4-bit quantization (type 0) |
| Q4_1 | 4-bit quantization (type 1) |
| Q5_0 | 5-bit quantization (type 0) |
| Q5_1 | 5-bit quantization (type 1) |
| Q8_0 | 8-bit quantization (type 0) |
| Q2_K - Q6_K | K-quant types |
| IQ series | I-quant types (IQ1_S, IQ2_XXS, etc.) |
| BF16 | Brain float 16 |
API Documentation
Full API documentation is available at docs.rs/gguf-rs.
Performance
- Zero-copy metadata access: Metadata is parsed once and stored in memory for fast repeated access
- Lazy tensor data: Tensor metadata is parsed, but actual tensor data is not loaded into memory
- Array truncation: By default, arrays in metadata are truncated to 3 elements for performance. Use
get_gguf_container_array_size()withu64::MAXto read full arrays when needed
Memory Usage
The library has minimal memory overhead:
- Metadata storage: O(n_kv + n_tensors) where n_kv = number of key-value pairs, n_tensors = number of tensors
- No tensor data is loaded into memory unless explicitly requested
Memory-Mapped Files
For large GGUF files (multiple GB), use the mmap feature for efficient access:
[dependencies]
gguf-rs = { version = "0.1", features = ["mmap"] }
use gguf_rs::mmap::MmapGGUF;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mmap = MmapGGUF::open("large_model.gguf")?;
let model = mmap.decode()?;
println!("Architecture: {}", model.model_family());
println!("Tensors: {}", model.num_tensor());
Ok(())
}
Benefits of memory mapping:
- Lazy loading: Only accessed pages are loaded into memory
- OS-managed paging: The operating system handles memory management
- Fast random access: Direct pointer access to file data
Async I/O
For async applications, enable the async feature:
[dependencies]
gguf-rs = { version = "0.1", features = ["async"] }
use gguf_rs::async_io::AsyncGGUF;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut container = AsyncGGUF::open("model.gguf").await?;
let model = container.decode().await?;
println!("Architecture: {}", model.model_family());
println!("Tensors: {}", model.num_tensor());
Ok(())
}
Writing GGUF Files
Create and write GGUF files:
use gguf_rs::writer::{GGUFWriter, TensorInfo};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create writer for GGUF v3
let mut writer = GGUFWriter::new("output.gguf", 3)?;
// Add metadata
writer.add_metadata("general.architecture", "llama");
writer.add_metadata_u32("llama.block_count", 12);
writer.add_metadata_f32("test.value", 3.14);
// Add tensor info
let tensor = TensorInfo {
name: "token_embd.weight".to_string(),
shape: vec![4096, 32000],
dtype: 0, // F32
};
writer.add_tensor(tensor);
// Write header and metadata
writer.write()?;
// Write tensor data
let data: Vec<u8> = vec![0; 4096 * 32000 * 4]; // F32 = 4 bytes
writer.write_tensor_data(0, &data)?;
// Finalize
writer.finalize()?;
Ok(())
}
Compatibility
- Rust version: Requires Rust 1.56+ (edition 2021)
- GGUF versions: Supports v1, v2, and v3
- Byte order: Both little-endian and big-endian files
- Platforms: Works on all platforms supported by Rust (Linux, macOS, Windows, BSD, etc.)
Testing
cargo test
Benchmarks
Run performance benchmarks:
cargo bench
Benchmarks measure:
- File parsing performance
- Metadata access speed
- Tensor iteration overhead
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and clippy
- Submit a pull request
Security
Please report security vulnerabilities to zackshen0526@gmail.com. See SECURITY.md for more information.
GGUF Specification
This library implements the GGUF specification.
License
MIT License - see LICENSE for details.
Credits
- GGUF format by ggml
- Contributors: @AvivAbachi, @jbooth, @Knight-Ops
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- None found
- No native code found
- Python bindings
- No Python binding crate found
- License
- MIT
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
GGUF file parser |
2,472 downloads over 30 days | 4 | 25 | 0.1.8 | GPU support unknown | No native code found | MIT |
|
safetensors Featured
Provides functions to read and write safetensors which aim to be safer than their PyTorch counterpart. |
5,486,837 downloads over 30 days | 531 | 3,943 | 0.8.0 | GPU support unknown | No native code found | Apache-2.0 |
|
onnx-extractor Listed
Minimal ONNX model loader for extracting weights, tensors, operations, and graph structure |
3,975 downloads over 30 days | 4 | 6 | 0.5.2 | GPU support unknown | No native code found | MIT |
|
onnx-rs Listed
Zero-dependency ONNX model parser in Rust |
453 downloads over 30 days | 5 | 6 | 0.1.3 | GPU support unknown | No native code found | MIT |
|
One backbone, many specialists. CMF is a self-describing, memory-mappable single-file format and a dependency-free runtime for quantized LLMs — zero-copy execution on CPU or GPU (Vulkan · Metal · DX12) that overlays task-specialized skills onto one shared model, with no per-model duplication. |
24 binary downloads per release | Not applicable | 52 | Not measured | Not measured | Apache-2.0 | |
|
Model conversion and quantization with no Python: reads SafeTensors, GGUF, TCF and PyTorch state dicts, writes SafeTensors, GGUF and TCF, and quantizes to Q2_K through Q8_0 and IQ4 formats, including Q4_K_M mixes. GPTQ, AWQ, NF4, FP8, EXL2 and ONNX input are not implemented. Python bindings |
23 downloads over 30 days | Not applicable | 0 | 0.2.1 | GPU support unknown | No native code found | Apache-2.0 |
All projects in Datasets and model formatsAll projects in Run and serve models
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 3 active dependents and 3 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 25 stars, 5 forks and 5 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.
What else the check found
- The last activity is on 15 Jun 2026, 147 days ago. The rules expect an update within 400 days. Dormancy rule
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.1.8 base 450, capped at 8 releases = 400: E = 400 daysdormancy: last activity 2026-06-15, 147 days ago, E = 400: activefeatured: not featured: active_users 3 < 11 and new_adopters 3 < 9 and repository route stars 25 (needs 4539), forks 5 (needs 434), contributors 5 (needs 79)listed: listed: no archive, new or featured rule applies
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption3 active dependents, 3 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 3 | crates.io database dump | Yes | |
| New dependents (365 days) | 3 | crates.io database dump | Yes | |
| Peak active dependents | 3 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 4 months ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2026-06-15 | GitHub repository | Yes | |
| Latest release | 2026-06-15 | crates.io database dump | Yes | |
| First release | 2024-01-04 | crates.io database dump | Yes | |
| Latest version | 0.1.8 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 90 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 6 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution8 releases, 2,472 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 8 | crates.io database dump | Yes | |
| Downloads over 30 days | 2472 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository25 stars, 5 forks, 5 contributors, 94 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 25 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 5 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 5 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 94 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | MIT | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | No native code found | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | No Python binding crate found | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 4 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.