derek-thomas
commited on
Commit
·
272ccb0
1
Parent(s):
9990990
Abstracting sidebar and dark_mode
Browse files
prompt_order_exeriment/dark_mode.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import reflex as rx
|
2 |
+
from reflex.style import color_mode, set_color_mode
|
3 |
+
|
4 |
+
|
5 |
+
def dark_mode_toggle() -> rx.Component:
|
6 |
+
return rx.segmented_control.root(
|
7 |
+
rx.segmented_control.item(
|
8 |
+
rx.icon(tag="monitor", size=20),
|
9 |
+
value="system",
|
10 |
+
),
|
11 |
+
rx.segmented_control.item(
|
12 |
+
rx.icon(tag="sun", size=20),
|
13 |
+
value="light",
|
14 |
+
),
|
15 |
+
rx.segmented_control.item(
|
16 |
+
rx.icon(tag="moon", size=20),
|
17 |
+
value="dark",
|
18 |
+
),
|
19 |
+
on_change=set_color_mode,
|
20 |
+
variant="classic",
|
21 |
+
radius="large",
|
22 |
+
value=color_mode,
|
23 |
+
)
|
prompt_order_exeriment/pages/index.py
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
import reflex as rx
|
2 |
|
3 |
-
from ..sidebar import sidebar
|
4 |
-
|
5 |
p1 = '''
|
6 |
# Prompt Order Experiment
|
7 |
This experiment aims to explore various scenarios for **prompt fine-tuning** using structured generation. We'll test how the order of elements in a prompt affects model performance. The elements we consider are:
|
@@ -71,9 +69,6 @@ Structured generation ensures consistent response formats, which is crucial for
|
|
71 |
|
72 |
|
73 |
def page():
|
74 |
-
return rx.
|
75 |
-
|
76 |
-
rx.vstack(
|
77 |
-
rx.markdown(p1),
|
78 |
-
)
|
79 |
)
|
|
|
1 |
import reflex as rx
|
2 |
|
|
|
|
|
3 |
p1 = '''
|
4 |
# Prompt Order Experiment
|
5 |
This experiment aims to explore various scenarios for **prompt fine-tuning** using structured generation. We'll test how the order of elements in a prompt affects model performance. The elements we consider are:
|
|
|
69 |
|
70 |
|
71 |
def page():
|
72 |
+
return rx.vstack(
|
73 |
+
rx.markdown(p1),
|
|
|
|
|
|
|
74 |
)
|
prompt_order_exeriment/pages/overview.py
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
import reflex as rx
|
2 |
|
3 |
-
from ..sidebar import sidebar
|
4 |
-
|
5 |
p2 = '''
|
6 |
# Steps
|
7 |
### Dataset Selection
|
@@ -26,21 +24,8 @@ def mermaid_svg():
|
|
26 |
)
|
27 |
|
28 |
|
29 |
-
def overview():
|
30 |
-
return rx.hstack(
|
31 |
-
sidebar(),
|
32 |
-
rx.vstack(
|
33 |
-
rx.markdown(p2),
|
34 |
-
mermaid_svg(),
|
35 |
-
)
|
36 |
-
)
|
37 |
-
|
38 |
-
|
39 |
def page():
|
40 |
-
return rx.
|
41 |
-
|
42 |
-
|
43 |
-
rx.markdown(p2),
|
44 |
-
mermaid_svg(),
|
45 |
-
)
|
46 |
)
|
|
|
1 |
import reflex as rx
|
2 |
|
|
|
|
|
3 |
p2 = '''
|
4 |
# Steps
|
5 |
### Dataset Selection
|
|
|
24 |
)
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
def page():
|
28 |
+
return rx.vstack(
|
29 |
+
rx.markdown(p2),
|
30 |
+
mermaid_svg(),
|
|
|
|
|
|
|
31 |
)
|
prompt_order_exeriment/pages/results.py
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
-
import reflex as rx
|
2 |
import pandas as pd
|
3 |
import plotly.express as px
|
|
|
|
|
4 |
from reflex_ag_grid import ag_grid
|
5 |
from sklearn.metrics import accuracy_score
|
6 |
-
from ..sidebar import sidebar
|
7 |
-
from datasets import load_dataset
|
8 |
|
9 |
chart_md = """
|
10 |
Make sure you explore what happeened between:
|
@@ -87,30 +86,27 @@ def topic_star_chart():
|
|
87 |
|
88 |
|
89 |
def page():
|
90 |
-
return rx.
|
91 |
-
|
92 |
-
rx.
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
rx.plotly(data=topic_star_chart()), # Render the radar chart
|
114 |
-
padding="20px",
|
115 |
-
)
|
116 |
)
|
|
|
|
|
1 |
import pandas as pd
|
2 |
import plotly.express as px
|
3 |
+
import reflex as rx
|
4 |
+
from datasets import load_dataset
|
5 |
from reflex_ag_grid import ag_grid
|
6 |
from sklearn.metrics import accuracy_score
|
|
|
|
|
7 |
|
8 |
chart_md = """
|
9 |
Make sure you explore what happeened between:
|
|
|
86 |
|
87 |
|
88 |
def page():
|
89 |
+
return rx.vstack(
|
90 |
+
rx.heading("Results", size="9", margin="20px 0"),
|
91 |
+
rx.markdown("Here we have a sortable table of our experiments and the results"),
|
92 |
+
ag_grid(
|
93 |
+
id="ag_grid_metrics",
|
94 |
+
row_data=metrics_df.to_dict("records"),
|
95 |
+
column_defs=metrics_column_defs,
|
96 |
+
width="60%",
|
97 |
+
margin="20px auto", # Center the table
|
98 |
+
size_columns_to_fit=True
|
99 |
+
),
|
100 |
+
rx.markdown("\n---\n"),
|
101 |
+
rx.divider(),
|
102 |
+
rx.heading("Performance Star Chart", size="8", margin="20px 0"),
|
103 |
+
rx.text(
|
104 |
+
"The chart below shows how each model performed across the most popular top 10 topics by row count. "
|
105 |
+
"Each line represents a model, and the radial axis represents accuracy.",
|
106 |
+
font_size="md",
|
107 |
+
padding="10px",
|
108 |
+
),
|
109 |
+
rx.markdown(chart_md),
|
110 |
+
rx.plotly(data=topic_star_chart()), # Render the radar chart
|
111 |
+
padding="20px",
|
|
|
|
|
|
|
112 |
)
|
prompt_order_exeriment/prompt_order_exeriment.py
CHANGED
@@ -1,9 +1,36 @@
|
|
1 |
import reflex as rx
|
2 |
|
|
|
|
|
3 |
from .pages import index, overview, results
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Initialize the Reflex app with polished layout
|
6 |
app = rx.App()
|
7 |
-
app.add_page(overview, title='Overview', route='/overview') # Overview page
|
8 |
-
app.add_page(results, title='Results', route='/results') # Results page
|
9 |
-
app.add_page(index, title='Index', route='/') # Index page
|
|
|
1 |
import reflex as rx
|
2 |
|
3 |
+
from .dark_mode import dark_mode_toggle
|
4 |
+
from .sidebar import sidebar
|
5 |
from .pages import index, overview, results
|
6 |
|
7 |
+
|
8 |
+
def add_components(rest_of_app):
|
9 |
+
"""
|
10 |
+
Adds sidebar and dark_mode components
|
11 |
+
:param rest_of_app:
|
12 |
+
:return:
|
13 |
+
"""
|
14 |
+
return rx.box(
|
15 |
+
rx.hstack(
|
16 |
+
sidebar(),
|
17 |
+
rest_of_app(),
|
18 |
+
),
|
19 |
+
rx.box(
|
20 |
+
dark_mode_toggle(),
|
21 |
+
position="absolute", # Enables absolute positioning
|
22 |
+
top="10px", # Position 10px from the top
|
23 |
+
right="10px", # Position 10px from the right
|
24 |
+
z_index=1000, # Ensures it appears above other elements
|
25 |
+
),
|
26 |
+
position="relative", # Sets the container as a relative position reference
|
27 |
+
width="100vw", # Full width of the viewport
|
28 |
+
height="100vh", # Full height of the viewport
|
29 |
+
)
|
30 |
+
|
31 |
+
|
32 |
# Initialize the Reflex app with polished layout
|
33 |
app = rx.App()
|
34 |
+
app.add_page(add_components(overview), title='Overview', route='/overview') # Overview page
|
35 |
+
app.add_page(add_components(results), title='Results', route='/results') # Results page
|
36 |
+
app.add_page(add_components(index), title='Index', route='/') # Index page
|