[gguf] Add git commit hash
This commit is contained in:
parent
684686eadb
commit
398bedb287
2 changed files with 10 additions and 1 deletions
|
@ -16,6 +16,7 @@ import pickle
|
|||
import re
|
||||
import signal
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
import numpy as np
|
||||
|
@ -735,7 +736,8 @@ class OutputFile:
|
|||
|
||||
def add_meta_arch(self, params: Params) -> None:
|
||||
self.gguf.add_name ("LLaMA")
|
||||
self.gguf.add_date(datetime.today().isoformat())
|
||||
self.gguf.add_date (datetime.today().isoformat())
|
||||
self.gguf.add_commit_hash (get_git_revision_short_hash())
|
||||
self.gguf.add_context_length (params.n_ctx)
|
||||
self.gguf.add_embedding_length (params.n_embd)
|
||||
self.gguf.add_block_count (params.n_layer)
|
||||
|
@ -1002,6 +1004,9 @@ def do_dump_model(model_plus: ModelPlus) -> None:
|
|||
print(f"{name}: shape={lazy_tensor.shape} type={lazy_tensor.data_type}; {lazy_tensor.description}")
|
||||
|
||||
|
||||
def get_git_revision_short_hash() -> str:
|
||||
return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
|
||||
|
||||
def main(args_in: Optional[List[str]] = None) -> None:
|
||||
parser = argparse.ArgumentParser(description="Convert a LLaMa model to a GGML compatible file")
|
||||
parser.add_argument("--dump", action="store_true", help="don't convert, just show what's in the model")
|
||||
|
|
4
gguf.py
4
gguf.py
|
@ -28,6 +28,7 @@ KEY_GENERAL_SOURCE_URL = "general.source.url"
|
|||
KEY_GENERAL_SOURCE_HF_REPO = "general.source.hugginface.repository"
|
||||
KEY_GENERAL_FILE_TYPE = "general.file_type"
|
||||
KEY_GENERAL_DATE = "general.date"
|
||||
KEY_GENERAL_COMMIT_HASH = "general.commit_hash"
|
||||
|
||||
# LLM
|
||||
KEY_LLM_CONTEXT_LENGTH = "{arch}.context_length"
|
||||
|
@ -603,6 +604,9 @@ class GGUFWriter:
|
|||
def add_date(self, date: str):
|
||||
self.add_string(KEY_GENERAL_DATE, date)
|
||||
|
||||
def add_commit_hash(self, commit_hash: str):
|
||||
self.add_string(KEY_GENERAL_COMMIT_HASH, commit_hash)
|
||||
|
||||
def add_name(self, name: str):
|
||||
self.add_string(KEY_GENERAL_NAME, name)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue