You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -538,6 +538,7 @@ TextAgent has undergone significant evolution since its inception. What started
538
538
539
539
| Date | Commits | Feature / Update |
540
540
|------|---------|-----------------:|
541
+
|**2026-03-28**|| 🤖 **Qwen Loop Fix** — switched to Qwen 3.5 official generation params (`presence_penalty: 2.0`, `repetition_penalty: 1.0`); added degenerate output circuit breaker (unique-word ratio monitoring in 200-char sliding window, auto-abort at 30% threshold); `trimToLastSentence()` graceful cleanup on abort; `no_repeat_ngram_size: 6` secondary guard; fixes all local Qwen models producing garbage/looping text |
541
542
|**2026-03-28**|| 🔗 **Space-Aware Sharing** — moved "Add to Space" dropdown to the pre-share modal; generates unified `#space=<slug>&s=<id>` URLs that load the document within its space context; converted management items to clickable anchor tags opening directly to the doc |
542
543
|**2026-03-28**|| 🎓 **Quiz Progress Bar Fix** — fixed progress bar not syncing with respondent navigation; bar now tracks current question position instead of answered-question count; `gotoScreen()` now updates HUD on every navigation |
543
544
|**2026-03-27**|| 📊 **ECharts Chart System** — new `{{Chart:}}` DocGen tag with 7 declarative chart types (bar, line, pie, scatter, radar, gauge, heatmap) and raw ECharts JS code mode; `chart-docgen.js` (~720 lines) parser/builder/transformer; `chart-docgen.css` + `echarts.css` styling; lazy-loaded ECharts CDN via `window.getECharts()`; 📊 Chart toolbar button, composer chip, mobile integration; 11 chart gallery templates (Line, Bar, Pie, Scatter, Sunburst, Treemap, Advanced, Sankey, Parallel, Graph) with ~4,200 lines of copy-paste-ready examples; new Charts template category |
# Qwen Loop Fix — Official Params + Circuit Breaker
2
+
3
+
- Switched to Qwen 3.5 official generation parameters: `presence_penalty: 2.0` (non-thinking), `1.5` (thinking)
4
+
- Set `repetition_penalty: 1.0` per official model card (high values cause unnatural text)
5
+
- Kept `no_repeat_ngram_size: 6` as secondary safety net against exact phrase repetition
6
+
- Added degenerate output circuit breaker: monitors unique-word ratio in 200-char sliding window every 40 tokens
7
+
- Circuit breaker aborts generation when unique ratio drops below 30% (garbage loop detected)
8
+
- Added `trimToLastSentence()` cleanup — when circuit breaker fires, output trims to last coherent sentence boundary
9
+
- Fixed: Qwen models (0.8B, 2B, 4B) producing garbage/looping text on open-ended prompts
10
+
11
+
---
12
+
13
+
## Summary
14
+
Qwen local models were entering degenerate text generation loops, producing garbage output. Root cause: incorrect `repetition_penalty` settings (too high, against official recommendations) and no runtime degeneration detection. Fix applies Qwen 3.5 official model card parameters (`presence_penalty: 2.0`) and adds a circuit breaker that monitors output quality during streaming.
**What:** Replaced `repetition_penalty: 1.3–1.5` with Qwen 3.5 official parameters: `presence_penalty: 2.0` (non-thinking) / `1.5` (thinking), `repetition_penalty: 1.0`. The `presence_penalty` penalizes tokens by *presence* (more effective against thematic loops) vs `repetition_penalty` which penalizes by *frequency* and causes unnatural phrasing when >1.5.
21
+
**Impact:** Eliminates the root cause of garbage text loops while maintaining natural output quality.
**What:** Added `isDegenerate()` function that monitors unique-word ratio in a 200-char sliding window every 40 tokens. If ratio drops below 30%, sets `_degenAborted` flag to stop token emission. Added `trimToLastSentence()` to gracefully truncate output at the last sentence boundary when circuit breaker fires.
26
+
**Impact:** Even if generation params fail to prevent loops, the circuit breaker catches garbage output in real-time and provides a clean truncated response instead of endless gibberish.
27
+
28
+
---
29
+
30
+
## Files Changed (2 total)
31
+
32
+
| File | Lines Changed | Type |
33
+
|------|:---:|------|
34
+
|`public/ai-worker.js`| +77 −8 | Official params + circuit breaker |
0 commit comments