squeez 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- squeez-0.1.0/LICENSE +190 -0
- squeez-0.1.0/PKG-INFO +354 -0
- squeez-0.1.0/README.md +325 -0
- squeez-0.1.0/pyproject.toml +64 -0
- squeez-0.1.0/setup.cfg +4 -0
- squeez-0.1.0/squeez/__init__.py +3 -0
- squeez-0.1.0/squeez/__main__.py +6 -0
- squeez-0.1.0/squeez/cli.py +82 -0
- squeez-0.1.0/squeez/data/__init__.py +1 -0
- squeez-0.1.0/squeez/data/auto_labeler.py +351 -0
- squeez-0.1.0/squeez/data/config.py +76 -0
- squeez-0.1.0/squeez/data/llm_distiller.py +374 -0
- squeez-0.1.0/squeez/data/pipeline.py +318 -0
- squeez-0.1.0/squeez/data/sample_assembler.py +124 -0
- squeez-0.1.0/squeez/data/source_fetcher.py +224 -0
- squeez-0.1.0/squeez/data/swebench_loader.py +128 -0
- squeez-0.1.0/squeez/data/tool_call_executor.py +537 -0
- squeez-0.1.0/squeez/data/tool_call_generator.py +377 -0
- squeez-0.1.0/squeez/data/validator.py +194 -0
- squeez-0.1.0/squeez/inference/__init__.py +1 -0
- squeez-0.1.0/squeez/inference/extractor.py +337 -0
- squeez-0.1.0/squeez/training/__init__.py +1 -0
- squeez-0.1.0/squeez/training/dataset.py +103 -0
- squeez-0.1.0/squeez/training/evaluate.py +236 -0
- squeez-0.1.0/squeez/training/train.py +180 -0
- squeez-0.1.0/squeez.egg-info/PKG-INFO +354 -0
- squeez-0.1.0/squeez.egg-info/SOURCES.txt +31 -0
- squeez-0.1.0/squeez.egg-info/dependency_links.txt +1 -0
- squeez-0.1.0/squeez.egg-info/entry_points.txt +2 -0
- squeez-0.1.0/squeez.egg-info/requires.txt +14 -0
- squeez-0.1.0/squeez.egg-info/top_level.txt +1 -0
- squeez-0.1.0/tests/test_cli.py +91 -0
- squeez-0.1.0/tests/test_extractor.py +160 -0
squeez-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 KR Labs
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
squeez-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: squeez
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Squeeze verbose LLM agent tool output down to only the relevant lines
|
|
5
|
+
Author-email: Adam Kovacs <kovacs@krlabs.eu>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/KRLabsOrg/squeez
|
|
8
|
+
Project-URL: Documentation, https://krlabsorg.github.io/squeez
|
|
9
|
+
Project-URL: Dataset, https://huggingface.co/datasets/KRLabsOrg/tool-output-extraction-swebench
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: torch>=2.1.0
|
|
17
|
+
Requires-Dist: transformers>=4.45.0
|
|
18
|
+
Requires-Dist: peft>=0.7.0
|
|
19
|
+
Requires-Dist: datasets>=2.14.0
|
|
20
|
+
Requires-Dist: openai>=1.0.0
|
|
21
|
+
Requires-Dist: pyyaml>=6.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
24
|
+
Requires-Dist: ruff>=0.0.270; extra == "dev"
|
|
25
|
+
Provides-Extra: docs
|
|
26
|
+
Requires-Dist: mkdocs-material>=9.0; extra == "docs"
|
|
27
|
+
Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Squeez
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img src="https://github.com/KRLabsOrg/squeez/blob/main/assets/squeez_mascot.png?raw=true" alt="Squeez Logo" width="300"/>
|
|
34
|
+
<br><em>Squeeze out the juice, leave the pulp behind.</em>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
Squeeze verbose LLM agent tool output down to only the relevant lines.
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/squeez/)
|
|
40
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
41
|
+
[](https://huggingface.co/datasets/KRLabsOrg/tool-output-extraction-swebench)
|
|
42
|
+
|
|
43
|
+
## The Problem
|
|
44
|
+
|
|
45
|
+
LLM coding agents waste **80-95% of context tokens** on irrelevant tool output. When an agent reads a 500-line file to find one function, or runs `git log` to find a specific commit, most of the output is noise.
|
|
46
|
+
|
|
47
|
+
Squeez trains a small (2-3B) generative model to identify and extract only the lines that matter for the task at hand — compressing tool output by ~86% on average.
|
|
48
|
+
|
|
49
|
+
## Example
|
|
50
|
+
|
|
51
|
+
Task: *"Fix the CSRF validation bug in the referer check"*
|
|
52
|
+
|
|
53
|
+
<table>
|
|
54
|
+
<tr>
|
|
55
|
+
<th>Before — 42 lines, ~1,200 tokens</th>
|
|
56
|
+
<th>After — 8 lines, ~150 tokens</th>
|
|
57
|
+
</tr>
|
|
58
|
+
<tr>
|
|
59
|
+
<td>
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
class CsrfViewMiddleware(MiddlewareMixin):
|
|
63
|
+
def _check_referer(self, request):
|
|
64
|
+
referer = request.META.get('HTTP_REFERER')
|
|
65
|
+
if referer is None:
|
|
66
|
+
raise RejectRequest('No referer')
|
|
67
|
+
good_referer = request.get_host()
|
|
68
|
+
if not same_origin(referer, good_referer):
|
|
69
|
+
raise RejectRequest('Bad referer')
|
|
70
|
+
|
|
71
|
+
def process_view(self, request, callback, ...):
|
|
72
|
+
if getattr(request, 'csrf_processing_done', False):
|
|
73
|
+
return None
|
|
74
|
+
csrf_token = request.META.get('CSRF_COOKIE')
|
|
75
|
+
if csrf_token is None:
|
|
76
|
+
return self._reject(request, 'No CSRF cookie')
|
|
77
|
+
return self._accept(request)
|
|
78
|
+
|
|
79
|
+
class SessionMiddleware(MiddlewareMixin):
|
|
80
|
+
def process_request(self, request):
|
|
81
|
+
session_key = request.COOKIES.get(...)
|
|
82
|
+
request.session = self.SessionStore(session_key)
|
|
83
|
+
|
|
84
|
+
def process_response(self, request, response):
|
|
85
|
+
if request.session.modified:
|
|
86
|
+
request.session.save()
|
|
87
|
+
return response
|
|
88
|
+
|
|
89
|
+
class CommonMiddleware(MiddlewareMixin):
|
|
90
|
+
def process_request(self, request):
|
|
91
|
+
host = request.get_host()
|
|
92
|
+
if settings.PREPEND_WWW and ...:
|
|
93
|
+
return redirect(...)
|
|
94
|
+
|
|
95
|
+
def process_response(self, request, response):
|
|
96
|
+
if settings.USE_ETAGS:
|
|
97
|
+
response['ETag'] = hashlib.md5(...)
|
|
98
|
+
return response
|
|
99
|
+
|
|
100
|
+
class SecurityMiddleware(MiddlewareMixin):
|
|
101
|
+
def process_request(self, request):
|
|
102
|
+
if settings.SECURE_SSL_REDIRECT and ...:
|
|
103
|
+
return redirect(...)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
</td>
|
|
107
|
+
<td>
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
class CsrfViewMiddleware(MiddlewareMixin):
|
|
111
|
+
def _check_referer(self, request):
|
|
112
|
+
referer = request.META.get('HTTP_REFERER')
|
|
113
|
+
if referer is None:
|
|
114
|
+
raise RejectRequest('No referer')
|
|
115
|
+
good_referer = request.get_host()
|
|
116
|
+
if not same_origin(referer, good_referer):
|
|
117
|
+
raise RejectRequest('Bad referer')
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**87% compression** — only the CSRF referer logic survives. Session, Common, and Security middleware are irrelevant to the task and get dropped.
|
|
121
|
+
|
|
122
|
+
</td>
|
|
123
|
+
</tr>
|
|
124
|
+
</table>
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
$ cat django/middleware.py | squeez "Fix the CSRF validation bug in the referer check"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
<details>
|
|
131
|
+
<summary><b>Another example — filtering git log</b></summary>
|
|
132
|
+
|
|
133
|
+
Task: *"Find the commit that changed the authentication timeout"*
|
|
134
|
+
|
|
135
|
+
**Before** — 25 commits of noise:
|
|
136
|
+
```
|
|
137
|
+
a1b2c3d Fix typo in README
|
|
138
|
+
e4f5g6h Update CI pipeline
|
|
139
|
+
i7j8k9l Bump version to 2.3.1
|
|
140
|
+
m0n1o2p Add docker-compose.yml
|
|
141
|
+
q3r4s5t Refactor database migrations
|
|
142
|
+
u6v7w8x Change auth timeout from 30m to 1h
|
|
143
|
+
y9z0a1b Fix linting warnings
|
|
144
|
+
c2d3e4f Update dependencies
|
|
145
|
+
...
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**After** — the one commit that matters:
|
|
149
|
+
```
|
|
150
|
+
u6v7w8x Change auth timeout from 30m to 1h
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
$ git log --oneline -25 | squeez "find the commit that changed the authentication timeout"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
</details>
|
|
158
|
+
|
|
159
|
+
## Installation
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
pip install squeez
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Quick Start
|
|
166
|
+
|
|
167
|
+
### CLI
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Pipe tool output through squeez
|
|
171
|
+
cat output.txt | squeez "Fix the CSRF validation bug"
|
|
172
|
+
|
|
173
|
+
# Or with a file
|
|
174
|
+
squeez "Fix the CSRF bug" --input-file output.txt
|
|
175
|
+
|
|
176
|
+
# Explicit extract subcommand also works
|
|
177
|
+
squeez extract "Fix the CSRF bug" --input-file output.txt
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Python API
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
from squeez.inference.extractor import ToolOutputExtractor
|
|
184
|
+
|
|
185
|
+
# Load model from config/env
|
|
186
|
+
extractor = ToolOutputExtractor()
|
|
187
|
+
|
|
188
|
+
# Or load model locally
|
|
189
|
+
extractor = ToolOutputExtractor(model_path="./output/squeez_qwen")
|
|
190
|
+
|
|
191
|
+
# Or connect to a server explicitly
|
|
192
|
+
extractor = ToolOutputExtractor(base_url="http://localhost:8000/v1", model_name="squeez")
|
|
193
|
+
|
|
194
|
+
filtered = extractor.extract(
|
|
195
|
+
task="Fix the CSRF validation bug in middleware",
|
|
196
|
+
tool_output=raw_output,
|
|
197
|
+
)
|
|
198
|
+
print(filtered) # Only the relevant lines
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The model returns JSON: `{"relevant_lines": ["line1", "line2", ...]}` and the `extract()` method joins them into filtered text.
|
|
202
|
+
|
|
203
|
+
### Configuration
|
|
204
|
+
|
|
205
|
+
Backend is resolved in order: CLI args > env vars > config file (`squeez.yaml` or `configs/default.yaml`).
|
|
206
|
+
|
|
207
|
+
```yaml
|
|
208
|
+
# squeez.yaml
|
|
209
|
+
backend: "transformers" # optional preference
|
|
210
|
+
local_model_path: "./output/squeez_qwen"
|
|
211
|
+
# server_url: "https://api.groq.com/openai/v1"
|
|
212
|
+
# server_model: "squeez"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Or via environment variables
|
|
217
|
+
export SQUEEZ_LOCAL_MODEL=./output/squeez_qwen
|
|
218
|
+
export SQUEEZ_SERVER_URL=https://api.groq.com/openai/v1
|
|
219
|
+
export SQUEEZ_SERVER_MODEL=squeez
|
|
220
|
+
export SQUEEZ_API_KEY=gsk_...
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Clear flag names are available on the CLI, with the old names kept as aliases:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
squeez "Fix the bug" --local-model ./output/squeez_qwen
|
|
227
|
+
squeez "Fix the bug" --server-url http://localhost:8000/v1 --server-model squeez
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Use with Claude Code
|
|
231
|
+
|
|
232
|
+
Add this to your project's `CLAUDE.md` (or `~/.claude/CLAUDE.md` for global):
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
Always when you invoke a shell command, pipe it through `squeez` and tell exactly what you want to know.
|
|
236
|
+
|
|
237
|
+
Examples:
|
|
238
|
+
- `bun test 2>&1 | squeez "did the tests pass?"`
|
|
239
|
+
- `git log --oneline -50 | squeez "find the commit that broke CSRF"`
|
|
240
|
+
- `cat src/auth/middleware.py | squeez "find the referer validation logic"`
|
|
241
|
+
|
|
242
|
+
Do NOT use squeez when:
|
|
243
|
+
- You need exact, uncompressed output (e.g. writing a patch)
|
|
244
|
+
- The command is interactive
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
This saves context tokens by replacing verbose tool output with only the relevant lines.
|
|
248
|
+
|
|
249
|
+
Also works with other coding agents (Codex CLI, OpenCode, etc.) via their equivalent instruction files.
|
|
250
|
+
|
|
251
|
+
## Training
|
|
252
|
+
|
|
253
|
+
### 1. Download the dataset
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
python scripts/download_data.py
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
This pulls the [SWE-bench tool output dataset](https://huggingface.co/datasets/KRLabsOrg/tool-output-extraction-swebench) (7,148 train + 436 eval samples) from HuggingFace.
|
|
260
|
+
|
|
261
|
+
### 2. Train with LoRA
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
squeez train \
|
|
265
|
+
--train-file data/train.jsonl \
|
|
266
|
+
--eval-file data/eval.jsonl
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Default: Qwen 3.5 2B with LoRA (r=16, alpha=32). See `configs/default.yaml` for all hyperparameters.
|
|
270
|
+
|
|
271
|
+
### 3. Evaluate
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
squeez eval \
|
|
275
|
+
--extractor-model output/squeez_qwen \
|
|
276
|
+
--eval-file data/eval.jsonl
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Dataset
|
|
280
|
+
|
|
281
|
+
Training data: [KRLabsOrg/tool-output-extraction-swebench](https://huggingface.co/datasets/KRLabsOrg/tool-output-extraction-swebench)
|
|
282
|
+
|
|
283
|
+
| | Count |
|
|
284
|
+
|---|---|
|
|
285
|
+
| Train samples | 7,148 |
|
|
286
|
+
| Eval samples | 436 |
|
|
287
|
+
| With relevant lines | 3,985 (53%) |
|
|
288
|
+
| Empty (not relevant) | 3,599 (47%) |
|
|
289
|
+
| Avg compression | 86% |
|
|
290
|
+
|
|
291
|
+
Built from 2,294 [SWE-bench](https://huggingface.co/datasets/princeton-nlp/SWE-bench) instances with real tool execution (git grep, git blame, pytest, ruff, etc.) against 12 repos. Teacher distillation by gpt-oss-120b on Groq.
|
|
292
|
+
|
|
293
|
+
### Tool types
|
|
294
|
+
|
|
295
|
+
| Tool Type | Count |
|
|
296
|
+
|---|---|
|
|
297
|
+
| read_file | 4,309 |
|
|
298
|
+
| git_log | 840 |
|
|
299
|
+
| grep | 575 |
|
|
300
|
+
| build_output | 380 |
|
|
301
|
+
| ls | 376 |
|
|
302
|
+
| test_output | 344 |
|
|
303
|
+
| python | 310 |
|
|
304
|
+
| git_blame | 201 |
|
|
305
|
+
| lint_output | 101 |
|
|
306
|
+
| curl | 95 |
|
|
307
|
+
| git_diff | 53 |
|
|
308
|
+
|
|
309
|
+
## How It Works
|
|
310
|
+
|
|
311
|
+
1. **Source**: SWE-bench test split (2,294 real GitHub issues)
|
|
312
|
+
2. **Tool calls**: 3-7 synthetic tool calls per instance
|
|
313
|
+
3. **Real execution**: All commands run against bare-cloned repos at the correct commit
|
|
314
|
+
4. **Teacher distillation**: gpt-oss-120b selects relevant line ranges via JSON spans
|
|
315
|
+
5. **Zero-hallucination extraction**: Teacher spans matched against original output — no generated text
|
|
316
|
+
6. **Assembly**: Extracted lines formatted as `{"relevant_lines": [...]}` for SFT training
|
|
317
|
+
|
|
318
|
+
## Data Generation
|
|
319
|
+
|
|
320
|
+
To regenerate the dataset from scratch:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
squeez pipeline --phase 1 2 3 4 5 6 7 8 \
|
|
324
|
+
--output-dir data \
|
|
325
|
+
--github-token $GITHUB_TOKEN \
|
|
326
|
+
--teacher-api-key $GROQ_API_KEY \
|
|
327
|
+
--teacher-base-url https://api.groq.com/openai/v1
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Citation
|
|
331
|
+
|
|
332
|
+
```bibtex
|
|
333
|
+
@software{kovacs2026squeez,
|
|
334
|
+
title={Squeez: Compressing Tool Output for LLM Coding Agents},
|
|
335
|
+
author={Adam Kovacs},
|
|
336
|
+
year={2026},
|
|
337
|
+
url={https://github.com/KRLabsOrg/squeez}
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Built on top of SWE-bench:
|
|
342
|
+
|
|
343
|
+
```bibtex
|
|
344
|
+
@inproceedings{jimenez2024swebench,
|
|
345
|
+
title={SWE-bench: Can Language Models Resolve Real-world Github Issues?},
|
|
346
|
+
author={Carlos E Jimenez and John Yang and Alexander Wettig and Shunyu Yao and Kexin Pei and Ofir Press and Karthik R Narasimhan},
|
|
347
|
+
booktitle={The Twelfth International Conference on Learning Representations},
|
|
348
|
+
year={2024}
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## License
|
|
353
|
+
|
|
354
|
+
Apache 2.0
|