[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-111802":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":9,"pushedAt":22,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":14,"starSnapshotCount":14,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},111802,"bitsy","leochlon\u002Fbitsy","leochlon","Prompt or weights: gate, bakeoff, diagnose, guard.",null,"Python",58,4,57,0,1,42.2,"MIT License",false,"main",true,[],"2026-11-08 13:12:46","2026-11-15 18:10:49","\u003Cdiv align=\"center\">\n\n# bitsy\n\n**How much did your model learn from its prompt, a fine-tune or a weight edit?\u003Cbr>\nbitsy measures all three in one unit: bits.**\n\n\u003Ch3>\n\n[Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2610.29419) | [Docs](docs\u002FREADME.md) | [Examples](examples\u002F)\n\n\u003C\u002Fh3>\n\n\u003C\u002Fdiv>\n\n---\n\nReading something in the prompt and being trained on it are both ways for a model to learn it. bitsy treats every\nprompt, fine-tune, adapter and weight edit as memory and scores it the same way. It takes the model's right answers on\nheld-out questions, first with nothing, then with the memory. The bits saved are what the memory taught it: each bit\nmakes the right answer twice as likely.\n\n- **Attribute it**: how many bits each part of a context contributes, including true lines the model misreads\n  (`diagnose`), and whether an answer's confidence comes from its evidence (`guard`).\n- **Compare memories**: prompt against fine-tune, adapter or edited weights, with a sequential test you can check\n  after every question. It stops when it calls a winner, wrong at most 5% of the time per comparison (`bakeoff`).\n- **Move it**: write a prompt into the weights, solved in closed form with no gradient steps, while holding other text\n  in place, and measure what moved (`compile`).\n- **Find what is lost**: a floor on how much of its prompt a model fails to use, and where inside a local model\n  ([where](docs\u002Fwhere.md)).\n- **Before you train**: whether a fine-tune is worth trying (`gate`), and, on data whose true answers are known, a\n  certificate that a prompt beats every memory of at most C bits, such as any small adapter\n  ([certificates](docs\u002Fcertificates.md)).\n\n## Try it\n\n### Which lines of its prompt does a model learn from?\n\nEach line is deleted and the answer scored again. A line's value is the bits it saves on the true answer.\n\n```python\nfrom bitsy import Local, diagnose\n\nm = Local('gpt2', sep='\\n')                       # any Hugging Face causal LM; one passage per line\npassages = ['The code for Bob is 17.', 'The code for Alice is 52.', 'The code for Bob is not 71.',\n            'Every code has two digits.', 'Fish swim in the sea.']\nr = diagnose.items(m, passages, [('The code for Bob is', ' 17')])      # a question and its true answer\nfor x in r['items']:\n    print(f\"{x['value'][0]:+.2f} bits  {x['verdict']:12s}{passages[x['item']]}\")   # [0]: the one question\n```\n\n```\n+3.99 bits  helps       The code for Bob is 17.\n-1.74 bits  misleading  The code for Alice is 52.\n-1.04 bits  misleading  The code for Bob is not 71.\n+0.85 bits  helps       Every code has two digits.\n-0.10 bits  dead weight Fish swim in the sea.\n```\n\nThe line with the answer makes 17 about 16 times as likely. Two true lines cost bits: the verdict is how GPT-2 uses a\nline, not whether it is true. The first run downloads GPT-2 (550 MB); the last digit can vary by machine.\n\n### How much does a fine-tune learn, compared with reading?\n\nA 512-token passage of Shakespeare, either in the prompt or fine-tuned in for one epoch. Each of 64 questions shows 8\ntokens of it and scores the next 24.\n\n```python\nimport numpy as np, urllib.request\nfrom bitsy import bakeoff\n\nurl = 'https:\u002F\u002Fraw.githubusercontent.com\u002Fkarpathy\u002Fchar-rnn\u002Fmaster\u002Fdata\u002Ftinyshakespeare\u002Finput.txt'\nids = np.array(m.enc(urllib.request.urlopen(url).read().decode()))\ndoc = ids[100000:100512]\nqueries = [(doc[s:s + 8], doc[s + 8:s + 32]) for s in np.random.default_rng(0).integers(0, 480, 64)]\nnone = bakeoff.score(m, [], queries, L=24)                        # L: tokens scored per question, fixed in advance\na = bakeoff.score(m, doc, queries, L=24)                          # the passage in the prompt\nb = bakeoff.score(m.tune([doc], epochs=1), [], queries, L=24)     # fine-tuned, nothing in the prompt\nprint([round(float(s['cost'].mean()) \u002F 24, 2) for s in (none, a, b)])   # bits per token\n# [7.55, 1.69, 6.19]\nbakeoff.race(a, b)                                                # 'A': the first argument is the better memory\n# {'call': 'A', 'queries': 27}\n```\n\nReading nothing, GPT-2 needs 7.55 bits per token. The prompt saves 5.86 of them, the fine-tune 1.36, and the test was\nsure after 27 of the 64 questions.\n\n### The same memory, moved into the weights\n\n[examples\u002Finstall.py](examples\u002Finstall.py) writes the passage into GPT-2's last four MLP layers from 64 questions,\nholding 128 other passages in place, then scores 416 new questions with nothing in the prompt. Its core is one call:\n\n```python\nc = m.compile([(doc, train)], keep, only=m.block('mlp', 'late'))   # train: 64 questions; keep: 128 other passages\n```\n\n| | the passage (bits\u002Ftoken) | other text (bits\u002Ftoken) |\n|---|---|---|\n| nothing | 7.32 | 7.86 |\n| the passage in the prompt | 1.72 | |\n| compiled weights, nothing in the prompt | 2.47 | 8.03 |\n\nThe weights now hold 87% of what the prompt taught (4.85 of 5.60 bits per token), and other text moved by 0.17. The\ntest called it within 1 bit per token of the prompt after 382 questions, and other text within 0.25 after 405.\n\n[notebooks\u002Finstall_a_skill.ipynb](notebooks\u002Finstall_a_skill.ipynb) does the same with a 183-token system prompt in\nQwen2.5-1.5B-Instruct: the edited model, with no prompt, keeps 97% of what the prompt teaches.\n[Open it in Colab](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fleochlon\u002Fbitsy\u002Fblob\u002Fmain\u002Fnotebooks\u002Finstall_a_skill.ipynb).\n\n## Runs on\n\n- [x] Hugging Face models on your machine (`Local`): everything, including fine-tuning and `compile`\n- [x] vLLM and other servers that return prompt log-probabilities (`Hosted`): `bakeoff`, `gate.fit`, `guard`,\n  `diagnose.value`, `diagnose.unused`, `diagnose.items`\n- [x] OpenAI and Azure chat (`Hosted`, `Azure`): `guard.strict`, `diagnose.spans`, `bakeoff.labels`\n- [x] Any model that outputs a probability distribution (`Fn`): tables, 3D shapes, cameras, physics fields\n- [x] Text-only APIs such as Claude: `bakeoff.graded` on scored answers\n\nDetails, and adapters for sklearn-style classifiers such as TabPFN, Chronos forecasts and 3D models, in\n[docs\u002Fmodels.md](docs\u002Fmodels.md).\n\n## Install\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fleochlon\u002Fbitsy && cd bitsy\npip install -e .              # numpy only: hosted models and any model you wrap\npip install -e '.[local]'     # adds torch and transformers, for Hugging Face models on your machine\npip install -e '.[series]'    # adds Chronos, for time series\n```\n\nPython 3.9+. On Linux, `pip install torch --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcpu` first skips the CUDA\ndownload. `python examples\u002Fcertificates.py` runs on numpy alone in under a second.\n\n## Citation\n\n```bibtex\n@misc{chlon2026thoughts,\n  title  = {When Thoughts Become Memory: Unifying In-Context Learning and Fine-Tuning},\n  author = {Chlon, Leon and Huang, Julie},\n  year   = {2026},\n  note   = {arXiv preprint}\n}\n```\n\n[MIT licence](LICENSE). `examples\u002Fdata\u002Fairfrans-pressure64.npz` holds 1,000 AirfRANS simulations (Bonnet et al.,\nNeurIPS 2022), each reduced to 18 design inputs and 64 surface pressure coefficients, under the Open Database Licence\n1.0.\n","bitsy 是一个用于量化评估大语言模型中不同知识注入方式（提示词、微调、权重编辑）信息贡献度的Python工具，统一以‘比特（bits）’为单位衡量其对模型输出正确性的提升效果。核心功能包括：诊断提示中各语句的实际作用（helps\u002Fmisleading\u002Fdead weight）、在统计显著性保障下对比不同记忆形式的效果（bakeoff）、将提示知识无梯度地编译至权重（compile）、检测模型未利用的提示信息（where）、以及预判微调是否必要（gate）。适用于模型可解释性分析、提示工程优化、轻量级适配方法选型及模型知识归因研究。",2,"2026-11-24 04:41:49","CREATED_QUERY"]