|
23 | 23 | "execution_count": 2, |
24 | 24 | "id": "b89279fe", |
25 | 25 | "metadata": {}, |
26 | | - "outputs": [], |
| 26 | + "outputs": [ |
| 27 | + { |
| 28 | + "name": "stderr", |
| 29 | + "output_type": "stream", |
| 30 | + "text": [ |
| 31 | + "/home/aerdem/projects/LLM/llmenv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", |
| 32 | + " warnings.warn(\n", |
| 33 | + "Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n", |
| 34 | + "/home/aerdem/projects/LLM/llmenv/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", |
| 35 | + " warnings.warn(\n" |
| 36 | + ] |
| 37 | + } |
| 38 | + ], |
27 | 39 | "source": [ |
28 | 40 | "from example_notebooks.transformers.utils import LLMRunner\n", |
29 | 41 | "from logits_processor_zoo.transformers import TriggerPhraseLogitsProcessor, GenLengthLogitsProcessor\n", |
|
58 | 70 | "name": "stderr", |
59 | 71 | "output_type": "stream", |
60 | 72 | "text": [ |
| 73 | + "/home/aerdem/projects/LLM/llmenv/lib/python3.10/site-packages/transformers/generation/configuration_utils.py:392: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `None` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.\n", |
| 74 | + " warnings.warn(\n", |
| 75 | + "/home/aerdem/projects/LLM/llmenv/lib/python3.10/site-packages/transformers/generation/configuration_utils.py:397: UserWarning: `do_sample` is set to `False`. However, `top_p` is set to `None` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_p`.\n", |
| 76 | + " warnings.warn(\n", |
| 77 | + "/home/aerdem/projects/LLM/llmenv/lib/python3.10/site-packages/transformers/generation/configuration_utils.py:407: UserWarning: `do_sample` is set to `False`. However, `top_k` is set to `None` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_k`.\n", |
| 78 | + " warnings.warn(\n", |
61 | 79 | "The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.\n", |
62 | | - "Setting `pad_token_id` to `eos_token_id`:None for open-end generation.\n", |
63 | | - "The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.\n" |
| 80 | + "Setting `pad_token_id` to `eos_token_id`:151643 for open-end generation.\n" |
64 | 81 | ] |
65 | 82 | }, |
66 | 83 | { |
|
96 | 113 | "\n", |
97 | 114 | "Let me test this function with some examples. For n=0, it returns 0. For n=1, returns 1. For n=2, it's F(1)+F(0) = 1+0=1. For n=3, F(2)+F(1)=1+1=2. That looks correct.\n", |
98 | 115 | "\n", |
99 | | - "Wait, but sometimes people define the Fibonacci sequence starting with F(1)=1, F(2)=1, F(3)=2, etc. So, if the function is called with n=5, it should return 5. Let me see: F(5) is 5, which is correct.\n", |
| 116 | + "Wait, but sometimes people define the Fibonacci sequence starting with F(1)=1, F(2)=1, F(3)=2, etc. So, if the function is called with n=5, it should return 5. Let me see: F(5) is 5, which matches the standard definition. So, the function should work regardless of the starting point as long as the base cases are correct.\n", |
100 | 117 | "\n", |
101 | | - "Another test case: n=5. Let's compute it step by step. F(0)=0, F(1)=1, F(2)=1, F(3)=2, F(4)=3, F(5)=5. So the function should return 5 for n=5.\n", |
| 118 | + "Another thing to consider is the base cases. If the function is called with n=0, it returns 0, which is correct. For n=1, returns 1. For n=2, returns 1, which is correct. So, the function should handle all non-negative integers correctly.\n", |
102 | 119 | "\n", |
103 | 120 | "I think this should work. So, the function is straightforward. It's a simple recursive implementation, but it's not the most efficient for large n. However, for the purpose of this problem, it's acceptable.\n", |
104 | 121 | "</think>\n", |
|
162 | 179 | "output_type": "stream", |
163 | 180 | "text": [ |
164 | 181 | "The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.\n", |
165 | | - "Setting `pad_token_id` to `eos_token_id`:None for open-end generation.\n" |
| 182 | + "Setting `pad_token_id` to `eos_token_id`:151643 for open-end generation.\n" |
166 | 183 | ] |
167 | 184 | }, |
168 | 185 | { |
|
198 | 215 | "\n", |
199 | 216 | "Let me test this function with some examples. For n=0, it returns 0. For n=1, returns 1. For n=2, it's F(1)+F(0) = 1+0=1. For n=3, F(2)+F(1)=1+1=2. That looks correct.\n", |
200 | 217 | "\n", |
201 | | - "Wait, but sometimes people define the Fibonacci sequence starting with F(1)=1, F(2)=1, F(3)=2, etc. So, if the function is called with n=5, it should return 5. Let me see: F(5) is 5, which is correct.\n", |
| 218 | + "Wait, but sometimes people define the Fibonacci sequence starting with F(1)=1, F(2)=1, F(3)=2, etc. So, if the function is called with n=5, it should return 5. Let me see: F(5) is 5, which matches the standard definition. So, the function should work regardless of the starting point as long as the base cases are correct.\n", |
202 | 219 | "\n", |
203 | | - "Another test case: n=5. Let's compute it step by step. F(0)=0, F(1)=1, F(2)=1, F(3)=2, F(4)=3, F(5)=5. So the function should return 5 for n=5.\n", |
| 220 | + "Another thing to consider is the base cases. If the function is called with n=0, it returns 0, which is correct. For n=1, returns 1. For n=2, returns 1, which is correct. So, the function should handle all non-negative integers correctly.\n", |
204 | 221 | "\n", |
205 | 222 | "I think this should work. So, the function is straightforward. It's a simple recursive implementation, but it's not the most efficient for large n. However, for the purpose of this problem, it's acceptable.\n", |
206 | 223 | ",,,\n", |
207 | 224 | "\n", |
208 | | - "Wait, but the problem says to make it recursive. So, the function as written is recursive. So, I think this should be the solution.\n", |
| 225 | + "Wait, but the problem says to make it recursive. So, the function should call itself with smaller arguments. The approach I have is correct and recursive.\n", |
| 226 | + "\n", |
| 227 | + "So, the final function is as I wrote above.\n", |
209 | 228 | ",,,\n", |
210 | 229 | "\n", |
211 | | - "Wait, but in the function I wrote, for n=0, it returns 0, which is correct. For n=1, returns 1. For n=2, returns 1, which is correct. So, the function should work as intended.\n", |
| 230 | + "Wait, but in the function, for n=2, it's F(1)+F(0) = 1+0=1, which is correct. For n=3, F(2)+F(1)=1+1=2. So, the function works as expected.\n", |
212 | 231 | "\n", |
213 | | - "I think that's a good approach. So, the function is as I wrote above.\n", |
| 232 | + "I think this should solve the problem.\n", |
214 | 233 | "</think>\n", |
215 | 234 | "\n", |
216 | 235 | "To solve this problem, we need to generate the nth Fibonacci number using a recursive approach. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, starting from 0 and 1. \n", |
217 | 236 | "\n", |
218 | 237 | "### Approach\n", |
219 | | - "The approach to solve this problem involves using recursion, which is a method where the function calls itself with a smaller input until it reaches a base case. Here's a step-by-step breakdown of the approach:\n", |
| 238 | + "The approach to solve this problem involves using recursion, which is a method where a function calls itself with a modified parameter to achieve the desired result. Here's a step-by-step breakdown of the approach:\n", |
220 | 239 | "\n", |
221 | 240 | "1. **Base Cases**: \n", |
222 | 241 | " - If `n` is 0, return 0.\n", |
|
236 | 255 | " elif n == 1:\n", |
237 | 256 | " return 1\n", |
238 | 257 | " else:\n", |
239 | | - " return fibonacci(n - 1) + fibonacci(n - 2)\n", |
| 258 | + " return fibonacci(n-1) + fibonacci(n-2)\n", |
240 | 259 | "```\n", |
241 | 260 | "\n", |
242 | 261 | "### Explanation\n", |
243 | 262 | "- **Base Cases**: The function first checks if `n` is 0 or 1. If `n` is 0, it returns 0. If `n` is 1, it returns 1. These are the simplest cases of the Fibonacci sequence.\n", |
244 | 263 | "- **Recursive Case**: For any `n` greater than 1, the function calls itself with `n-1` and `n-2`, and returns the sum of these two recursive calls. This builds up the solution by solving smaller subproblems and combining their results.\n", |
245 | 264 | "\n", |
246 | | - "This approach is straightforward and easy to understand, but it's important to note that it is not the most efficient for large values of `n` due to the exponential time complexity. However, for the purpose of this problem, the recursive approach is sufficient.\n", |
| 265 | + "This approach is straightforward and leverages the divide-and-conquer strategy inherent in recursion, making it easy to understand and implement. However, it's important to note that this approach has a time complexity of O(2^n) due to the exponential number of function calls, which is not efficient for large values of `n`. For larger values, an iterative approach or memoization would be more efficient.\n", |
247 | 266 | "-----END-----\n", |
248 | 267 | "\n" |
249 | 268 | ] |
|
277 | 296 | "output_type": "stream", |
278 | 297 | "text": [ |
279 | 298 | "The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.\n", |
280 | | - "Setting `pad_token_id` to `eos_token_id`:None for open-end generation.\n" |
| 299 | + "Setting `pad_token_id` to `eos_token_id`:151643 for open-end generation.\n" |
281 | 300 | ] |
282 | 301 | }, |
283 | 302 | { |
|
313 | 332 | "\n", |
314 | 333 | "Let me test this function with some examples. For n=0, it returns 0. For n=1, returns 1. For n=2, it's F(1)+F(0) = 1+0=1. For n=3, F(2)+F(1)=1+1=2. That looks correct.\n", |
315 | 334 | "\n", |
316 | | - "Wait, but sometimes people define the Fibonacci sequence starting with F(1)=1, F(2)=1, F(3)=2, etc. So, if the function is called with n=5, it should return 5. Let me see: F(5) is 5, which is correct.\n", |
| 335 | + "Wait, but sometimes people define the Fibonacci sequence starting with F(1)=1, F(2)=1, F(3)=2, etc. So, if the function is called with n=5, it should return 5. Let me see: F(5) is 5, which matches the standard definition. So, the function should work regardless of the starting point as long as the base cases are correct.\n", |
317 | 336 | "\n", |
318 | | - "Another test case: n=5. Let's compute it step by step. F(0)=0, F(1)=1, F(2)=1, F(3)=2, F(4)=3, F(5)=5. So the function should return 5 for n=5.\n", |
| 337 | + "Another thing to consider is the base cases. If the function is called with n=0, it returns 0, which is correct. For n=1, returns 1. For n=2, returns 1, which is correct. So, the function should handle all non-negative integers correctly.\n", |
319 | 338 | "\n", |
320 | 339 | "I think this should work. So, the function is straightforward. It's a simple recursive implementation, but it's not the most efficient for large n. However, for the purpose of this problem, it's acceptable.\n", |
321 | 340 | "</think>\n", |
|
329 | 348 | " return fibonacci(n-1) + fibonacci(n-2)\n", |
330 | 349 | "```\n", |
331 | 350 | "\n", |
332 | | - "This function calculates the nth Fibonacci number using a recursive approach. It handles the base cases where n is 0 or 1 and for other values, it recursively calculates the sum of the two preceding Fibonacci numbers. While this implementation is straightforward, it's not the most efficient for large values of n due to repeated calculations.\n", |
| 351 | + "This function calculates the nth Fibonacci number using a recursive approach. It handles the base cases where n is 0 or 1 and recursively computes the value for larger n by summing the two preceding Fibonacci numbers.\n", |
333 | 352 | "-----END-----\n", |
334 | 353 | "\n" |
335 | 354 | ] |
|
361 | 380 | "output_type": "stream", |
362 | 381 | "text": [ |
363 | 382 | "The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.\n", |
364 | | - "Setting `pad_token_id` to `eos_token_id`:None for open-end generation.\n" |
| 383 | + "Setting `pad_token_id` to `eos_token_id`:151643 for open-end generation.\n" |
365 | 384 | ] |
366 | 385 | }, |
367 | 386 | { |
|
429 | 448 | "name": "python", |
430 | 449 | "nbconvert_exporter": "python", |
431 | 450 | "pygments_lexer": "ipython3", |
432 | | - "version": "3.10.13" |
| 451 | + "version": "3.10.17" |
433 | 452 | } |
434 | 453 | }, |
435 | 454 | "nbformat": 4, |
|
0 commit comments