Spaces:
Running on T4
Running on T4
Drop attention_mask at inference: the checkpoint was trained without one, and generate()'s auto-mask degenerates the output
Browse files
app.py
CHANGED
|
@@ -79,6 +79,20 @@ def _load():
|
|
| 79 |
model = model.to("cuda")
|
| 80 |
model.eval()
|
| 81 |
model.config.use_cache = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
_state.update(model=model, tok=tok, device=dev, status="ready", error=None)
|
| 83 |
except Exception as e: # honest degrade — landing page still works
|
| 84 |
_state.update(status="error", error=str(e)[:500])
|
|
|
|
| 79 |
model = model.to("cuda")
|
| 80 |
model.eval()
|
| 81 |
model.config.use_cache = False
|
| 82 |
+
|
| 83 |
+
# This checkpoint was instruction-tuned with attention_mask=None, so the model
|
| 84 |
+
# never saw a mask during training. generate() builds one automatically, which
|
| 85 |
+
# pushes it off-distribution and degenerates the output ("국가의 수도는 국가의
|
| 86 |
+
# 수도입니다..."). Dropping the mask restores the trained behaviour. Measured
|
| 87 |
+
# 2026-07-20: with mask -> degenerate, without -> correct on every probe.
|
| 88 |
+
_fwd = model.forward
|
| 89 |
+
|
| 90 |
+
def _forward_without_mask(*a, **kw):
|
| 91 |
+
kw.pop("attention_mask", None)
|
| 92 |
+
return _fwd(*a, **kw)
|
| 93 |
+
|
| 94 |
+
model.forward = _forward_without_mask
|
| 95 |
+
|
| 96 |
_state.update(model=model, tok=tok, device=dev, status="ready", error=None)
|
| 97 |
except Exception as e: # honest degrade — landing page still works
|
| 98 |
_state.update(status="error", error=str(e)[:500])
|