Documentation

Hesper.GGUF.Parser

GGUF Binary Parser #

Binary parser for GGUF v3 format files. Uses single ByteArray with offset tracking (following gemma.hs pattern for efficiency).

Design Principles #

  1. Single Buffer Allocation: Pin ByteArray once, pass offsets
  2. Zero-Copy: Extract sub-arrays without copying when possible
  3. Bounds Checking: Return Except for all parsing operations
  4. Little-Endian: All integers are stored in little-endian format

References #

Low-level Binary Reading Utilities #

Read UInt8 from ByteArray at offset

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Read UInt16 (little-endian) from ByteArray

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Read UInt32 (little-endian) from ByteArray

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Read UInt64 (little-endian) from ByteArray

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Read Int32 (little-endian) from ByteArray

          Equations
          Instances For

            Read Int64 (little-endian) from ByteArray

            Equations
            Instances For

              Read Float32 (IEEE 754, little-endian) from ByteArray

              Equations
              Instances For

                Read string (length-prefixed) from ByteArray

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  GGUF Header Parsing #

                  Parse GGUF header (24 bytes)

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    Metadata Parsing #

                    Parse a single metadata value (simplified - stores raw bytes)

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Parse single metadata key-value pair

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        Parse all metadata key-value pairs

                        Equations
                        Instances For

                          Tensor Info Parsing #

                          Parse dimensions array

                          Equations
                          Instances For
                            @[irreducible]
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              Parse single tensor info

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                Parse all tensor infos

                                Equations
                                Instances For

                                  Complete GGUF File Parsing #

                                  def Hesper.GGUF.Parser.alignmentPadding (offset : Nat) (alignment : UInt32) :

                                  Calculate alignment padding

                                  Equations
                                  Instances For

                                    Parse complete GGUF file

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For