Download code/falcon/samples.py from LiteMind/homunculus: direct link, hf CLI and curl.
- Browser
- Download file 922 Bytes
-
https://huggingface.co/LiteMind/homunculus/resolve/main/code/falcon/samples.py
- Command line
-
hf download hf://LiteMind/homunculus/code/falcon/samples.py
-
curl -L -o samples.py https://huggingface.co/LiteMind/homunculus/resolve/main/code/falcon/samples.py
922 Bytes
| import prune | |
| from clust3 import * | |
| import prune as P_ | |
| sd0, cfg0 = load(); sd0.pop('lm_head.weight', None); S = {eval(k): v for k, v in torch.load('S.pt').items()} | |
| mo, _ = build(sd0, cfg0) | |
| sd, cfg, _ = build_from(sd0, cfg0, 'imp', 0.25, None, S); sd = quant_b(sd, 8); mp, _ = build(sd, cfg) | |
| prune.NEW = 48 | |
| out = [] | |
| labels = ["Why is the sky blue? Answer in two sentences.", "Write a short poem (4 lines) about a falcon flying over the desert.", "What is the capital of Libya?", P_.P[0], P_.P[1], P_.P[2]] | |
| GO, GP = prune.gen(mo), prune.gen(mp) | |
| for l, a, b in zip(labels, GO, GP): | |
| out.append({'prompt': l, 'orig': tok.decode(a, skip_special_tokens=True), 'pruned_q8': tok.decode(b, skip_special_tokens=True), 'same': a == b}) | |
| json.dump(out, open('samples.json', 'w'), ensure_ascii=False, indent=1) | |
| for o in out: print('PROMPT:', repr(o['prompt']), '\nORIG:', repr(o['orig']), '\nPRUNED25+Q8:', repr(o['pruned_q8']), '\n') | |