entroplain 0.1.0
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.
- package/CONTRIBUTING.md +103 -0
- package/LICENSE +21 -0
- package/README.md +389 -0
- package/dist/entroplain-0.1.0-py3-none-any.whl +0 -0
- package/dist/entroplain-0.1.0.tar.gz +0 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/monitor.d.ts.map +1 -0
- package/dist/types.d.ts.map +1 -0
- package/docs/USAGE.md +302 -0
- package/entroplain/__init__.py +30 -0
- package/entroplain/cli.py +152 -0
- package/entroplain/hooks.py +183 -0
- package/entroplain/monitor.py +272 -0
- package/entroplain/providers.py +626 -0
- package/examples.md +40 -0
- package/package.json +44 -0
- package/pyproject.toml +85 -0
- package/src/hooks.ts +130 -0
- package/src/index.ts +9 -0
- package/src/monitor.ts +252 -0
- package/src/types.ts +58 -0
- package/tests/test_functional.py +303 -0
- package/tests/test_monitor.py +165 -0
- package/tsconfig.json +19 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Contributing to Entroplain
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! 🎉
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Clone the repo
|
|
9
|
+
git clone https://github.com/entroplain/entroplain.git
|
|
10
|
+
cd entroplain
|
|
11
|
+
|
|
12
|
+
# Create virtual environment
|
|
13
|
+
python -m venv .venv
|
|
14
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
15
|
+
|
|
16
|
+
# Install in development mode
|
|
17
|
+
pip install -e ".[dev]"
|
|
18
|
+
|
|
19
|
+
# Run tests
|
|
20
|
+
pytest
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Project Structure
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
entroplain/
|
|
27
|
+
├── entroplain/
|
|
28
|
+
│ ├── __init__.py # Package exports
|
|
29
|
+
│ ├── monitor.py # Core entropy monitor
|
|
30
|
+
│ ├── providers.py # LLM provider integrations
|
|
31
|
+
│ ├── hooks.py # Agent framework hooks
|
|
32
|
+
│ └── cli.py # Command-line interface
|
|
33
|
+
├── tests/
|
|
34
|
+
│ └── test_monitor.py # Unit tests
|
|
35
|
+
├── pyproject.toml # Package config
|
|
36
|
+
├── README.md # Documentation
|
|
37
|
+
└── LICENSE # MIT License
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Adding a New Provider
|
|
41
|
+
|
|
42
|
+
1. Create a new provider class in `providers.py`:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
class MyProvider(BaseProvider):
|
|
46
|
+
def calculate_entropy(self, logprobs_data: Dict) -> float:
|
|
47
|
+
# Parse provider-specific format
|
|
48
|
+
...
|
|
49
|
+
|
|
50
|
+
def stream_with_entropy(self, **kwargs) -> Iterator[TokenWithEntropy]:
|
|
51
|
+
# Stream tokens with entropy
|
|
52
|
+
...
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. Export it in `__init__.py`
|
|
56
|
+
|
|
57
|
+
3. Add tests in `tests/test_providers.py`
|
|
58
|
+
|
|
59
|
+
## Code Style
|
|
60
|
+
|
|
61
|
+
- Use **Black** for formatting
|
|
62
|
+
- Use **isort** for imports
|
|
63
|
+
- Use **mypy** for type checking
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
black entroplain/ tests/
|
|
67
|
+
isort entroplain/ tests/
|
|
68
|
+
mypy entroplain/
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Testing
|
|
72
|
+
|
|
73
|
+
Run all tests:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pytest
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Run with coverage:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pytest --cov=entroplain
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Pull Request Process
|
|
86
|
+
|
|
87
|
+
1. Fork the repo
|
|
88
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
89
|
+
3. Make your changes
|
|
90
|
+
4. Add tests for new functionality
|
|
91
|
+
5. Ensure all tests pass (`pytest`)
|
|
92
|
+
6. Format code (`black .`)
|
|
93
|
+
7. Commit changes (`git commit -m 'Add amazing feature'`)
|
|
94
|
+
8. Push to branch (`git push origin feature/amazing-feature`)
|
|
95
|
+
9. Open a Pull Request
|
|
96
|
+
|
|
97
|
+
## Questions?
|
|
98
|
+
|
|
99
|
+
Open an issue or join our Discord: https://discord.gg/entroplain
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Entroplain Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
# Entroplain
|
|
2
|
+
|
|
3
|
+
**Entropy-based early exit for efficient agent reasoning.**
|
|
4
|
+
|
|
5
|
+
Stop burning tokens. Know when your agent has finished thinking.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What It Does
|
|
10
|
+
|
|
11
|
+
Entroplain monitors your LLM's **predictive entropy** — the uncertainty in its output distribution — to detect when reasoning has converged.
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
High entropy → Model is searching, exploring, uncertain
|
|
15
|
+
Low entropy → Model is confident, converged, ready to output
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Key insight:** Reasoning follows a multi-modal entropy trajectory. Local minima ("valleys") mark reasoning milestones. Exit at the right valley, save 40-60% compute with minimal accuracy loss.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Python (pip)
|
|
28
|
+
pip install entroplain
|
|
29
|
+
|
|
30
|
+
# Node.js (npm)
|
|
31
|
+
npm install entroplain
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Requirements
|
|
35
|
+
|
|
36
|
+
**Python:** 3.8+
|
|
37
|
+
|
|
38
|
+
**Node.js:** 18+
|
|
39
|
+
|
|
40
|
+
**For cloud providers:** Set API keys via environment variables:
|
|
41
|
+
```bash
|
|
42
|
+
export OPENAI_API_KEY=sk-...
|
|
43
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
44
|
+
export NVIDIA_API_KEY=nvapi-...
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**For local models:** Install [Ollama](https://ollama.ai) or [llama.cpp](https://github.com/ggerganov/llama.cpp)
|
|
48
|
+
|
|
49
|
+
### Use with Any Agent
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from entroplain import EntropyMonitor
|
|
53
|
+
|
|
54
|
+
monitor = EntropyMonitor()
|
|
55
|
+
|
|
56
|
+
# Stream tokens with entropy tracking
|
|
57
|
+
async for token, entropy in monitor.stream(agent.generate()):
|
|
58
|
+
print(f"{token} (entropy: {entropy:.3f})")
|
|
59
|
+
|
|
60
|
+
# Detect reasoning convergence
|
|
61
|
+
if monitor.is_converged():
|
|
62
|
+
break # Early exit — reasoning complete
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## How It Works
|
|
68
|
+
|
|
69
|
+
### 1. Track Entropy Per Token
|
|
70
|
+
|
|
71
|
+
Every token has an entropy value derived from the model's output distribution:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
entropy = -sum(p * log2(p) for p in probabilities if p > 0)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. Detect Valleys
|
|
78
|
+
|
|
79
|
+
Local minima in the entropy trajectory indicate reasoning milestones:
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
Entropy: 0.8 → 0.6 → 0.3* → 0.5 → 0.2* → 0.1*
|
|
83
|
+
↑ ↑
|
|
84
|
+
Valley 1 Valley 2
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 3. Exit at the Right Moment
|
|
88
|
+
|
|
89
|
+
When valley count plateaus and velocity stabilizes, reasoning is complete.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Experimental Evidence
|
|
94
|
+
|
|
95
|
+
Tested on Llama-3.1-70b via NVIDIA API:
|
|
96
|
+
|
|
97
|
+
| Difficulty | Avg Valleys | Avg Entropy | Avg Velocity |
|
|
98
|
+
|------------|-------------|-------------|--------------|
|
|
99
|
+
| Easy | 61.3 | 0.3758 | 0.4852 |
|
|
100
|
+
| Medium | 53.0 | 0.3267 | 0.4394 |
|
|
101
|
+
| Hard | 70.2 | 0.2947 | 0.4095 |
|
|
102
|
+
|
|
103
|
+
**Finding:** Hard problems have more entropy valleys (70.2 vs 61.3) — valleys correlate with reasoning complexity.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Platform Support
|
|
108
|
+
|
|
109
|
+
| Platform | Support | How to Enable |
|
|
110
|
+
|----------|---------|---------------|
|
|
111
|
+
| **Local (llama.cpp, Ollama)** | ✅ Full | Built-in, no config |
|
|
112
|
+
| **OpenAI** | ✅ Yes | `logprobs: true` |
|
|
113
|
+
| **Anthropic Claude** | ✅ Yes (Claude 4) | `logprobs: True` |
|
|
114
|
+
| **Google Gemini** | ✅ Yes | `response_logprobs=True` |
|
|
115
|
+
| **NVIDIA NIM** | ✅ Yes | `logprobs: true` |
|
|
116
|
+
| **OpenRouter** | ⚠️ Partial | ~23% of models support it |
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Integration Examples
|
|
121
|
+
|
|
122
|
+
### OpenAI / NVIDIA / OpenRouter
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from openai import OpenAI
|
|
126
|
+
from entroplain import EntropyMonitor
|
|
127
|
+
|
|
128
|
+
client = OpenAI()
|
|
129
|
+
monitor = EntropyMonitor()
|
|
130
|
+
|
|
131
|
+
response = client.chat.completions.create(
|
|
132
|
+
model="gpt-4o",
|
|
133
|
+
messages=[{"role": "user", "content": "Solve this step by step..."}],
|
|
134
|
+
logprobs=True,
|
|
135
|
+
top_logprobs=5,
|
|
136
|
+
stream=True
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
for chunk in response:
|
|
140
|
+
if chunk.choices[0].delta.content:
|
|
141
|
+
token = chunk.choices[0].delta.content
|
|
142
|
+
entropy = monitor.calculate_entropy(chunk.choices[0].logprobs)
|
|
143
|
+
|
|
144
|
+
if monitor.should_exit():
|
|
145
|
+
print("\n[Early exit — reasoning converged]")
|
|
146
|
+
break
|
|
147
|
+
|
|
148
|
+
print(token, end="")
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Ollama (Local)
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
import ollama
|
|
155
|
+
from entroplain import EntropyMonitor
|
|
156
|
+
|
|
157
|
+
monitor = EntropyMonitor()
|
|
158
|
+
|
|
159
|
+
# Ollama exposes logits for local models
|
|
160
|
+
response = ollama.generate(
|
|
161
|
+
model="llama3.1",
|
|
162
|
+
prompt="Think through this carefully...",
|
|
163
|
+
options={"num_ctx": 4096}
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
# Direct access to token probabilities
|
|
167
|
+
for token_data in response.get("token_probs", []):
|
|
168
|
+
entropy = monitor.calculate_from_logits(token_data["logits"])
|
|
169
|
+
monitor.track(token_data["token"], entropy)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Anthropic Claude
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from anthropic import Anthropic
|
|
176
|
+
from entroplain import EntropyMonitor
|
|
177
|
+
|
|
178
|
+
client = Anthropic()
|
|
179
|
+
monitor = EntropyMonitor()
|
|
180
|
+
|
|
181
|
+
with client.messages.stream(
|
|
182
|
+
model="claude-sonnet-4-20250514",
|
|
183
|
+
max_tokens=1024,
|
|
184
|
+
messages=[{"role": "user", "content": "Analyze this..."}],
|
|
185
|
+
) as stream:
|
|
186
|
+
for text in stream.text_stream:
|
|
187
|
+
entropy = monitor.get_entropy()
|
|
188
|
+
if monitor.should_exit():
|
|
189
|
+
break
|
|
190
|
+
print(text, end="", flush=True)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Agent Frameworks
|
|
194
|
+
|
|
195
|
+
**OpenClaw:**
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
# In your agent config
|
|
199
|
+
entropy_monitor:
|
|
200
|
+
enabled: true
|
|
201
|
+
exit_threshold: 0.15 # Exit when entropy drops below this
|
|
202
|
+
min_valleys: 3 # Require at least N reasoning milestones
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Claude Code:**
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"hooks": {
|
|
210
|
+
"on_token": "entroplain.hooks.track_entropy",
|
|
211
|
+
"on_converge": "entroplain.hooks.early_exit"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Configuration
|
|
219
|
+
|
|
220
|
+
### Environment Variables
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# For cloud providers
|
|
224
|
+
ENTROPPLAIN_OPENAI_API_KEY=sk-...
|
|
225
|
+
ENTROPPLAIN_ANTHROPIC_API_KEY=sk-ant-...
|
|
226
|
+
ENTROPPLAIN_NVIDIA_API_KEY=nvapi-...
|
|
227
|
+
|
|
228
|
+
# For local models
|
|
229
|
+
ENTROPPLAIN_LOCAL_PROVIDER=ollama # or llama.cpp
|
|
230
|
+
ENTROPPLAIN_LOCAL_MODEL=llama3.1
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Exit Conditions
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
monitor = EntropyMonitor(
|
|
237
|
+
# Exit when entropy drops below threshold
|
|
238
|
+
entropy_threshold=0.15,
|
|
239
|
+
|
|
240
|
+
# Require minimum valleys before exit
|
|
241
|
+
min_valleys=2,
|
|
242
|
+
|
|
243
|
+
# Exit when velocity stabilizes (change < this)
|
|
244
|
+
velocity_threshold=0.05,
|
|
245
|
+
|
|
246
|
+
# Don't exit before N tokens
|
|
247
|
+
min_tokens=50,
|
|
248
|
+
|
|
249
|
+
# Custom exit condition
|
|
250
|
+
exit_condition="valleys_plateau" # or "entropy_drop", "velocity_zero"
|
|
251
|
+
)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## CLI Usage
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Analyze a prompt's entropy trajectory
|
|
260
|
+
entroplain analyze "What is 2+2?" --model gpt-4o
|
|
261
|
+
|
|
262
|
+
# Stream with early exit
|
|
263
|
+
entroplain stream "Solve this step by step: x^2 = 16" --exit-on-converge
|
|
264
|
+
|
|
265
|
+
# Benchmark entropy patterns
|
|
266
|
+
entroplain benchmark --problems gsm8k --output results.json
|
|
267
|
+
|
|
268
|
+
# Visualize entropy trajectory
|
|
269
|
+
entroplain visualize results.json --output entropy_plot.png
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## API Reference
|
|
275
|
+
|
|
276
|
+
### `EntropyMonitor`
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
class EntropyMonitor:
|
|
280
|
+
def __init__(
|
|
281
|
+
self,
|
|
282
|
+
entropy_threshold: float = 0.15,
|
|
283
|
+
min_valleys: int = 2,
|
|
284
|
+
velocity_threshold: float = 0.05,
|
|
285
|
+
min_tokens: int = 50
|
|
286
|
+
): ...
|
|
287
|
+
|
|
288
|
+
def calculate_entropy(self, logprobs: List[float]) -> float:
|
|
289
|
+
"""Calculate Shannon entropy from log probabilities."""
|
|
290
|
+
|
|
291
|
+
def track(self, token: str, entropy: float) -> None:
|
|
292
|
+
"""Track a token and its entropy value."""
|
|
293
|
+
|
|
294
|
+
def get_valleys(self) -> List[Tuple[int, float]]:
|
|
295
|
+
"""Get all entropy valleys (local minima)."""
|
|
296
|
+
|
|
297
|
+
def get_velocity(self) -> float:
|
|
298
|
+
"""Get current entropy velocity (rate of change)."""
|
|
299
|
+
|
|
300
|
+
def should_exit(self) -> bool:
|
|
301
|
+
"""Determine if reasoning has converged."""
|
|
302
|
+
|
|
303
|
+
def is_converged(self) -> bool:
|
|
304
|
+
"""Alias for should_exit()."""
|
|
305
|
+
|
|
306
|
+
def get_trajectory(self) -> List[float]:
|
|
307
|
+
"""Get full entropy trajectory."""
|
|
308
|
+
|
|
309
|
+
def reset(self) -> None:
|
|
310
|
+
"""Clear all tracked data."""
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### `calculate_entropy(logprobs)`
|
|
314
|
+
|
|
315
|
+
```python
|
|
316
|
+
from entroplain import calculate_entropy
|
|
317
|
+
|
|
318
|
+
# From log probabilities
|
|
319
|
+
entropy = calculate_entropy([-0.5, -2.1, -0.1, -5.2])
|
|
320
|
+
# Returns: 0.847
|
|
321
|
+
|
|
322
|
+
# From probabilities
|
|
323
|
+
entropy = calculate_entropy([0.6, 0.125, 0.9, 0.005], from_probs=True)
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Research
|
|
329
|
+
|
|
330
|
+
### Paper
|
|
331
|
+
|
|
332
|
+
See [`paper.md`](./paper.md) for the full research proposal: **"Entropy-Based Early Exit for Efficient Agent Reasoning"**
|
|
333
|
+
|
|
334
|
+
### Key Findings
|
|
335
|
+
|
|
336
|
+
1. **H1 Supported:** Entropy valleys correlate with reasoning complexity (70.2 valleys for hard problems vs 61.3 for easy)
|
|
337
|
+
2. **H2 Supported:** Entropy velocity differs by difficulty (0.4852 easy vs 0.4095 hard)
|
|
338
|
+
3. **Potential:** 40-60% compute reduction with 95%+ accuracy retention
|
|
339
|
+
|
|
340
|
+
### Citation
|
|
341
|
+
|
|
342
|
+
```bibtex
|
|
343
|
+
@software{entroplain2026,
|
|
344
|
+
title = {Entroplain: Entropy-Based Early Exit for Efficient Agent Reasoning},
|
|
345
|
+
author = {Entroplain Contributors},
|
|
346
|
+
year = {2026},
|
|
347
|
+
url = {https://github.com/entroplain/entroplain}
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## Roadmap
|
|
354
|
+
|
|
355
|
+
- [ ] v0.1.0 — Core entropy tracking (Python)
|
|
356
|
+
- [ ] v0.2.0 — Multi-provider support (OpenAI, Anthropic, Gemini, NVIDIA)
|
|
357
|
+
- [ ] v0.3.0 — Local model support (llama.cpp, Ollama)
|
|
358
|
+
- [ ] v0.4.0 — Agent framework integrations (OpenClaw, Claude Code)
|
|
359
|
+
- [ ] v0.5.0 — JavaScript/Node.js SDK
|
|
360
|
+
- [ ] v1.0.0 — Production release with benchmarks
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Contributing
|
|
365
|
+
|
|
366
|
+
We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
367
|
+
|
|
368
|
+
### Development Setup
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
git clone https://github.com/entroplain/entroplain.git
|
|
372
|
+
cd entroplain
|
|
373
|
+
pip install -e ".[dev]"
|
|
374
|
+
pytest
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## License
|
|
380
|
+
|
|
381
|
+
MIT License — see [LICENSE](./LICENSE) for details.
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Acknowledgments
|
|
386
|
+
|
|
387
|
+
- Research inspired by early exit architectures in transformers
|
|
388
|
+
- Experimental validation using NVIDIA NIM API
|
|
389
|
+
- Built for the agent-first future of AI
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAgB,YAAY,EAAE,MAAM,SAAS,CAAC;AAMrD;;GAEG;AACH,wBAAgB,SAAS,CAAC,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,IAAI,CAQxE;AAED;;GAEG;AAC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AAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Entroplain — Entropy-based early exit for efficient agent reasoning
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.earlyExit = exports.trackEntropy = exports.EntropyHook = exports.calculateEntropy = exports.EntropyMonitor = void 0;
|
|
23
|
+
var monitor_1 = require("./monitor");
|
|
24
|
+
Object.defineProperty(exports, "EntropyMonitor", { enumerable: true, get: function () { return monitor_1.EntropyMonitor; } });
|
|
25
|
+
Object.defineProperty(exports, "calculateEntropy", { enumerable: true, get: function () { return monitor_1.calculateEntropy; } });
|
|
26
|
+
var hooks_1 = require("./hooks");
|
|
27
|
+
Object.defineProperty(exports, "EntropyHook", { enumerable: true, get: function () { return hooks_1.EntropyHook; } });
|
|
28
|
+
Object.defineProperty(exports, "trackEntropy", { enumerable: true, get: function () { return hooks_1.trackEntropy; } });
|
|
29
|
+
Object.defineProperty(exports, "earlyExit", { enumerable: true, get: function () { return hooks_1.earlyExit; } });
|
|
30
|
+
__exportStar(require("./types"), exports);
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../src/monitor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AAEnF,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,KAAK,CAAa;gBAEd,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM;IAYhD;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,GAAE,OAAe,GAAG,MAAM;IAgBxE;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY;IA+BnD;;OAEG;IACH,UAAU,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIrC;;OAEG;IACH,WAAW,IAAI,MAAM;IAOrB;;OAEG;IACH,cAAc,IAAI,MAAM;IAQxB;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAuB3B;;OAEG;IACH,YAAY,IAAI,OAAO;IAOvB;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;OAEG;IACH,UAAU,IAAI,OAAO;IAyBrB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;OAEG;IACH,SAAS,IAAI,MAAM,EAAE;IAIrB;;OAEG;IACH,QAAQ,IAAI,YAAY;IA4BxB;;OAEG;IACH,KAAK,IAAI,IAAI;CAKd;AAED;;GAEG;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