Skip to content

Commit 913bf45

Browse files
authored
Merge pull request #16 from john0isaac/ch2/review-garbage-output
2 parents 73f931c + 1dd65f5 commit 913bf45

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎code/chapter02/quickstart.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ def step4_compare(model, tokenizer, demo_rows: List[Dict[str, Any]]) -> List[Dic
243243
is now domain-tuned.
244244
"""
245245
print("Step 4: compare outputs on held-out prompts")
246+
# SFTTrainer leaves the model in train mode, where gradient checkpointing drops
247+
# the KV cache and generate() produces garbage. eval() restores normal decoding.
248+
model.eval()
246249
samples: List[Dict[str, str]] = []
247250
for row in demo_rows:
248251
ctx = row.get("context", "") or ""

0 commit comments

Comments
 (0)