mirror of
				https://github.com/rasbt/LLMs-from-scratch.git
				synced 2025-11-04 11:50:14 +00:00 
			
		
		
		
	improve code comments
This commit is contained in:
		
							parent
							
								
									78ed2e35bc
								
							
						
					
					
						commit
						f6266c3756
					
				@ -1315,7 +1315,7 @@
 | 
				
			|||||||
   "outputs": [],
 | 
					   "outputs": [],
 | 
				
			||||||
   "source": [
 | 
					   "source": [
 | 
				
			||||||
    "def generate_text_simple(model, idx, max_new_tokens, context_size):\n",
 | 
					    "def generate_text_simple(model, idx, max_new_tokens, context_size):\n",
 | 
				
			||||||
    "    # idx is (B, T) array of indices in the current context\n",
 | 
					    "    # idx is (batch, n_tokens) array of indices in the current context\n",
 | 
				
			||||||
    "    for _ in range(max_new_tokens):\n",
 | 
					    "    for _ in range(max_new_tokens):\n",
 | 
				
			||||||
    "        \n",
 | 
					    "        \n",
 | 
				
			||||||
    "        # Crop current context if it exceeds the supported context size\n",
 | 
					    "        # Crop current context if it exceeds the supported context size\n",
 | 
				
			||||||
@ -1328,7 +1328,7 @@
 | 
				
			|||||||
    "            logits = model(idx_cond)\n",
 | 
					    "            logits = model(idx_cond)\n",
 | 
				
			||||||
    "        \n",
 | 
					    "        \n",
 | 
				
			||||||
    "        # Focus only on the last time step\n",
 | 
					    "        # Focus only on the last time step\n",
 | 
				
			||||||
    "        # (batch, n_token, vocab_size) becomes (batch, vocab_size)\n",
 | 
					    "        # (batch, n_tokens, vocab_size) becomes (batch, vocab_size)\n",
 | 
				
			||||||
    "        logits = logits[:, -1, :]  \n",
 | 
					    "        logits = logits[:, -1, :]  \n",
 | 
				
			||||||
    "\n",
 | 
					    "\n",
 | 
				
			||||||
    "        # Apply softmax to get probabilities\n",
 | 
					    "        # Apply softmax to get probabilities\n",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user