Awkweave translates an English text-processing request plus representative input into an awk program. It is a LoRA fine-tune of Qwen/Qwen2.5-Coder-7B-Instruct, merged into ordinary Transformers weights for local, offline inference. No API key is needed for inference.
awk program only, without the awk executable, filename, Markdown, or explanation.All scores are greedy, one generation per row. Valid means awk executes the prediction on the primary input. Correct requires exact output equality on both the primary and second input. Only trailing special tokens are stripped; Markdown is never repaired.
| Model | Test valid | Test correct | Dev valid | Dev correct | Frozen valid | Frozen correct |
|---|---|---|---|---|---|---|
| Qwen2.5-Coder base | 2.6% (77/3000) | 2.5% (76/3000) | 9.1% (3/33) | 3.0% (1/33) | 13.5% (5/37) | 8.1% (3/37) |
| Awkweave stage 1 | 100.0% (3000/3000) | 100.0% (3000/3000) | 90.9% (30/33) | 30.3% (10/33) | 94.6% (35/37) | 32.4% (12/37) |
| Awkweave 7B | 100.0% (3000/3000) | 100.0% (3000/3000) | 100.0% (33/33) | 97.0% (32/33) | 94.6% (35/37) | 37.8% (14/37) |
The base model fenced every prediction in Markdown and usually emitted a shell command, so it was invalid under the strict bare-program contract.
Test contains 3000 grammar-generated rows from the original 39 families and measures in-distribution behavior only; input texts are disjoint, but request/program pairs can recur. Dev contains 33 authored tasks used to guide the realistic expansion, so it is development data, not an untouched test. Frozen contains 37 separately authored network-flow, inventory, syslog, group, sensor, and formatting tasks. It was excluded from all training and tuning. Full predictions and summaries are included under evaluation/.
Request: For each record, print column 1 and the running sum of column 2, separated by a space.
gus 24 indigo
jules 18 delta
farah 18 grove
alice 22 delta
farah 29 grove
dina 10 amber
jules 4 fable
farah 2 fable
Generated program:
{s+=$2;print $1,s}
Executed output:
gus 24
jules 42
farah 60
alice 82
farah 111
dina 121
jules 125
farah 127
from awkweave.model import generate_program
program = generate_program(
"Print each name and the running total of column 2.",
"alice 10\nbruno 15\nchen 7\n",
"asterbraid/awkweave-7b",
)
print(program)
Or use the lower-level API:
from transformers import AutoModelForCausalLM, AutoTokenizer
from awkweave.prompts import messages
model_id = "asterbraid/awkweave-7b"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
prompt = tokenizer.apply_chat_template(
messages("Print the last field of every line.", "a 1\nb 2\n"),
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
output = model.generate(**inputs, do_sample=False, max_new_tokens=192)
print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Clone this repository, install the package, and pipe representative input to the CLI. Python 3.10+ and an awk executable are required:
git clone https://huggingface.co/asterbraid/awkweave-7b
cd awkweave-7b
pip install -e '.[model]'
printf 'alice 10\nbruno 15\n' | awkweave 'Print the running sum of column 2'
Add --run to print the generated program to stderr and execute it with the included safety guard. The guard permits stdin/stdout processing only and rejects file, environment, subprocess, pipe, and redirection operations.
Quantized builds are included for llama.cpp-compatible runtimes:
awkweave-7b.Q4_K_M.ggufawkweave-7b.Q8_0.ggufllama-server -m awkweave-7b.Q8_0.gguf --host 127.0.0.1 --port 8080
The Q4_K_M build was also loaded in llama-completion and passed a real generation smoke check.
Measured with llama.cpp 483cab3dd913fffcce1ce86edeb3617a7672936f, deterministic decoding, and prompt caching disabled. Correctness requires exact output on both inputs. Raw predictions and the evaluation script are under evaluation/.
| Format | Dev valid | Dev correct | Frozen valid | Frozen correct |
|---|---|---|---|---|
| Transformers | 100.0% (33/33) | 97.0% (32/33) | 94.6% (35/37) | 37.8% (14/37) |
| Q8_0 GGUF | 100.0% (33/33) | 90.9% (30/33) | 91.9% (34/37) | 37.8% (14/37) |
| Q4_K_M GGUF | 100.0% (33/33) | 97.0% (32/33) | 97.3% (36/37) | 43.2% (16/37) |
Q4_K_M is the best default for the demo: it matches full-weight development accuracy and exceeds full-weight frozen correctness in this comparison. Q8_0 provides no accuracy advantage.
Measured with 8 CPU threads, five identical short generations, and deterministic decoding. Cold total includes model initialization but not network downloads. Warm median is the median of five generations after the first. Peak memory is process RSS. GGUF uses a persistent llama-server.
| Format | Cold total | Warm median | Peak memory |
|---|---|---|---|
| Transformers | 191.82s | 14.84s | 43.46 GiB |
| Q4_K_M GGUF / llama.cpp | 11.25s | 2.27s | 7.54 GiB |
Environment: Transformers 5.17.0, torch 2.14.0+cu130, llama.cpp 483cab3dd913fffcce1ce86edeb3617a7672936f. These are short-request measurements, not a throughput benchmark. Raw results and scripts are under evaluation/.
Qwen/Qwen2.5-Coder-7B-Instruct (Apache-2.0).training_config.json records the resolved settings and training metrics.Every reference program in the dataset was executed on two inputs. Paraphrases changed request wording only, never the program, inputs, or expected outputs.
The model itself produces text and does not execute anything. The optional CLI and Space use awkweave.execution.run_awk, which supplies input on stdin and rejects file/environment access, system(), getline, pipes, and output redirection. CPU, memory, output-file, and wall-clock limits are also applied. Review generated programs before use. A syntactically valid program can still implement the wrong request.
awk on supplied text. No multi-file joins, quoted CSV, or external pipelines.awk implementation exploit. Use a container for untrusted production workloads.Code and merged weights are Apache-2.0, matching the base model. See LICENSE and NOTICE. Training data is CC-BY-4.0; attribute Asterbraid when redistributing it.
Qwen/Qwen2.5-Coder-7B-Instruct