Browse Source

Clarify dataset length in chapter 2 (#589)

Sebastian Raschka 7 tháng trước cách đây
mục cha
commit
6ea4dd3ae7
1 tập tin đã thay đổi với 1 bổ sung0 xóa
  1. 1 0
      ch02/01_main-chapter-code/ch02.ipynb

+ 1 - 0
ch02/01_main-chapter-code/ch02.ipynb

@@ -1296,6 +1296,7 @@
     "\n",
     "        # Tokenize the entire text\n",
     "        token_ids = tokenizer.encode(txt, allowed_special={\"<|endoftext|>\"})\n",
+    "        assert len(token_ids) > max_length, \"Number of tokenized inputs must at least be equal to max_length+1\"\n",
     "\n",
     "        # Use a sliding window to chunk the book into overlapping sequences of max_length\n",
     "        for i in range(0, len(token_ids) - max_length, stride):\n",