Skip to content

Commit

Permalink
use default value for temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed May 19, 2024
1 parent 1b340c9 commit 1463b2a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ch05/01_main-chapter-code/ch05.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@
"metadata": {},
"outputs": [],
"source": [
"def generate(model, idx, max_new_tokens, context_size, temperature, top_k=None, eos_id=None):\n",
"def generate(model, idx, max_new_tokens, context_size, temperature=1.0, top_k=None, eos_id=None):\n",
"\n",
" # For-loop is the same as before: Get logits, and only focus on last time step\n",
" for _ in range(max_new_tokens):\n",
Expand Down
2 changes: 1 addition & 1 deletion ch05/02_alternative_weight_loading/previous_chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def token_ids_to_text(token_ids, tokenizer):
return tokenizer.decode(flat.tolist())


def generate(model, idx, max_new_tokens, context_size, temperature, top_k=None, eos_id=None):
def generate(model, idx, max_new_tokens, context_size, temperature=1.0, top_k=None, eos_id=None):

# For-loop is the same as before: Get logits, and only focus on last time step
for _ in range(max_new_tokens):
Expand Down
2 changes: 1 addition & 1 deletion ch06/02_bonus_additional-experiments/previous_chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def load_weights_into_gpt(gpt, params):
gpt.out_head.weight = assign(gpt.out_head.weight, params["wte"])


def generate(model, idx, max_new_tokens, context_size, temperature, top_k=None, eos_id=None):
def generate(model, idx, max_new_tokens, context_size, temperature=1.0, top_k=None, eos_id=None):
# For-loop is the same as before: Get logits, and only focus on last time step
for _ in range(max_new_tokens):
idx_cond = idx[:, -context_size:]
Expand Down

0 comments on commit 1463b2a

Please sign in to comment.