Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,90 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
metrics:
|
| 6 |
+
- exact_match
|
| 7 |
+
base_model:
|
| 8 |
+
- google/t5-efficient-tiny
|
| 9 |
+
pipeline_tag: text-generation
|
| 10 |
+
tags:
|
| 11 |
+
- text-generation-inference
|
| 12 |
+
- dsl
|
| 13 |
---
|
| 14 |
+
# Model Card β logx v0.1.0
|
| 15 |
+
|
| 16 |
+
NL β nginx-log-query translation model. Fine-tune of
|
| 17 |
+
[`google/t5-efficient-tiny`](https://huggingface.co/google/t5-efficient-tiny)
|
| 18 |
+
(15.57M params, Apache-2.0) that maps English questions about nginx logs to a
|
| 19 |
+
strict JSON DSL, executed by this repo's deterministic read-only layer.
|
| 20 |
+
|
| 21 |
+
- **Task**: seq2seq; input `parse: <question>` (β€64 tokens) β single-line
|
| 22 |
+
minified DSL JSON (β€128 tokens). The DSL contract (4 actions + abstain,
|
| 23 |
+
nginx access/error fields) is defined by
|
| 24 |
+
[schema/dsl_v0.1.json](schema/dsl_v0.1.json) and
|
| 25 |
+
[schema/fields.py](schema/fields.py).
|
| 26 |
+
- **Download**: [Releases](https://github.com/devang007/logX/releases) β
|
| 27 |
+
`logx-model-v0.1.0.zip` (56 MB) + `.sha256`. Contains **safetensors and
|
| 28 |
+
JSON only β no pickle files**.
|
| 29 |
+
- **License**: Apache-2.0 (code and weights; base model is Apache-2.0).
|
| 30 |
+
|
| 31 |
+
## How to use
|
| 32 |
+
|
| 33 |
+
Via the CLI (recommended β includes validation + safe execution):
|
| 34 |
+
|
| 35 |
+
```bash
|
| 36 |
+
git clone https://github.com/devang007/logX && cd logX
|
| 37 |
+
./install.sh # downloads this model zip automatically
|
| 38 |
+
logx -q "top 5 ips" -src /var/log/nginx/access.log
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
Or directly with π€ Transformers:
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 45 |
+
tok = AutoTokenizer.from_pretrained("path/to/unzipped/model")
|
| 46 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("path/to/unzipped/model")
|
| 47 |
+
ids = tok("parse: how many 502s in the last hour", return_tensors="pt").input_ids
|
| 48 |
+
print(tok.decode(model.generate(ids, max_length=128)[0], skip_special_tokens=True))
|
| 49 |
+
# {"action":"count","source":"nginx_access","filters":[{"field":"status","op":"eq","value":"502"}],"time":{"last":"1h"}}
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
The tokenizer is **not** a stock T5 tokenizer: 6 tokens (`< \ ^ { } ~`) were
|
| 53 |
+
added so JSON braces survive encoding, with a patched Metaspace pre-tokenizer.
|
| 54 |
+
Always load the tokenizer shipped in the zip, never the base model's.
|
| 55 |
+
|
| 56 |
+
## Training
|
| 57 |
+
|
| 58 |
+
Trained in a separate private pipeline; this repo distributes the artifacts.
|
| 59 |
+
|
| 60 |
+
| | |
|
| 61 |
+
|---|---|
|
| 62 |
+
| Data | 42,558 train / 2,364 val rows, synthetic teacher-generated NL/DSL pairs; every row schema-validated and executor-verified before training |
|
| 63 |
+
| Recipe | HF `Seq2SeqTrainer`, 15 epochs, lr 3e-4 (linear, 5% warmup), batch 64, fp32, AdamW, wd 0.01, seed 42 |
|
| 64 |
+
| Selection | best val exact-match checkpoint (epoch 14) |
|
| 65 |
+
| Hardware | Apple M1 Pro (MPS), ~43 h wall clock |
|
| 66 |
+
|
| 67 |
+
## Evaluation (val split, n=2,364, greedy decoding)
|
| 68 |
+
|
| 69 |
+
| Metric | Value |
|
| 70 |
+
|---|---|
|
| 71 |
+
| Exact match (canonical string) | **90.95%** |
|
| 72 |
+
| JSON-valid rate | 98.27% |
|
| 73 |
+
| Schema-valid rate | 98.18% |
|
| 74 |
+
|
| 75 |
+
Held-out `test` and out-of-distribution `test_ood` results are **not yet
|
| 76 |
+
published** β treat OOD generalization as unmeasured. Training data is
|
| 77 |
+
synthetic; phrasings far from its distribution will degrade accuracy.
|
| 78 |
+
|
| 79 |
+
## Intended use & limitations
|
| 80 |
+
|
| 81 |
+
- Intended: translating English questions about **nginx access/error logs**
|
| 82 |
+
into DSL v0.1, **behind schema validation** (as the `logx` CLI does).
|
| 83 |
+
Out-of-scope questions are trained to yield `{"action":"abstain"}`.
|
| 84 |
+
- Not intended: general text generation, other log formats, other languages,
|
| 85 |
+
or use of raw outputs without validation (~2% of outputs are invalid, ~9%
|
| 86 |
+
are wrong β validate, and show the DSL to the user before acting on it).
|
| 87 |
+
- The model only *translates*; it never executes anything. Execution safety
|
| 88 |
+
(read-only allowlist, shell-free, injection-proof value passing) lives in
|
| 89 |
+
[src/executor.py](src/executor.py) and is enforced regardless of what the
|
| 90 |
+
model emits.
|