{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Regular expression constraints\n", "\n", "While you can specify any constraint you want with raw guidance functions/grammars, it is often useful to enforce very simple patterns on our `gen()` calls. To do this you can specify regular expression formats to which generated text must adhere. Internally these expressions are converted to native guidance grammars (set of guidance functions).\n", "\n", "## Example\n", "In the following example we know that we want to get number for the generated `chapter` variable, but GPT2 does not know that, and instead makes up something else.\n", "\n", "### Invalid output without a regex guide" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "gpustat is not installed, run `pip install gpustat` to collect GPU stats.\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3aec0964796543eda8105c6019797e94", "version_major": 2, "version_minor": 0 }, "text/plain": [ "StitchWidget(initial_height='auto', initial_width='100%', srcdoc='\\n\\n\\n …" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from guidance import models, gen\n", "\n", "gpt2 = models.Transformers(\"gpt2\")\n", "\n", "gpt2 + f\"\"\"\\\n", "Rewrite this proverb to apply to model instructions instead.\n", "\n", "Where there is no guidance, a people falls,\n", "but in an abundance of counselors there is safety.\n", "== Proverbs 11:14\n", "\n", "UPDATED\n", "Where there is no guidance{gen('rewrite', stop=\"==\")}\n", "== GPT {gen('chapter', max_tokens=10)}:{gen('verse', max_tokens=10)}\"\"\"" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Valid output with a regex guide" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "823daf931936471784a9eb9f18fa59b7", "version_major": 2, "version_minor": 0 }, "text/plain": [ "StitchWidget(initial_height='auto', initial_width='100%', srcdoc='\\n\\n\\n …" ] }, "metadata": {}, "output_type": "display_data" }, { "ename": "ValueError", "evalue": "panic: lexer_stack=[LexerState { row_idx: 0, lexer_state: StateID(19,0), byte: None }, LexerState { row_idx: 0, lexer_state: StateID(20,0), byte: Some(84) }, LexerState { row_idx: 0, lexer_state: StateID(21,0), byte: Some(119) }, LexerState { row_idx: 0, lexer_state: StateID(22,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(23,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(24,0), byte: Some(107) }, LexerState { row_idx: 0, lexer_state: StateID(25,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(26,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(27,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(28,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(29,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(30,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(31,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(32,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(33,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(34,0), byte: Some(118) }, LexerState { row_idx: 0, lexer_state: StateID(35,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(36,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(37,0), byte: Some(98) }, LexerState { row_idx: 0, lexer_state: StateID(38,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(39,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(40,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(41,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(42,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(43,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(44,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(45,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(46,0), byte: Some(121) }, LexerState { row_idx: 0, lexer_state: StateID(47,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(48,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(49,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(50,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(51,0), byte: Some(109) }, LexerState { row_idx: 0, lexer_state: StateID(52,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(53,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(54,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(55,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(56,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(57,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(58,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(59,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(60,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(61,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(62,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(63,0), byte: Some(99) }, LexerState { row_idx: 0, lexer_state: StateID(64,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(65,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(66,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(67,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(68,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(69,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(70,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(71,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(72,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(73,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(74,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(75,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(76,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(77,0), byte: Some(46) }, LexerState { row_idx: 0, lexer_state: StateID(78,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(79,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(80,0), byte: Some(87) }, LexerState { row_idx: 0, lexer_state: StateID(81,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(82,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(83,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(84,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(85,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(86,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(87,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(88,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(89,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(90,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(91,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(92,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(93,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(94,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(95,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(96,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(97,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(98,0), byte: Some(103) }, LexerState { row_idx: 0, lexer_state: StateID(99,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(100,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(101,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(102,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(103,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(104,0), byte: Some(99) }, LexerState { row_idx: 0, lexer_state: StateID(105,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(106,0), byte: Some(44) }, LexerState { row_idx: 0, lexer_state: StateID(107,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(108,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(109,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(110,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(111,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(112,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(113,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(114,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(115,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(116,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(117,0), byte: Some(102) }, LexerState { row_idx: 0, lexer_state: StateID(118,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(119,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(120,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(121,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(122,0), byte: Some(44) }, LexerState { row_idx: 0, lexer_state: StateID(123,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(124,0), byte: Some(98) }, LexerState { row_idx: 0, lexer_state: StateID(125,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(126,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(127,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(128,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(129,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(130,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(131,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(132,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(133,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(134,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(135,0), byte: Some(98) }, LexerState { row_idx: 0, lexer_state: StateID(136,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(137,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(138,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(139,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(140,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(141,0), byte: Some(99) }, LexerState { row_idx: 0, lexer_state: StateID(142,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(143,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(144,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(145,0), byte: Some(102) }, LexerState { row_idx: 0, lexer_state: StateID(146,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(147,0), byte: Some(99) }, LexerState { row_idx: 0, lexer_state: StateID(148,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(149,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(150,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(151,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(152,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(153,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(154,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(155,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(156,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(157,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(158,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(159,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(160,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(161,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(162,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(163,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(164,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(165,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(166,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(167,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(168,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(169,0), byte: Some(102) }, LexerState { row_idx: 0, lexer_state: StateID(170,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(171,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(172,0), byte: Some(121) }, LexerState { row_idx: 0, lexer_state: StateID(173,0), byte: Some(46) }, LexerState { row_idx: 0, lexer_state: StateID(174,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(175,0), byte: Some(61) }, LexerState { row_idx: 0, lexer_state: StateID(176,0), byte: Some(61) }, LexerState { row_idx: 0, lexer_state: StateID(177,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(178,0), byte: Some(80) }, LexerState { row_idx: 0, lexer_state: StateID(179,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(180,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(181,0), byte: Some(118) }, LexerState { row_idx: 0, lexer_state: StateID(182,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(183,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(184,0), byte: Some(98) }, LexerState { row_idx: 0, lexer_state: StateID(185,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(186,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(187,0), byte: Some(49) }, LexerState { row_idx: 0, lexer_state: StateID(188,0), byte: Some(49) }, LexerState { row_idx: 0, lexer_state: StateID(189,0), byte: Some(58) }, LexerState { row_idx: 0, lexer_state: StateID(190,0), byte: Some(49) }, LexerState { row_idx: 0, lexer_state: StateID(191,0), byte: Some(52) }, LexerState { row_idx: 0, lexer_state: StateID(192,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(193,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(194,0), byte: Some(85) }, LexerState { row_idx: 0, lexer_state: StateID(195,0), byte: Some(80) }, LexerState { row_idx: 0, lexer_state: StateID(196,0), byte: Some(68) }, LexerState { row_idx: 0, lexer_state: StateID(197,0), byte: Some(65) }, LexerState { row_idx: 0, lexer_state: StateID(198,0), byte: Some(84) }, LexerState { row_idx: 0, lexer_state: StateID(199,0), byte: Some(69) }, LexerState { row_idx: 0, lexer_state: StateID(200,0), byte: Some(68) }, LexerState { row_idx: 0, lexer_state: StateID(201,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(202,0), byte: Some(87) }, LexerState { row_idx: 0, lexer_state: StateID(203,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(204,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(205,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(206,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(207,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(208,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(209,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(210,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(211,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(212,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(213,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(214,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(215,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(216,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(217,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(218,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(219,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(220,0), byte: Some(103) }, LexerState { row_idx: 0, lexer_state: StateID(221,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(222,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(223,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(224,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(225,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(226,0), byte: Some(99) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: None }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(44) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(112) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(111) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(112) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(108) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(102) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(108) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(108) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(44) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(98) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(117) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(116) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(105) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(98) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(117) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(100) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(99) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(111) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(102) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(99) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(111) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(117) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(108) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(111) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(114) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(116) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(104) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(114) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(105) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(102) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(116) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(121) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(46) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(10) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(10) }, LexerState { row_idx: 1, lexer_state: StateID(229,0), byte: Some(61) }, LexerState { row_idx: 2, lexer_state: StateID(232,0), byte: None }, LexerState { row_idx: 2, lexer_state: StateID(238,0), byte: Some(10) }, LexerState { row_idx: 2, lexer_state: StateID(239,0), byte: Some(61) }, LexerState { row_idx: 2, lexer_state: StateID(240,0), byte: Some(61) }, LexerState { row_idx: 2, lexer_state: StateID(241,0), byte: Some(32) }, LexerState { row_idx: 2, lexer_state: StateID(242,0), byte: Some(71) }, LexerState { row_idx: 2, lexer_state: StateID(243,0), byte: Some(80) }, LexerState { row_idx: 2, lexer_state: StateID(244,0), byte: Some(84) }, LexerState { row_idx: 3, lexer_state: StateID(246,0), byte: None }, LexerState { row_idx: 3, lexer_state: StateID(247,0), byte: Some(49) }, LexerState { row_idx: 3, lexer_state: StateID(247,0), byte: Some(48) }, LexerState { row_idx: 3, lexer_state: StateID(247,0), byte: Some(49) }, LexerState { row_idx: 5, lexer_state: StateID(246,0), byte: None }, LexerState { row_idx: 5, lexer_state: StateID(247,0), byte: Some(49) }] bytes=\"Tweak this proverb to apply to model instructions instead.\\n\\nWhere there is no guidance, a people falls,\\nbut in an abundance of counselors there is safety.\\n== Proverbs 11:14\\n\\nUPDATED\\nWhere there is no guidance, a people falls,but in an abundance of counselors there is safety.\\n\\n\\n== GPT 101:1\" 293!=290+1\n 0: llg_clone_matcher\n 1: llg_clone_matcher\n 2: llg_clone_matcher\n 3: llg_clone_matcher\n 4: llg_clone_matcher\n 5: llg_clone_matcher\n 6: llg_clone_matcher\n 7: llg_clone_matcher\n 8: llg_clone_matcher\n 9: llg_clone_matcher\n 10: llg_clone_matcher\n 11: llg_clone_matcher\n 12: llg_clone_matcher\n 13: llg_clone_matcher\n 14: llg_clone_matcher\n 15: \n 16: \n 17: \n 18: method_vectorcall_VARARGS_KEYWORDS\n at \\Objects\\descrobject.c:365\n 19: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 20: PyObject_Vectorcall\n at \\Objects\\call.c:325\n 21: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:2715\n 22: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 23: gen_send_ex2\n at \\Objects\\genobject.c:230\n 24: gen_send_ex\n at \\Objects\\genobject.c:274\n 25: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3094\n 26: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 27: gen_send_ex2\n at \\Objects\\genobject.c:230\n 28: gen_iternext\n at \\Objects\\genobject.c:603\n 29: enum_next\n at \\Objects\\enumobject.c:231\n 30: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:2324\n 31: _PyFunction_Vectorcall\n at \\Objects\\call.c:424\n 32: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 33: vectorcall_unbound\n at \\Objects\\typeobject.c:2236\n 34: vectorcall_maybe\n at \\Objects\\typeobject.c:2288\n 35: slot_nb_add\n at \\Objects\\typeobject.c:8588\n 36: binary_op1\n at \\Objects\\abstract.c:882\n 37: PyNumber_Add\n at \\Objects\\abstract.c:1062\n 38: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3391\n 39: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 40: _PyEval_Vector\n at \\Python\\ceval.c:1685\n 41: PyEval_EvalCode\n at \\Python\\ceval.c:580\n 42: builtin_exec_impl\n at \\Python\\bltinmodule.c:1096\n 43: builtin_exec\n at \\Python\\clinic\\bltinmodule.c.h:586\n 44: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:2975\n 45: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 46: gen_send_ex2\n at \\Objects\\genobject.c:230\n 47: gen_send_ex\n at \\Objects\\genobject.c:274\n 48: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3094\n 49: _PyFunction_Vectorcall\n at \\Objects\\call.c:424\n 50: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 51: method_vectorcall\n at \\Objects\\classobject.c:61\n 52: _PyVectorcall_Call\n at \\Objects\\call.c:283\n 53: _PyObject_Call\n at \\Objects\\call.c:354\n 54: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3263\n 55: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 56: gen_send_ex2\n at \\Objects\\genobject.c:230\n 57: PyGen_am_send\n at \\Objects\\genobject.c:267\n 58: \n 59: \n 60: cfunction_vectorcall_O\n at \\Objects\\methodobject.c:509\n 61: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 62: context_run\n at \\Python\\context.c:668\n 63: cfunction_vectorcall_FASTCALL_KEYWORDS\n at \\Objects\\methodobject.c:438\n 64: _PyVectorcall_Call\n at \\Objects\\call.c:271\n 65: _PyObject_Call\n at \\Objects\\call.c:354\n 66: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3263\n 67: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 68: _PyEval_Vector\n at \\Python\\ceval.c:1685\n 69: PyEval_EvalCode\n at \\Python\\ceval.c:580\n 70: builtin_exec_impl\n at \\Python\\bltinmodule.c:1096\n 71: builtin_exec\n at \\Python\\clinic\\bltinmodule.c.h:586\n 72: cfunction_vectorcall_FASTCALL_KEYWORDS\n at \\Objects\\methodobject.c:438\n 73: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 74: PyObject_Vectorcall\n at \\Objects\\call.c:325\n 75: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:2715\n 76: _PyFunction_Vectorcall\n at \\Objects\\call.c:424\n 77: _PyVectorcall_Call\n at \\Objects\\call.c:271\n 78: _PyObject_Call\n at \\Objects\\call.c:354\n 79: PyObject_Call\n at \\Objects\\call.c:379\n 80: pymain_run_module\n at \\Modules\\main.c:300\n 81: pymain_run_python\n at \\Modules\\main.c:628\n 82: Py_RunMain\n at \\Modules\\main.c:714\n 83: pymain_main\n at \\Modules\\main.c:744\n 84: Py_Main\n at \\Modules\\main.c:756\n 85: invoke_main\n at D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_common.inl:90\n 86: __scrt_common_main_seh\n at D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_common.inl:288\n 87: BaseThreadInitThunk\n 88: RtlUserThreadStart\n\n\nTokens: ⟦Twe‧ak‧ this‧ proverb‧ to‧ apply‧ to‧ model‧ instructions‧ instead‧.‧\\n‧\\n‧Where‧ there‧ is‧ no‧ guidance‧,‧ a‧ people‧ falls‧,‧\\n‧but‧ in‧ an‧ abundance‧ of‧ counselors‧ there‧ is‧ safety‧.‧\\n‧==‧ Pro‧verbs‧ 11‧:‧14‧\\n‧\\n‧U‧PDATED‧\\n‧Where‧ there‧ is‧ no‧ guidance‧,‧ a‧ people‧ falls‧,‧but‧ in‧ an‧ abundance‧ of‧ counselors‧ there‧ is‧ safety‧.‧\\n‧\\n‧\\n‧==‧ G‧PT‧ 101‧:‧1⟧\n75 tokens, 290 bytes; grm_prefix: \"\"\nFlags: had_backtrack\nParser: {\n \"compute_time_us\": 23165,\n \"rows\": 34,\n \"cached_rows\": 354,\n \"all_items\": 47,\n \"lexer_cost\": 6420,\n \"slices_applied\": 0,\n \"trie_nodes_walked\": 1766059,\n \"definitive_bytes\": 292,\n \"lexer_ops\": 0,\n \"num_lex_errors\": 0,\n \"num_lexemes\": 0\n}\nStop: NotStopped\nError: None\n", "output_type": "error", "traceback": [ "\u001b[31m---------------------------------------------------------------------------\u001b[39m", "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[2]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mgpt2\u001b[49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[33;43mf\u001b[39;49m\u001b[33;43m\"\"\"\u001b[39;49m\u001b[38;5;130;43;01m\\\u001b[39;49;00m\n\u001b[32m 2\u001b[39m \u001b[33;43mTweak this proverb to apply to model instructions instead.\u001b[39;49m\n\u001b[32m 3\u001b[39m \n\u001b[32m 4\u001b[39m \u001b[33;43mWhere there is no guidance, a people falls,\u001b[39;49m\n\u001b[32m 5\u001b[39m \u001b[33;43mbut in an abundance of counselors there is safety.\u001b[39;49m\n\u001b[32m 6\u001b[39m \u001b[33;43m== Proverbs 11:14\u001b[39;49m\n\u001b[32m 7\u001b[39m \n\u001b[32m 8\u001b[39m \u001b[33;43mUPDATED\u001b[39;49m\n\u001b[32m 9\u001b[39m \u001b[33;43mWhere there is no guidance\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mgen\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mrewrite\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;250;43m \u001b[39;49m\u001b[43mstop\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m==\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\n\u001b[32m 10\u001b[39m \u001b[33;43m== GPT \u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mgen\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mchapter\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;250;43m \u001b[39;49m\u001b[43mregex\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m[0-9]+\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m:\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mgen\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mverse\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;250;43m \u001b[39;49m\u001b[43mregex\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m[0-9]+\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[33;43m\"\"\"\u001b[39;49m\n", "\u001b[36mFile \u001b[39m\u001b[32m~\\source\\repos\\guidance\\guidance\\models\\_base\\_model.py:104\u001b[39m, in \u001b[36mModel.__add__\u001b[39m\u001b[34m(self, other)\u001b[39m\n\u001b[32m 102\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m other(\u001b[38;5;28mself\u001b[39m)\n\u001b[32m 103\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(other, ASTNode):\n\u001b[32m--> \u001b[39m\u001b[32m104\u001b[39m \u001b[38;5;28mself\u001b[39m = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_apply_node\u001b[49m\u001b[43m(\u001b[49m\u001b[43mother\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 105\u001b[39m \u001b[38;5;28mself\u001b[39m = \u001b[38;5;28mself\u001b[39m._update_open_block_captures()\n\u001b[32m 106\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\n", "\u001b[36mFile \u001b[39m\u001b[32m~\\source\\repos\\guidance\\guidance\\models\\_base\\_model.py:132\u001b[39m, in \u001b[36mModel._apply_node\u001b[39m\u001b[34m(self, node)\u001b[39m\n\u001b[32m 129\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 130\u001b[39m \u001b[38;5;28mself\u001b[39m._update_trace_node(\u001b[38;5;28mself\u001b[39m._id, \u001b[38;5;28mself\u001b[39m._parent_id, StatelessGuidanceInput(value=node))\n\u001b[32m--> \u001b[39m\u001b[32m132\u001b[39m \u001b[43m\u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mi\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moutput_attr\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43menumerate\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_interpreter\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnode\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 133\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43misinstance\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43moutput_attr\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mTextOutput\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 134\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m# TODO: put this elsewhere (inside state?)\u001b[39;49;00m\n\u001b[32m 135\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mtoken_count\u001b[49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43moutput_attr\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtoken_count\u001b[49m\n", "\u001b[36mFile \u001b[39m\u001b[32m~\\source\\repos\\guidance\\guidance\\models\\_base\\_interpreter.py:36\u001b[39m, in \u001b[36mInterpreter.run\u001b[39m\u001b[34m(self, node, **kwargs)\u001b[39m\n\u001b[32m 35\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mrun\u001b[39m(\u001b[38;5;28mself\u001b[39m, node: ASTNode, **kwargs) -> Iterator[OutputAttr]:\n\u001b[32m---> \u001b[39m\u001b[32m36\u001b[39m \u001b[38;5;28;01myield from\u001b[39;00m node.simplify()._run(\u001b[38;5;28mself\u001b[39m, **kwargs)\n", "\u001b[36mFile \u001b[39m\u001b[32m~\\source\\repos\\guidance\\guidance\\models\\_engine\\_interpreter.py:65\u001b[39m, in \u001b[36mEngineInterpreter.grammar\u001b[39m\u001b[34m(self, node, **kwargs)\u001b[39m\n\u001b[32m 57\u001b[39m engine_gen = \u001b[38;5;28mself\u001b[39m.engine(\n\u001b[32m 58\u001b[39m state=\u001b[38;5;28mself\u001b[39m.state,\n\u001b[32m 59\u001b[39m grammar=node.ll_grammar(),\n\u001b[32m 60\u001b[39m ensure_bos_token=\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[32m 61\u001b[39m echo=\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[32m 62\u001b[39m )\n\u001b[32m 64\u001b[39m delayed_bytes = \u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m---> \u001b[39m\u001b[32m65\u001b[39m \u001b[43m\u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mengine_gen\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 66\u001b[39m \u001b[43m \u001b[49m\u001b[43mnew_bytes\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m.\u001b[49m\u001b[43mnew_bytes\u001b[49m\n\u001b[32m 67\u001b[39m \u001b[43m \u001b[49m\u001b[43mnew_text\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdelayed_bytes\u001b[49m\u001b[43m \u001b[49m\u001b[43m=\u001b[49m\u001b[43m \u001b[49m\u001b[43mpartial_decode\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnew_bytes\u001b[49m\u001b[43m)\u001b[49m\n", "\u001b[36mFile \u001b[39m\u001b[32m~\\source\\repos\\guidance\\guidance\\models\\_engine\\_engine.py:175\u001b[39m, in \u001b[36mEngine.__call__\u001b[39m\u001b[34m(self, state, grammar, ensure_bos_token, echo)\u001b[39m\n\u001b[32m 172\u001b[39m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m parser.done():\n\u001b[32m 173\u001b[39m t0 = time.time()\n\u001b[32m--> \u001b[39m\u001b[32m175\u001b[39m tokens, mask_fut, backtrack = \u001b[43mparser\u001b[49m\u001b[43m.\u001b[49m\u001b[43madvance\u001b[49m\u001b[43m(\u001b[49m\u001b[43mengine_output\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 177\u001b[39m \u001b[38;5;66;03m# Note that has_pending_stop implies that the response is a stop response,\u001b[39;00m\n\u001b[32m 178\u001b[39m \u001b[38;5;66;03m# but the converse is not true. We can therefore avoid some (but not all)\u001b[39;00m\n\u001b[32m 179\u001b[39m \u001b[38;5;66;03m# unnecessary calls to get_logits on the final iteration.\u001b[39;00m\n\u001b[32m 180\u001b[39m has_pending_stop = parser.has_pending_stop()\n", "\u001b[36mFile \u001b[39m\u001b[32m~\\source\\repos\\guidance\\guidance\\_parser.py:70\u001b[39m, in \u001b[36mTokenParser.advance\u001b[39m\u001b[34m(self, engine_output)\u001b[39m\n\u001b[32m 67\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.done():\n\u001b[32m 68\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m TokenParserException(\u001b[33m\"\u001b[39m\u001b[33mCannot advance on a done parser\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m---> \u001b[39m\u001b[32m70\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_generator\u001b[49m\u001b[43m.\u001b[49m\u001b[43msend\u001b[49m\u001b[43m(\u001b[49m\u001b[43mengine_output\u001b[49m\u001b[43m)\u001b[49m\n", "\u001b[36mFile \u001b[39m\u001b[32m~\\source\\repos\\guidance\\guidance\\_parser.py:145\u001b[39m, in \u001b[36mTokenParser._parse\u001b[39m\u001b[34m(self, prompt, ensure_bos_token)\u001b[39m\n\u001b[32m 136\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m mask[engine_output.issued_token.token_id]:\n\u001b[32m 137\u001b[39m \u001b[38;5;66;03m# Note: we could punt this probem to ll_interpreter.post_process,\u001b[39;00m\n\u001b[32m 138\u001b[39m \u001b[38;5;66;03m# but it's a bit clearer to handle it here\u001b[39;00m\n\u001b[32m 139\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m InvalidTokenException(\n\u001b[32m 140\u001b[39m token=engine_output.issued_token.token_id,\n\u001b[32m 141\u001b[39m valid_tokens=[i \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mlen\u001b[39m(mask)) \u001b[38;5;28;01mif\u001b[39;00m mask[i]],\n\u001b[32m 142\u001b[39m prompt_tokens=tokens\n\u001b[32m 143\u001b[39m ) \n\u001b[32m--> \u001b[39m\u001b[32m145\u001b[39m backtrack, ff_tokens = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mll_interpreter\u001b[49m\u001b[43m.\u001b[49m\u001b[43mcommit_token\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 146\u001b[39m \u001b[43m \u001b[49m\u001b[43mengine_output\u001b[49m\u001b[43m.\u001b[49m\u001b[43missued_token\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtoken_id\u001b[49m\n\u001b[32m 147\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 148\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m backtrack:\n\u001b[32m 149\u001b[39m tokens = tokens[:-backtrack]\n", "\u001b[31mValueError\u001b[39m: panic: lexer_stack=[LexerState { row_idx: 0, lexer_state: StateID(19,0), byte: None }, LexerState { row_idx: 0, lexer_state: StateID(20,0), byte: Some(84) }, LexerState { row_idx: 0, lexer_state: StateID(21,0), byte: Some(119) }, LexerState { row_idx: 0, lexer_state: StateID(22,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(23,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(24,0), byte: Some(107) }, LexerState { row_idx: 0, lexer_state: StateID(25,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(26,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(27,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(28,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(29,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(30,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(31,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(32,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(33,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(34,0), byte: Some(118) }, LexerState { row_idx: 0, lexer_state: StateID(35,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(36,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(37,0), byte: Some(98) }, LexerState { row_idx: 0, lexer_state: StateID(38,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(39,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(40,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(41,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(42,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(43,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(44,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(45,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(46,0), byte: Some(121) }, LexerState { row_idx: 0, lexer_state: StateID(47,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(48,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(49,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(50,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(51,0), byte: Some(109) }, LexerState { row_idx: 0, lexer_state: StateID(52,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(53,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(54,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(55,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(56,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(57,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(58,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(59,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(60,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(61,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(62,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(63,0), byte: Some(99) }, LexerState { row_idx: 0, lexer_state: StateID(64,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(65,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(66,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(67,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(68,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(69,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(70,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(71,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(72,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(73,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(74,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(75,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(76,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(77,0), byte: Some(46) }, LexerState { row_idx: 0, lexer_state: StateID(78,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(79,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(80,0), byte: Some(87) }, LexerState { row_idx: 0, lexer_state: StateID(81,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(82,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(83,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(84,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(85,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(86,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(87,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(88,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(89,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(90,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(91,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(92,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(93,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(94,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(95,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(96,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(97,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(98,0), byte: Some(103) }, LexerState { row_idx: 0, lexer_state: StateID(99,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(100,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(101,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(102,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(103,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(104,0), byte: Some(99) }, LexerState { row_idx: 0, lexer_state: StateID(105,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(106,0), byte: Some(44) }, LexerState { row_idx: 0, lexer_state: StateID(107,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(108,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(109,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(110,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(111,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(112,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(113,0), byte: Some(112) }, LexerState { row_idx: 0, lexer_state: StateID(114,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(115,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(116,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(117,0), byte: Some(102) }, LexerState { row_idx: 0, lexer_state: StateID(118,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(119,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(120,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(121,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(122,0), byte: Some(44) }, LexerState { row_idx: 0, lexer_state: StateID(123,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(124,0), byte: Some(98) }, LexerState { row_idx: 0, lexer_state: StateID(125,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(126,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(127,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(128,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(129,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(130,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(131,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(132,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(133,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(134,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(135,0), byte: Some(98) }, LexerState { row_idx: 0, lexer_state: StateID(136,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(137,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(138,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(139,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(140,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(141,0), byte: Some(99) }, LexerState { row_idx: 0, lexer_state: StateID(142,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(143,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(144,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(145,0), byte: Some(102) }, LexerState { row_idx: 0, lexer_state: StateID(146,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(147,0), byte: Some(99) }, LexerState { row_idx: 0, lexer_state: StateID(148,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(149,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(150,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(151,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(152,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(153,0), byte: Some(108) }, LexerState { row_idx: 0, lexer_state: StateID(154,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(155,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(156,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(157,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(158,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(159,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(160,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(161,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(162,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(163,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(164,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(165,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(166,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(167,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(168,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(169,0), byte: Some(102) }, LexerState { row_idx: 0, lexer_state: StateID(170,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(171,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(172,0), byte: Some(121) }, LexerState { row_idx: 0, lexer_state: StateID(173,0), byte: Some(46) }, LexerState { row_idx: 0, lexer_state: StateID(174,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(175,0), byte: Some(61) }, LexerState { row_idx: 0, lexer_state: StateID(176,0), byte: Some(61) }, LexerState { row_idx: 0, lexer_state: StateID(177,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(178,0), byte: Some(80) }, LexerState { row_idx: 0, lexer_state: StateID(179,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(180,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(181,0), byte: Some(118) }, LexerState { row_idx: 0, lexer_state: StateID(182,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(183,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(184,0), byte: Some(98) }, LexerState { row_idx: 0, lexer_state: StateID(185,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(186,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(187,0), byte: Some(49) }, LexerState { row_idx: 0, lexer_state: StateID(188,0), byte: Some(49) }, LexerState { row_idx: 0, lexer_state: StateID(189,0), byte: Some(58) }, LexerState { row_idx: 0, lexer_state: StateID(190,0), byte: Some(49) }, LexerState { row_idx: 0, lexer_state: StateID(191,0), byte: Some(52) }, LexerState { row_idx: 0, lexer_state: StateID(192,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(193,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(194,0), byte: Some(85) }, LexerState { row_idx: 0, lexer_state: StateID(195,0), byte: Some(80) }, LexerState { row_idx: 0, lexer_state: StateID(196,0), byte: Some(68) }, LexerState { row_idx: 0, lexer_state: StateID(197,0), byte: Some(65) }, LexerState { row_idx: 0, lexer_state: StateID(198,0), byte: Some(84) }, LexerState { row_idx: 0, lexer_state: StateID(199,0), byte: Some(69) }, LexerState { row_idx: 0, lexer_state: StateID(200,0), byte: Some(68) }, LexerState { row_idx: 0, lexer_state: StateID(201,0), byte: Some(10) }, LexerState { row_idx: 0, lexer_state: StateID(202,0), byte: Some(87) }, LexerState { row_idx: 0, lexer_state: StateID(203,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(204,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(205,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(206,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(207,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(208,0), byte: Some(116) }, LexerState { row_idx: 0, lexer_state: StateID(209,0), byte: Some(104) }, LexerState { row_idx: 0, lexer_state: StateID(210,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(211,0), byte: Some(114) }, LexerState { row_idx: 0, lexer_state: StateID(212,0), byte: Some(101) }, LexerState { row_idx: 0, lexer_state: StateID(213,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(214,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(215,0), byte: Some(115) }, LexerState { row_idx: 0, lexer_state: StateID(216,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(217,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(218,0), byte: Some(111) }, LexerState { row_idx: 0, lexer_state: StateID(219,0), byte: Some(32) }, LexerState { row_idx: 0, lexer_state: StateID(220,0), byte: Some(103) }, LexerState { row_idx: 0, lexer_state: StateID(221,0), byte: Some(117) }, LexerState { row_idx: 0, lexer_state: StateID(222,0), byte: Some(105) }, LexerState { row_idx: 0, lexer_state: StateID(223,0), byte: Some(100) }, LexerState { row_idx: 0, lexer_state: StateID(224,0), byte: Some(97) }, LexerState { row_idx: 0, lexer_state: StateID(225,0), byte: Some(110) }, LexerState { row_idx: 0, lexer_state: StateID(226,0), byte: Some(99) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: None }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(44) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(112) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(111) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(112) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(108) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(102) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(108) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(108) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(44) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(98) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(117) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(116) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(105) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(98) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(117) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(100) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(99) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(111) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(102) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(99) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(111) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(117) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(110) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(108) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(111) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(114) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(116) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(104) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(114) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(105) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(32) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(115) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(97) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(102) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(101) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(116) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(121) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(46) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(10) }, LexerState { row_idx: 1, lexer_state: StateID(3,0), byte: Some(10) }, LexerState { row_idx: 1, lexer_state: StateID(229,0), byte: Some(61) }, LexerState { row_idx: 2, lexer_state: StateID(232,0), byte: None }, LexerState { row_idx: 2, lexer_state: StateID(238,0), byte: Some(10) }, LexerState { row_idx: 2, lexer_state: StateID(239,0), byte: Some(61) }, LexerState { row_idx: 2, lexer_state: StateID(240,0), byte: Some(61) }, LexerState { row_idx: 2, lexer_state: StateID(241,0), byte: Some(32) }, LexerState { row_idx: 2, lexer_state: StateID(242,0), byte: Some(71) }, LexerState { row_idx: 2, lexer_state: StateID(243,0), byte: Some(80) }, LexerState { row_idx: 2, lexer_state: StateID(244,0), byte: Some(84) }, LexerState { row_idx: 3, lexer_state: StateID(246,0), byte: None }, LexerState { row_idx: 3, lexer_state: StateID(247,0), byte: Some(49) }, LexerState { row_idx: 3, lexer_state: StateID(247,0), byte: Some(48) }, LexerState { row_idx: 3, lexer_state: StateID(247,0), byte: Some(49) }, LexerState { row_idx: 5, lexer_state: StateID(246,0), byte: None }, LexerState { row_idx: 5, lexer_state: StateID(247,0), byte: Some(49) }] bytes=\"Tweak this proverb to apply to model instructions instead.\\n\\nWhere there is no guidance, a people falls,\\nbut in an abundance of counselors there is safety.\\n== Proverbs 11:14\\n\\nUPDATED\\nWhere there is no guidance, a people falls,but in an abundance of counselors there is safety.\\n\\n\\n== GPT 101:1\" 293!=290+1\n 0: llg_clone_matcher\n 1: llg_clone_matcher\n 2: llg_clone_matcher\n 3: llg_clone_matcher\n 4: llg_clone_matcher\n 5: llg_clone_matcher\n 6: llg_clone_matcher\n 7: llg_clone_matcher\n 8: llg_clone_matcher\n 9: llg_clone_matcher\n 10: llg_clone_matcher\n 11: llg_clone_matcher\n 12: llg_clone_matcher\n 13: llg_clone_matcher\n 14: llg_clone_matcher\n 15: \n 16: \n 17: \n 18: method_vectorcall_VARARGS_KEYWORDS\n at \\Objects\\descrobject.c:365\n 19: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 20: PyObject_Vectorcall\n at \\Objects\\call.c:325\n 21: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:2715\n 22: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 23: gen_send_ex2\n at \\Objects\\genobject.c:230\n 24: gen_send_ex\n at \\Objects\\genobject.c:274\n 25: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3094\n 26: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 27: gen_send_ex2\n at \\Objects\\genobject.c:230\n 28: gen_iternext\n at \\Objects\\genobject.c:603\n 29: enum_next\n at \\Objects\\enumobject.c:231\n 30: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:2324\n 31: _PyFunction_Vectorcall\n at \\Objects\\call.c:424\n 32: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 33: vectorcall_unbound\n at \\Objects\\typeobject.c:2236\n 34: vectorcall_maybe\n at \\Objects\\typeobject.c:2288\n 35: slot_nb_add\n at \\Objects\\typeobject.c:8588\n 36: binary_op1\n at \\Objects\\abstract.c:882\n 37: PyNumber_Add\n at \\Objects\\abstract.c:1062\n 38: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3391\n 39: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 40: _PyEval_Vector\n at \\Python\\ceval.c:1685\n 41: PyEval_EvalCode\n at \\Python\\ceval.c:580\n 42: builtin_exec_impl\n at \\Python\\bltinmodule.c:1096\n 43: builtin_exec\n at \\Python\\clinic\\bltinmodule.c.h:586\n 44: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:2975\n 45: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 46: gen_send_ex2\n at \\Objects\\genobject.c:230\n 47: gen_send_ex\n at \\Objects\\genobject.c:274\n 48: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3094\n 49: _PyFunction_Vectorcall\n at \\Objects\\call.c:424\n 50: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 51: method_vectorcall\n at \\Objects\\classobject.c:61\n 52: _PyVectorcall_Call\n at \\Objects\\call.c:283\n 53: _PyObject_Call\n at \\Objects\\call.c:354\n 54: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3263\n 55: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 56: gen_send_ex2\n at \\Objects\\genobject.c:230\n 57: PyGen_am_send\n at \\Objects\\genobject.c:267\n 58: \n 59: \n 60: cfunction_vectorcall_O\n at \\Objects\\methodobject.c:509\n 61: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 62: context_run\n at \\Python\\context.c:668\n 63: cfunction_vectorcall_FASTCALL_KEYWORDS\n at \\Objects\\methodobject.c:438\n 64: _PyVectorcall_Call\n at \\Objects\\call.c:271\n 65: _PyObject_Call\n at \\Objects\\call.c:354\n 66: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:3263\n 67: _PyEval_EvalFrame\n at \\Include\\internal\\pycore_ceval.h:89\n 68: _PyEval_Vector\n at \\Python\\ceval.c:1685\n 69: PyEval_EvalCode\n at \\Python\\ceval.c:580\n 70: builtin_exec_impl\n at \\Python\\bltinmodule.c:1096\n 71: builtin_exec\n at \\Python\\clinic\\bltinmodule.c.h:586\n 72: cfunction_vectorcall_FASTCALL_KEYWORDS\n at \\Objects\\methodobject.c:438\n 73: _PyObject_VectorcallTstate\n at \\Include\\internal\\pycore_call.h:92\n 74: PyObject_Vectorcall\n at \\Objects\\call.c:325\n 75: _PyEval_EvalFrameDefault\n at \\PCbuild\\Python\\bytecodes.c:2715\n 76: _PyFunction_Vectorcall\n at \\Objects\\call.c:424\n 77: _PyVectorcall_Call\n at \\Objects\\call.c:271\n 78: _PyObject_Call\n at \\Objects\\call.c:354\n 79: PyObject_Call\n at \\Objects\\call.c:379\n 80: pymain_run_module\n at \\Modules\\main.c:300\n 81: pymain_run_python\n at \\Modules\\main.c:628\n 82: Py_RunMain\n at \\Modules\\main.c:714\n 83: pymain_main\n at \\Modules\\main.c:744\n 84: Py_Main\n at \\Modules\\main.c:756\n 85: invoke_main\n at D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_common.inl:90\n 86: __scrt_common_main_seh\n at D:\\a\\_work\\1\\s\\src\\vctools\\crt\\vcstartup\\src\\startup\\exe_common.inl:288\n 87: BaseThreadInitThunk\n 88: RtlUserThreadStart\n\n\nTokens: ⟦Twe‧ak‧ this‧ proverb‧ to‧ apply‧ to‧ model‧ instructions‧ instead‧.‧\\n‧\\n‧Where‧ there‧ is‧ no‧ guidance‧,‧ a‧ people‧ falls‧,‧\\n‧but‧ in‧ an‧ abundance‧ of‧ counselors‧ there‧ is‧ safety‧.‧\\n‧==‧ Pro‧verbs‧ 11‧:‧14‧\\n‧\\n‧U‧PDATED‧\\n‧Where‧ there‧ is‧ no‧ guidance‧,‧ a‧ people‧ falls‧,‧but‧ in‧ an‧ abundance‧ of‧ counselors‧ there‧ is‧ safety‧.‧\\n‧\\n‧\\n‧==‧ G‧PT‧ 101‧:‧1⟧\n75 tokens, 290 bytes; grm_prefix: \"\"\nFlags: had_backtrack\nParser: {\n \"compute_time_us\": 23165,\n \"rows\": 34,\n \"cached_rows\": 354,\n \"all_items\": 47,\n \"lexer_cost\": 6420,\n \"slices_applied\": 0,\n \"trie_nodes_walked\": 1766059,\n \"definitive_bytes\": 292,\n \"lexer_ops\": 0,\n \"num_lex_errors\": 0,\n \"num_lexemes\": 0\n}\nStop: NotStopped\nError: None\n" ] } ], "source": [ "gpt2 + f\"\"\"\\\n", "Tweak this proverb to apply to model instructions instead.\n", "\n", "Where there is no guidance, a people falls,\n", "but in an abundance of counselors there is safety.\n", "== Proverbs 11:14\n", "\n", "UPDATED\n", "Where there is no guidance{gen('rewrite', stop=\"==\")}\n", "== GPT {gen('chapter', regex=\"[0-9]+\")}:{gen('verse', regex=\"[0-9]+\")}\"\"\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
Have an idea for more helpful examples? Pull requests that add to this documentation notebook are encouraged!
" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.9" } }, "nbformat": 4, "nbformat_minor": 4 }