Skip to content

Commit 3a5de64

Browse files
committed
refactor:Using "DSL::Examples" for making the parsing function.
1 parent aaf8924 commit 3a5de64

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

Presentations/DSSG-SouthFL-2025/Translations-by-LLM-examples-Raku.ipynb

+59-59
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,22 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 13,
66
"metadata": {
77
"jupyter": {
88
"is_executing": true
99
}
1010
},
1111
"outputs": [],
1212
"source": [
13-
"use LLM::Configurations;"
13+
"use LLM::Configurations;\n",
14+
"use DSL::Examples;\n",
15+
"use DSL::English::QuantileRegressionWorkflows;"
1416
]
1517
},
1618
{
1719
"cell_type": "code",
18-
"execution_count": 2,
19-
"metadata": {},
20-
"outputs": [
21-
{
22-
"data": {
23-
"text/plain": [
24-
"-> **@args, *%args { #`(Block|5495820722832) ... }"
25-
]
26-
},
27-
"execution_count": 2,
28-
"metadata": {},
29-
"output_type": "execute_result"
30-
}
31-
],
32-
"source": [
33-
"my &fLLMForQRMon = llm-example-function([\n",
34-
" 'use tsTemp' => 'Regressionizer(temp_data)',\n",
35-
" 'with the data tsTemp' => 'Regressionizer(temp_data)',\n",
36-
" 'do regression with 12 knots' => 'quantile_regression(knots=12)',\n",
37-
" 'quantile regression with 30 knots and interpolation order 3' => 'quantile_regression(knots=12,order=3)',\n",
38-
" 'compute the regression quantiles for probabilities 0.1, 0.5, and 0.9' => 'quantile_regression(knots=12, probs=[0.1, 0.5, 0.9])',\n",
39-
" 'compute linear regression' => 'least_squares_fit(funcs=6)',\n",
40-
" 'compute linear regression with 14 basis functions' => 'least_squares_fit(funcs=14)',\n",
41-
" 'do a least squares fit with the basis functions MyFuncs' => 'least_squares_fit(funcs=MyFuncs)',\n",
42-
" 'show date list plot' => 'date_list_plot()',\n",
43-
" 'plot the data and fits' => 'plot()',\n",
44-
" 'plot with width 800 and aspect ratio 1/3' => 'plot(width=800, height=800*1/3)',\n",
45-
" 'plot with image size 1000 and plot theme plotly_dark' => 'plot(width=1000, template=\\\"plotly_dark\\\")',\n",
46-
" 'show error plots' => 'error_plots()',\n",
47-
" 'show date list error plots' => 'error_plots(date_list_plot=True)',\n",
48-
" 'show relative error plots' => 'error_plots(relative_errors=True)',\n",
49-
" 'echo data summary' => 'echo_data_summary()',\n",
50-
" 'rescale the data' => 'rescale(regressor=False, value=True)',\n",
51-
" 'rescale the data in both dimensions' => 'rescale(regressor=True, value=True)',\n",
52-
" 'find outliers' => 'outliers()',\n",
53-
" 'plot outliers' => 'outliers_plot()',\n",
54-
" 'take the value' => 'take_value()',\n",
55-
" 'show the value' => 'take_value()'\n",
56-
"],\n",
57-
"e => $conf4o\n",
58-
");"
59-
]
60-
},
61-
{
62-
"cell_type": "code",
63-
"execution_count": 3,
20+
"execution_count": 9,
6421
"metadata": {},
6522
"outputs": [
6623
{
@@ -69,31 +26,36 @@
6926
"&LLMQRMon"
7027
]
7128
},
72-
"execution_count": 3,
29+
"execution_count": 9,
7330
"metadata": {},
7431
"output_type": "execute_result"
7532
}
7633
],
7734
"source": [
35+
"use LLM::Functions;\n",
36+
"my &llm-pipeline-segment = llm-example-function(dsl-examples()<Python><QRMon>, e => $conf4o);\n",
37+
"\n",
7838
"sub LLMQRMon(Str $s) {\n",
79-
" my $res = &fLLMForQRMon($s);\n",
39+
" my $res = &llm-pipeline-segment($s);\n",
8040
" $res .= trim;\n",
8141
" return $res;\n",
8242
"}"
8343
]
8444
},
8545
{
8646
"cell_type": "code",
87-
"execution_count": 4,
47+
"execution_count": null,
8848
"metadata": {},
8949
"outputs": [
9050
{
9151
"data": {
9252
"text/plain": [
93-
"[Regressionizer(temp_data) echo_data_summary() rescale(regressor=True, value=False) quantile_regression(knots=20, probs=[0.025, 0.5, 0.976]) least_squares_fit(funcs=34) date_list_plot(width=900, height=900*1/3) outliers_plot(date_list_plot=True, width=900, height=900*1/3)]"
53+
"[Regressionizer(temp_data) echo_data_summary() rescale(regressor=True, value=False) quantile_regression(knots=20, probs=[0.025, 0.5, 0.976]) least_squares_fit(funcs=34) date_list_plot(width=900, height=900*1/3) ```python\n",
54+
"date_list_plot(outliers=True, width=900, height=900*1/3)\n",
55+
"```]"
9456
]
9557
},
96-
"execution_count": 4,
58+
"execution_count": 10,
9759
"metadata": {},
9860
"output_type": "execute_result"
9961
}
@@ -111,7 +73,7 @@
11173
},
11274
{
11375
"cell_type": "code",
114-
"execution_count": 5,
76+
"execution_count": 11,
11577
"metadata": {},
11678
"outputs": [
11779
{
@@ -123,10 +85,12 @@
12385
".quantile_regression(knots=20, probs=[0.025, 0.5, 0.976])\n",
12486
".least_squares_fit(funcs=34)\n",
12587
".date_list_plot(width=900, height=900*1/3)\n",
126-
".outliers_plot(date_list_plot=True, width=900, height=900*1/3)"
88+
".```python\n",
89+
"date_list_plot(outliers=True, width=900, height=900*1/3)\n",
90+
"```"
12791
]
12892
},
129-
"execution_count": 5,
93+
"execution_count": 11,
13094
"metadata": {},
13195
"output_type": "execute_result"
13296
}
@@ -135,12 +99,48 @@
13599
"@qrPythonCode.join(\"\\n.\")"
136100
]
137101
},
102+
{
103+
"cell_type": "markdown",
104+
"metadata": {},
105+
"source": [
106+
"Compare with the \"Small Language Model\" (SML) results:"
107+
]
108+
},
138109
{
139110
"cell_type": "code",
140-
"execution_count": null,
111+
"execution_count": 36,
141112
"metadata": {},
142-
"outputs": [],
143-
"source": []
113+
"outputs": [
114+
{
115+
"name": "stderr",
116+
"output_type": "stream",
117+
"text": [
118+
"Possible misspelling of 'summary' as 'summari'.\n"
119+
]
120+
},
121+
{
122+
"data": {
123+
"text/plain": [
124+
"obj = Regressionizer(temp_data).echo_data_summary().rescale( regressor = True).quantile_regression( knots = 20, probs = [0.025, 0.5, 0.976] ).plot( date_plot = True).plot( datePlotQ = false)"
125+
]
126+
},
127+
"execution_count": 36,
128+
"metadata": {},
129+
"output_type": "execute_result"
130+
}
131+
],
132+
"source": [
133+
"my $spec = q:to/END/;\n",
134+
"use dataset temp_data\n",
135+
"echo data summari;\n",
136+
"rescale the x axis;\n",
137+
"do quantile regression with 20 knots, with probabilities 0.025, 0.5, and 0.976;\n",
138+
"show date list plot;\n",
139+
"show outliers plot;\n",
140+
"END\n",
141+
"\n",
142+
"ToQuantileRegressionWorkflowCode($spec, target => 'Python::Regressionizer')"
143+
]
144144
}
145145
],
146146
"metadata": {

0 commit comments

Comments
 (0)