Skip to content

jkrukowski/swift-gguf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swift-gguf

A parser for the GGUF file format. Done using swift-binary-parsing.

Usage

let fileData = try Data(contentsOf: url, options: .mappedIfSafe)
let gguf = try GGUF(parsing: fileData)
print("Version: \(gguf.header.version)")
print("Tensors: \(gguf.tensorInfos.count)")

// Access metadata
if let modelName = gguf.metadataValue(forKey: "general.name") {
    print("Model: \(modelName)")
}

// Load float array
let tensor = try gguf.tensorFloatArray(at: 0, from: fileData)

Acknowledgements

This project uses some of the code from:

Code Formatting

This project uses swift-format. To format the code run:

swift format . -i -r --configuration .swift-format

About

A parser for the GGUF file format. Done using swift-binary-parsing.

Topics

Resources

License

Stars

Watchers

Forks

Contributors