|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": 13, |
| 5 | + "execution_count": 12, |
6 | 6 | "id": "23530ae1", |
7 | 7 | "metadata": {}, |
8 | 8 | "outputs": [ |
9 | 9 | { |
10 | 10 | "name": "stdout", |
11 | 11 | "output_type": "stream", |
12 | 12 | "text": [ |
13 | | - "Loading Lark base parser from cache: cache/parsers/python_lalr_parser.pkl\n" |
| 13 | + "[2025-06-03 16:10:30,358-root] - Loading model meta-llama/Llama-3.2-1B with device:cuda, device_map:auto, torch_dtype:torch.bfloat16\n", |
| 14 | + "[2025-06-03 16:10:31,670-root] - Loading model meta-llama/Llama-3.2-1B with device:cuda, device_map:auto, torch_dtype:torch.bfloat16\n" |
14 | 15 | ] |
15 | 16 | } |
16 | 17 | ], |
17 | 18 | "source": [ |
| 19 | + "import sys\n", |
| 20 | + "sys.path.append('..') # Assuming we are in the root directory\n", |
18 | 21 | "from syncode import Syncode\n", |
19 | 22 | "import warnings\n", |
20 | 23 | "warnings.filterwarnings('ignore')\n", |
21 | 24 | "\n", |
22 | | - "model_name = \"WizardLM/WizardCoder-1B-V1.0\"\n", |
| 25 | + "model_name = \"meta-llama/Llama-3.2-1B\"\n", |
23 | 26 | "\n", |
24 | 27 | "# Load the unconstrained original model\n", |
25 | 28 | "llm = Syncode(model = model_name, mode='original', max_new_tokens=200)\n", |
26 | 29 | "\n", |
27 | 30 | "# Load the Syncode augmented model\n", |
28 | | - "syn_llm = Syncode(model = model_name, mode='grammar_mask', grammar='python', parse_output_only=False)" |
| 31 | + "syn_llm = Syncode(\n", |
| 32 | + " model = model_name, \n", |
| 33 | + " mode='grammar_mask', \n", |
| 34 | + " grammar='python', \n", |
| 35 | + " parse_output_only=False,\n", |
| 36 | + " indent=True,\n", |
| 37 | + " opp=False\n", |
| 38 | + " )" |
29 | 39 | ] |
30 | 40 | }, |
31 | 41 | { |
|
39 | 49 | }, |
40 | 50 | { |
41 | 51 | "cell_type": "code", |
42 | | - "execution_count": 16, |
| 52 | + "execution_count": 8, |
43 | 53 | "id": "490cddb3", |
44 | 54 | "metadata": {}, |
45 | 55 | "outputs": [ |
| 56 | + { |
| 57 | + "name": "stderr", |
| 58 | + "output_type": "stream", |
| 59 | + "text": [ |
| 60 | + "Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n" |
| 61 | + ] |
| 62 | + }, |
46 | 63 | { |
47 | 64 | "name": "stdout", |
48 | 65 | "output_type": "stream", |
|
51 | 68 | " '''Return if prime'''\n", |
52 | 69 | " if n < 2:\n", |
53 | 70 | " return False\n", |
54 | | - " for i in range(2, int(n**0.5)+1):\n", |
| 71 | + " for i in range(2, n):\n", |
55 | 72 | " if n % i == 0:\n", |
56 | 73 | " return False\n", |
57 | | - " return True\n" |
| 74 | + " return True\n", |
| 75 | + "\n" |
58 | 76 | ] |
59 | 77 | }, |
60 | 78 | { |
|
64 | 82 | "traceback": [ |
65 | 83 | "Traceback \u001b[0;36m(most recent call last)\u001b[0m:\n", |
66 | 84 | "\u001b[0m File \u001b[1;32m~/anaconda3/envs/codex/lib/python3.11/site-packages/IPython/core/interactiveshell.py:3577\u001b[0m in \u001b[1;35mrun_code\u001b[0m\n exec(code_obj, self.user_global_ns, self.user_ns)\u001b[0m\n", |
67 | | - "\u001b[0;36m Cell \u001b[0;32mIn[16], line 4\u001b[0;36m\n\u001b[0;31m exec(output)\u001b[0;36m\n", |
| 85 | + "\u001b[0;36m Cell \u001b[0;32mIn[8], line 4\u001b[0;36m\n\u001b[0;31m exec(output)\u001b[0;36m\n", |
68 | 86 | "\u001b[0;36m File \u001b[0;32m<string>:3\u001b[0;36m\u001b[0m\n\u001b[0;31m if n < 2:\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unindent does not match any outer indentation level\n" |
69 | 87 | ] |
70 | 88 | } |
|
78 | 96 | }, |
79 | 97 | { |
80 | 98 | "cell_type": "code", |
81 | | - "execution_count": 15, |
| 99 | + "execution_count": 13, |
82 | 100 | "id": "76cd93f5", |
83 | 101 | "metadata": {}, |
84 | 102 | "outputs": [ |
| 103 | + { |
| 104 | + "name": "stderr", |
| 105 | + "output_type": "stream", |
| 106 | + "text": [ |
| 107 | + "Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n" |
| 108 | + ] |
| 109 | + }, |
85 | 110 | { |
86 | 111 | "name": "stdout", |
87 | 112 | "output_type": "stream", |
88 | 113 | "text": [ |
89 | 114 | "def is_prime(n):\n", |
90 | 115 | " '''Return if prime'''\n", |
91 | | - " if n < 2:\n", |
92 | | - " return False\n", |
93 | | - " for i in range(2, int(n**0.5) + 1):\n", |
94 | | - " if n % i == 0:\n", |
95 | | - " return False\n", |
96 | | - " return True\n" |
| 116 | + " return n > 1 and all(n % i!= 0 for i in range(2, int(n**0.5) + 1))\n", |
| 117 | + "\n" |
97 | 118 | ] |
98 | 119 | } |
99 | 120 | ], |
|
0 commit comments