Llama-3.2-3B-Instruct-Astra-Weight-Edit
Built with Llama. An experimental direct weight edit of Llama 3.2 3B Instruct, developed with Astra in Codex, targeting a narrow numerical-comparison failure.
On a frozen, fresh test of 128 greater/less requests, the original model scored 59/128 (46.1%) and this final edited model scored 125/128 (97.7%). Across the complete 308-request evaluation, four answers the original model got right became wrong. This release documents both the improvement and those regressions.
This is a complete float16 Transformers checkpoint. It runs with ordinary inference: no adapters, activation hooks, external comparator, special inference code, or extra inference passes are needed. The published results use the same prompts for the original and final models.
What this experiment tested
The original model often answered a numerical comparison correctly when asked a Yes/No question or asked to return the larger number, but struggled when asked to return the label GREATER, LESS, or EQUAL.
Example from the fresh evaluation:
Compare 44 with 41. Respond with exactly one of GREATER, LESS, EQUAL. Return the label only, without punctuation or explanation.
| Correct answer | Original model | Final edited model |
|---|---|---|
| GREATER | LESS | GREATER |
This is a measured weakness of this model under the tested formats. It is not a claim that current language models generally cannot compare numbers, or that Llama 3.2 3B cannot represent numerical order.
Model and attribution
- Base: meta-llama/Llama-3.2-3B-Instruct.
- Base revision:
0cb88a4f764b7a12671c53f0838cd831a0843b95. - Publisher: ndileep.
- Astra's role: inspected diagnostic evidence, proposed explicit weight transformations, and wrote the code that calculated and evaluated them. The name Astra describes the assistant used for this experiment; this is an independent experiment, not an official Meta or OpenAI release.
- Experiment date: 6 November 2026.
- Inspiration: Weight Space Programming.
What changed
Only two parameter regions differ from the original model after loading the original into float16. The source model's conversion to float16 is shared by the baseline and the edited model; the edit counts below exclude that conversion.
| Parameter | Region | Changed scalar values |
|---|---|---|
model.layers.13.self_attn.o_proj.weight | All 3,072 rows, columns [2304:2432], corresponding to attention head 18 | 393,025 |
model.embed_tokens.weight | Row 97124, the existing EQUAL token vector; multiplied by 1.025 and rounded to float16 | 3,072 |
| Total | 396,097 |
Layer and head indices are zero-based. The input embedding and output weights are tied, so the second edit also changes the same row used by lm_head.weight. Weight tying and the architecture are preserved. The first region is a head's output-projection block, not a single neuron. Localizing useful behavior here does not prove this head alone implements comparison.
How the weights were chosen
This final direct-edit series used no regression, gradient computation, backpropagation, fitted classifier, or optimizer-based training. An earlier regression-based exploration was kept separate; its fitted weights were not incorporated into this checkpoint.
It did use diagnostic examples and development feedback. Astra specified geometric transformations and candidate constants; code calculated the new values, and development results selected the final candidate. It would be inaccurate to describe this as data-free editing or as Astra individually guessing every new weight value.
The construction used observed head activations and an ordering direction derived from six diagnostic pair-order contrasts. A destination direction came from successful Yes/No versions of the comparison task. The final construction:
- Reduced the input direction's projection onto a basis containing observed pair-shared components and diagnostic means by 75%, then normalized it. Pair-shared components are based on
(h(a,b) + h(b,a)) / 2and do not change when the numbers are swapped. - Applied an explicit head redirection with gain 16:
W_candidate = W_original + outer(W_original @ (16*d - r_new), r_new). - Partially protected five observed equality directions: with
D = W_candidate - W_prior_directand orthonormal rowsQ, usedW_final = W_prior_direct + D - 0.5 * (D @ Q.T) @ Q. HereW_prior_directis the earlier no-regression direct head edit, not the separate regression-based exploration. - Multiplied the original tied
EQUALtoken row by1.025.
Float16 rounding is part of the persisted edit. The metadata and formula audit describe the exact selected construction. The final edited projection and token row are also supplied as safetensors under editing/; users do not need them separately to run the complete checkpoint.
Evaluation: original versus final
All comparisons below use the original, unedited model as the baseline. Both models used the same revision, float16 precision, greedy decoding, prompt templates, and evaluation environment.
| Test group | Requests | Original correct | Final correct |
|---|---|---|---|
| Primary greater/less combined | 128 | 59 | 125 |
| ↳ GREATER | 64 | 2 | 64 |
| ↳ LESS | 64 | 57 | 61 |
| EQUAL | 64 | 60 | 61 |
| Alternate wording, greater/less | 32 | 18 | 31 |
| Yes/No comparison | 16 | 15 | 16 |
| Return the larger number | 16 | 16 | 16 |
| Alternate wording, equality | 16 | 16 | 15 |
| JSON extraction controls | 6 | 6 | 6 |
| Simple factual controls | 6 | 6 | 6 |
| Decimal / negative / larger-number stress cases | 24 | 12 | 13 |
The GREATER and LESS rows subdivide the primary group; they are not additional requests. The 128 primary requests represent 64 number pairs, each tested in both orders. Alternate wording and other formats reuse some numbers, so all 308 requests are not independent numerical samples.
Across the full mixed evaluation, 85 answers changed from wrong to correct and four changed from correct to wrong. Aggregate results across these heterogeneous groups should not be treated as a general math benchmark.
All four regressions versus the original
| Comparison | Format | Original response (correct) | Final response (wrong) |
|---|---|---|---|
| 99 < 100 | Primary labels | LESS | GREATER |
| 201 = 201 | Primary labels | EQUAL | LESS |
| 108 = 108 | Alternate equality wording | EQUAL | LESS |
| 14.03 < 14.3 | Stress-test labels | LESS | GREATER |
These are new errors relative to the original model, not the complete list of remaining mistakes. There are 19 incorrect final responses across the 308 requests. Exact regression prompts and all original/final generations are included.
Development separation and scoring
- 442 previously exposed requests were used for development. They included earlier test examples that had become known; they are not counted as fresh evidence here.
- The final edit was selected before generating answers to the 308 final requests. The new main comparison pairs and equality values were excluded from earlier main comparison datasets. The frozen protocol records the seed and case hash.
- Evaluation used Apple MPS, float16, SDPA attention, batch size 4 within each group, left padding, and greedy decoding with at most 32 new tokens. The chat-template date was pinned to
06 Nov 2026. - Answers must terminate naturally with an EOS token. Both exact and content scores are retained. Content scoring ignores case and trailing
.,!, or?; exact scoring requires the expected string. Primary, equality, and stress results above also match exact scores. Yes/No comparison exact scores were 8/16 for both models; factual exact scores were 1/6 for both. JSON scoring requires the expected object and an integer age. - A separate process loaded the saved checkpoint and exactly reproduced responses and token sequences for all 436 checked requests: 308 fresh requests plus 128 known primary requests. This was a persistence check, not 436 additional independent tests. See reload verification.
Use with Transformers
The checkpoint was saved and tested with transformers==5.22.1, torch==2.15.0, and safetensors==0.8.0. The full recorded environment is in requirements-lock.txt. Older Transformers versions may not support this saved configuration.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
model_id = "ndileep/Llama-3.2-3B-Instruct-Astra-Weight-Edit"
device = "cuda" if torch.cuda.is_available() else (
"mps" if torch.backends.mps.is_available() else "cpu"
)
tokenizer = AutoTokenizer.from_pretrained(model_id, padding_side="left")
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForCausalLM.from_pretrained(
model_id, dtype=torch.float16, attn_implementation="sdpa"
).to(device).eval()
prompt = (
"Compare 44 with 41. Respond with exactly one of GREATER, LESS, EQUAL. "
"Return the label only, without punctuation or explanation."
)
text = tokenizer.apply_chat_template(
[{"role": "user", "content": prompt}], tokenize=False,
add_generation_prompt=True, date_string="06 Nov 2026",
)
inputs = tokenizer(text, add_special_tokens=False, return_tensors="pt").to(device)
config = GenerationConfig(
do_sample=False, max_new_tokens=32,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=model.generation_config.eos_token_id,
use_cache=True,
)
with torch.inference_mode():
output = model.generate(**inputs, generation_config=config)
print(tokenizer.decode(output[0, inputs.input_ids.shape[1]:], skip_special_tokens=True))
The saved generation defaults are inherited from the base checkpoint and enable sampling. Explicitly use greedy decoding as above to match the experiment. Device, precision, batching, library version, or prompt changes can change results; a single-request example is not an exact replay of the batched evaluation.
Reproduce the evaluation
Download this repository, install compatible dependencies, and run:
python evaluate.py --model . --device mps --output final-rerun.json
To evaluate the original model (requires access to Meta's gated repository):
python evaluate.py --model meta-llama/Llama-3.2-3B-Instruct --revision 0cb88a4f764b7a12671c53f0838cd831a0843b95 --device mps --output original-rerun.json
The evaluator uses the published cases and the original grouping, batch size, date, decoding, and scoring rules. It does not edit weights or attach activation hooks. SHA256SUMS records the release file hashes. The complete checkpoint is sufficient for inference; applying another patch on top would be incorrect.
Limitations and intended use
This is a small research artifact for studying direct weight editing and behavior under specific comparison templates. Most main examples are positive integers below 1,000. The broader stress set remains weak at 13/24. General reasoning, math, multilingual behavior, instruction following, and safety preservation were not established by this evaluation. The six factual and six JSON controls are too small to establish broad capability preservation.
Candidate formulas and constants were selected using development behavior. Geometric projection can overfit observed activation directions. The fresh test is small, uses related templates, and does not establish a universal repair. The head edit is localized in parameter count but not necessarily small in magnitude or effect.
The base model's limitations and acceptable-use requirements continue to apply. Consult its model card for the underlying architecture, original training, supported languages, and safety information. This experiment does not replace the original model's safety evaluation.
License
Distributed under the Llama 3.2 Community License, with Meta's license, attribution notice, and acceptable-use policy. This derivative is not endorsed by Meta or OpenAI.