Instructions to use Garnet-Owl/token-compression-log-reader with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Garnet-Owl/token-compression-log-reader with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-1.7B") model = PeftModel.from_pretrained(base_model, "Garnet-Owl/token-compression-log-reader") - Notebooks
- Google Colab
- Kaggle
Log reader: Qwen3-1.7B LoRA for template-compressed logs
A LoRA adapter for Qwen3-1.7B that answers questions about server logs stored in a compact template format, so the prompt uses about 25% fewer tokens. It is part of the token-compression project.
Results
Test set: 150 new 30-line logs, with three kinds of question (look up a request, highest duration, count the ERROR lines).
| Model and log | Correct | Prompt tokens |
|---|---|---|
| Base Qwen3-1.7B, original log | 33% | 1,459 |
| Base Qwen3-1.7B, compressed log with a short legend | 16% | 1,147 |
| This adapter, original log | 77% | 1,459 |
| This adapter, compressed log, no legend | 73% | 1,090 |
With 150 questions, the 4-point gap between the last two rows is within noise. Counting is the weak spot: 31% on compressed logs, against 100% for lookups and 90% for highest duration.
The compressed format
Each repeated line shape is written once as a template, and every line becomes a short row of values:
@1 2026-11-12 {} INFO request_id={} method={} path={} status={} duration_ms={}
---
1|10:22:09|16480894|GET|/api/v1/orders/299|200|845
The compressor is lossless and lives in the GitHub repo (app/structured_compression/compressor.py).
Usage
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
from app.structured_compression.compressor import StructuredCompressor # from the GitHub repo
base = "Qwen/Qwen3-1.7B"
tokenizer = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base, dtype=torch.float16, device_map="auto")
model = PeftModel.from_pretrained(model, "Garnet-Owl/token-compression-log-reader").eval()
INSTRUCTION = (
"Reply with only the answer. For a request_id question give the status code and duration_ms. "
"For a count or a highest value give just the number."
)
packed = StructuredCompressor().compress(log_text)
question = "How many ERROR lines are in the log?"
prompt = f"Log:\n{packed}\n\nQuestion: {question}\n{INSTRUCTION}"
text = tokenizer.apply_chat_template(
[{"role": "user", "content": prompt}], tokenize=False, add_generation_prompt=True, enable_thinking=False
)
inputs = tokenizer(text, return_tensors="pt", add_special_tokens=False).to(model.device)
output = model.generate(**inputs, max_new_tokens=10, do_sample=False)
print(tokenizer.decode(output[0, inputs.input_ids.shape[1]:], skip_special_tokens=True))
On a CPU, load in torch.float32 and drop device_map. It works but is slow.
Training
- Base model: Qwen3-1.7B, fp16, LoRA rank 32 and alpha 64 on all linear layers (about 35M trainable parameters).
- Data: 1,470 synthetic log questions, about 80% compressed logs without a legend and 20% original logs. Loss on answer tokens only.
- One pass, learning rate 2e-4 with a cosine schedule, batches packed by token budget, gradient checkpointing, on one 16 GB T4 GPU in about 44 minutes.
- The scripts are in
experiments/log_reader/.
Limitations
- Trained and tested on generated logs in one format, from a single random seed. Real logs are messier.
- It is specific to this template format and these question types. Other formats need their own training.
- Counting questions are unreliable.
- This is a research adapter, not a production log-analysis tool.
Author
- Downloads last month
- 22