Fixed inference
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 35,
+ "execution_count": 15,
"metadata": {},
"outputs": [
{
},
{
"cell_type": "code",
- "execution_count": 36,
+ "execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
" model.eval()\n",
" for k in range(steps):\n",
" x_cond = x if x.size(1) <= block_size else x[:, -block_size:] # crop context if needed\n",
- " logits = model.local_forward(x, training=False)\n",
+ " logits = model.local_forward(x_cond, training=False)\n",
" logits = model.target_layer(logits.local_hidden)\n",
" # pluck the logits at the final step and scale by temperature\n",
" logits = logits[:, -1, :] / temperature\n",
},
{
"cell_type": "code",
- "execution_count": 44,
+ "execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Potato was made of her work of himself in I gave to me of a book\n"
+ "John is not certain by everyone that Fred is certain.Bill saw him.You washed yourself.Sally believes that she is pregnantAnson became hoping for as much, too much good nice.What did you eat?They can do that, can they'd go to the dentist to be book.Mary didn't see up a fool the boys.The child was never crazy.John has not must eaten.John must eaten the deep fried muffins.Mary doesn't have been eating cake, but John will.John did not here.John convinced the fool to be sound.John talked to a fool.A lion is majestic.You may pick any flower.John talked to any woman who saw himYou doesn't pick any play of the station.Mary didn't see Mary and Bill and him tried to come to goynally a good, and.I saw Mary and she together together, and that he were pregnant.You must go to the station, and the flowers had we had all any\n"
]
}
],
"source": [
- "context = \"Potato\"\n",
+ "context = \"John\"\n",
"\n",
"# Tokenize the input\n",
"x = tokenizer(context, padding=True, truncation=True)['input_ids']\n",
"x = x.unsqueeze(0)\n",
"\n",
"# Let's sample the network for some output\n",
- "y = sample(model, x, 15, temperature=1.0, sample=True, top_k=10)\n",
+ "y = sample(model, x, 200, temperature=1.0, sample=True, top_k=10)\n",
"\n",
"# Decode the output\n",
"completion = ''.join([tokenizer.decode(i, skip_special_tokens=True) for i in y])\n",
