The Problem
I actively use AI to debug issues in my project development. I ran into an annoying problem: logs typically contain massive amounts of repetitive information. This eats up a huge chunk of input context without adding any real value.
Here's a typical scenario: I notice a bug, copy 1000 lines of logs, and paste them into the chat. The neural network starts parsing the text, but out of those 1000 lines, only about 300 are actually unique. The rest is the same template repeated hundreds of times:
2026-04-18T11:54:02.746 [WinFocusMonitor] computeIsSecureField: queryMsaaProtected == 0
2026-04-18T11:54:02.747 [WinFocusMonitor] workerMain: hwnd=00000000016000FE idObject=-4 idChild=0 -> secure=0
2026-04-18T11:54:02.765 [WinFocusMonitor] computeIsSecureField: queryMsaaProtected == 0
2026-04-18T11:54:02.765 [WinFocusMonitor] workerMain: hwnd=00000000003B0640 idObject=-4 idChild=-45107 -> secure=0
2026-04-18T11:54:04.787 [MemDiag] periodic t+9s WorkingSet=352.257812MB Peak=368.761719MB
2026-04-18T11:54:04.788 [MemDiag] WordIndex en_US READY at t+9s
2026-04-18T11:54:04.788 [MemDiag] after WordIndex en_US READY WorkingSet=352.320312MB Peak=368.761719MB
You can see the same components ([WinFocusMonitor], [MemDiag]), the same keys (WorkingSet=, hwnd=), the same phrases over and over.
The idea was to copy logs to the clipboard the standard way, then use Ctrl+Alt+V to paste an optimized version. As a result, with this simple background utility, I achieved log compression of up to 80% depending on volume and number of repetitions.
Stage 1: Basic Idea — Dictionary of Repetitions
My first thought was simple: if something repeats, I'll extract it into a "legend" (dictionary) and replace it with a short tag. I asked a AI to write a PowerShell script that analyzes logs and extracts repeating elements into tags like #1#, #2#.
Here's what those same logs look like after the first version of the script:
--- LEGEND ---
#T# = 2026-04-18T11:54:
#0# = [WinFocusMonitor]
#1# = [MemDiag]
#2# = hwnd=
#3# = idObject=
#4# = idChild=
#5# = secure=
#6# = WorkingSet=
#7# = Peak=
#8# = ' computeIsSecureField: queryMsaaProtected == 0'
#9# = ' WordIndex '
--- LOGS ---
#T#02.746 #0##8#
#T#02.747 #0# workerMain: #00000000016000FE #3#-4 #4#0 -> #5#0
#T#02.765 #0#8
#T#02.765 #0# workerMain: #00000000003B0640 #3#-4 #4#-45107 -> #5#0
#T#04.787 #1# periodic t+9s #6352.257812MB #7#368.761719MB
#T#04.788 #1# #9#en_US READY at t+9s
#T#04.788 #1# after #9#en_US READY #6#352.320312MB #7#368.761719MB
All basic repeating elements are extracted into the legend at the top.
Result of stage one: 4072 characters → 2625 characters. Savings: ~35%.
Stage 2: Tag Optimization with Base62
When you have many variables, tags start looking like #123, #456 — that's already 4-5 characters per tag.
This can be optimized by adding lowercase and uppercase letters to tags. In this system, the first 62 variables can be written in just two characters:
-
#0,#1,#2...#9(10 items) -
#a,#b,#c...#z(26 items) -
#A,#B,#C...#Z(26 items)
That's 62 variables in two characters total. Beyond that come #10, #11 and so on, but in three characters.
--- LEGEND ---
#T# = 2026-04-18T11:54:
#0# = [WinFocusMonitor]
#1# = [MemDiag]
#2# = hwnd=
#3# = idObject=
#4# = idChild=
#5# = secure=
#6# = WorkingSet=
#7# = Peak=
#8# = ' computeIsSecureField: queryMsaaProtected == 0'
#9# = ' WordIndex '
--- LOGS ---
#T#02.746 #0##8#
#T#02.747 #0# workerMain: #2#16000FE #3#-4 #4#0 -> #5#0
At larger scales, this can provide an additional 3-5% compression.
Stage 3: Removing Leading Zeros
Another detail that catches the eye in C++ logs — hex pointers with fixed width. The Windows API returns HWND as 00000000016000FE — eight leading zeros that carry no meaningful information.
I optimized this by trimming leading zeros. What was 00000000016000FE became 16000FE.
--- LOGS ---
#T#02.746 #0##8#
#T#02.747 #0# workerMain: #2#16000FE #3#-4 #4#0 -> #5#0
#T#02.765 #0#8
#T#02.765 #0# workerMain: #2#3B0640 #3#-4 #4#-45107 -> #5#0
On 45 KB of logs, this saved about 300 characters. Not much, but still something.
Stage 4: Meta-BPE — Tags Made of Tags
Working with larger logs revealed duplicates among the tags themselves:
#T#19.557 #0##C##8##81# #90#
#T#19.557 #0##K##8##81# #90#
#T#19.601 #0##U##8##81# #90#
#T#19.601 #0##C##8##32# #91#
#T#19.601 #0##w##8##32# #91#
#T#19.601 #0##x##8##32# #91#
The prefix #T#19.557 #0# repeats several times in a row. Now we need to find repeating sequences of tags and extract them into new variables.
I added an additional processing cycle that works on top of the regular one. I started marking new variables with (!) instead of (#) to differentiate them:
--- LEGEND ---
#T# = 2026-04-18T11:54:
#0# = [TTDiag]
#8# = vk=
#32# = 881
#81# = 890
#C# = ' > shouldBlockAllFeatures '
#K# = ' > drainPendingReset '
#U# = ' > entry '
#w# = ' > executePendingReplacementIfAny '
#x# = ' > hotkeyManager.processKeyEvent '
!1! = #T#19.557 #0##C##8#
!2! = #T#19.601 #0#
!3! = #8##32# #91#
--- LOGS ---
!1!#81# #90#
!1!#K##81# #90#
!2!#U##81# #90#
!2!#C#!3!
!2!#w#!3!
!2!#x#!3!
Now regular tags combine into meta-tags.
Result of stage four: 45,839 characters → 13,398 characters. Compression of 70.8% from original.
Stage 5: Macros with Substitution
Further work revealed the following patterns:
!26!#o#!3!
!26!#E#!3!
!26!#K#!3!
!26!#D#!3!
!26!#w#!3!
!26!#z#!3!
!26!#x#!3!
Here only one middle element changes! The prefix !26 and suffix !3 are identical in all lines. We can extract this construction into the following pattern !26!#@#!3!, where @ is a placeholder for substitution, and the actual value in the final macro will be passed after :, for example &1:o
--- LEGEND ---
#o# = ' > shouldExecute '
#E# = ' > hotkeyDefs->snapshot '
#K# = ' > drainPendingReset '
#D# = ' > handleCaseSwitchHotkey '
#w# = ' > executePendingReplacementIfAny '
#z# = ' > handleTranslationHotkey '
#x# = ' > hotkeyManager.processKeyEvent '
!26! = #T#1d#0
!3! = #881 #90
&1 = !26!#@#!3!
--- LOGS ---
&1:o
&1:E
&1:K
&1:D
&1:w
&1:z
&1:x
Now the logs have turned into pure enumeration of pointers. Each line &1:o reads as: "Take template &1 (which expands to !26!#@#!3!), substitute o for @, and you get the original log line."
Result of stage five: 45,839 characters → 10,192 characters. Final compression of 78.4%!
Bonus: Performance
PowerShell is great for quick automation on the fly, but it's slow with loops over string arrays and nested iterations. This led to long paste delays that could reach 20 seconds. Eventually, AI rewrote everything for me in Rust, and now pasting happens instantly.
How Does This Work with Neural Networks?
The question arises: "Will neural networks understand this format? Won't the model get confused by these tags?"
The answer — not only will they understand, but they work with it even better than with raw logs.
1. LLMs Are Trained on Structured Data
Modern neural networks are trained on code, JSON, YAML, markdown. When a model sees a --- LEGEND --- block with "key = value" pairs, it automatically understands: this is a dictionary, I need to keep it in context. You don't need to explain how to work with this format — it "expands" the tags in its mind on its own.
2. Focus on Anomalies
This is the most important part. When you paste 1000 lines into chat with identical text like [WinFocusMonitor] workerMain: hwnd=..., the model's attention (attention mechanism) gets "smeared" across repetitive noise.
In compressed format, the model sees:
&24:o
&24:E
&24:K
&24:D
For a neural network, this is the perfect signal: "Aha, the line structure is identical, only one parameter changes. Let me check the legend to see what o, E, K, D mean, and focus on the differences".
Errors and anomalies in this format literally shine. If suddenly among ten &24:K entries, &24:X appears or even &25:K — the model will instantly spot the pattern violation.
3. Context Window Savings
Even the most advanced models have a problem: the larger the context, the more "forgetfulness."
By saving up to 80% of characters on logs, you leave the model more "working memory" for:
- Retaining your project's architecture
- Chat history
- Writing quality code in responses
The model won't "forget" the task context due to bloated logs.
4. No Hallucinations
The key difference of this approach from "asking AI to shorten the log" — we compress mathematically, not through paraphrasing. All milliseconds, hex addresses, error codes remain in their places. The BPE algorithm guarantees zero data loss.
How to Use?
The application is currently available only for Windows and Mac. It works as follows:
- Copy raw logs from terminal/file (
Ctrl+C) - Switch to Cursor or ChatGPT/Claude web interface
- Press
Ctrl+Alt+Vinstead of regularCtrl+V - Compressed logs are pasted
- Bonus: original logs are automatically restored to clipboard (in case you need to paste the original somewhere else)
The project source code is available on. You can port this algorithm to your platform in a couple of minutes, as well as adapt it to your needs.
Top comments (0)