gguf-py readme example fixes for keys: general.architecture and general.alignment

This commit is contained in:
jay-johnson 2023-11-13 17:44:30 +00:00
parent bd90eca237
commit eda5614f41
2 changed files with 7 additions and 2 deletions

View file

@ -15,7 +15,6 @@ def writer_example() -> None:
# Example usage with a file
gguf_writer = GGUFWriter("example.gguf", "llama")
gguf_writer.add_architecture()
gguf_writer.add_block_count(12)
gguf_writer.add_uint32("answer", 42) # Write a 32-bit integer
gguf_writer.add_float32("answer_in_float", 42.0) # Write a 32-bit float

View file

@ -107,7 +107,13 @@ class GGUFReader:
offs, tensors_fields = self._build_tensors_fields(offs, tensor_count)
new_align = self.fields.get('general.alignment')
if new_align is not None:
if new_align.types != [GGUFValueType.UINT64]:
if (
(
new_align.types != [GGUFValueType.UINT64]
) and (
new_align.types != [GGUFValueType.UINT32]
)
):
raise ValueError('Bad type for general.alignment field')
self.alignment = new_align.parts[-1][0]
padding = offs % self.alignment