convert.py : --vocab-only generates false but valid params (#7027)

An example of how this might be used in the style of baby-llama will be attached with this PR.
This commit is contained in:
20kdc 2024-05-08 13:22:32 +01:00 committed by GitHub
parent 229ffff872
commit ad211edef5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1508,6 +1508,8 @@ def main(args_in: list[str] | None = None) -> None:
if args.big_endian:
endianess = gguf.GGUFEndian.BIG
params = None
if args.pad_vocab or not args.vocab_only:
params = Params.load(model_plus)
if params.n_ctx == -1:
if args.ctx is None:
@ -1539,6 +1541,17 @@ def main(args_in: list[str] | None = None) -> None:
if not args.outfile:
raise ValueError("need --outfile if using --vocab-only")
outfile = args.outfile
if params is None:
params = Params(
n_vocab = vocab.vocab_size,
n_embd = 1,
n_layer = 1,
n_ctx = 1,
n_ff = 1,
n_head = 1,
n_head_kv = 1,
f_norm_eps = 1e-5,
)
OutputFile.write_vocab_only(outfile, params, vocab, special_vocab,
endianess=endianess, pad_vocab=args.pad_vocab)
logger.info(f"Wrote {outfile}")