alfraser commited on
Commit
88be29a
·
1 Parent(s): c6fe718

Added a side by side compare for the architectures

Browse files
config/architectures.json CHANGED
@@ -21,7 +21,7 @@
21
  "img": "architecture_baseline.jpg"
22
  },
23
  {
24
- "name": "3. Retrieval Augmented Generation (RAG) Architecture",
25
  "description": "An architecture which uses a raw baseline LLM for its core, but augments requests from the user with information which has been retrieved from a knowledge store where the organisational knowledge has previously been stored for this purpose.",
26
  "steps": [
27
  {"class": "InputRequestScreener"},
 
21
  "img": "architecture_baseline.jpg"
22
  },
23
  {
24
+ "name": "3. RAG Architecture",
25
  "description": "An architecture which uses a raw baseline LLM for its core, but augments requests from the user with information which has been retrieved from a knowledge store where the organisational knowledge has previously been stored for this purpose.",
26
  "steps": [
27
  {"class": "InputRequestScreener"},
pages/010_LLM_Architectures.py CHANGED
@@ -1,14 +1,61 @@
1
  import pandas as pd
2
  import streamlit as st
3
 
 
 
4
  from src.st_helpers import st_setup
5
  from src.common import img_dir, escape_dollars
6
  from src.architectures import *
7
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def show_architecture(architecture: str) -> None:
10
  """
11
- Convenience wrapper for the streamlit rendering of an architecture details and the
12
  ability to interact with the architecture
13
  :param architecture: the name of the architecture to output
14
  """
@@ -75,8 +122,14 @@ if st_setup('LLM Arch'):
75
  Architecture.load_architectures(force_reload=True)
76
 
77
  arch_names = [a.name for a in Architecture.architectures]
 
 
 
78
  selected_arch = st.radio(label="Available architectures", label_visibility="hidden", options=arch_names, index=None)
 
79
  if selected_arch is None:
80
  st.info('Select an architecture from above to see details and interact with it')
 
 
81
  else:
82
  show_architecture(selected_arch)
 
1
  import pandas as pd
2
  import streamlit as st
3
 
4
+ from time import time
5
+
6
  from src.st_helpers import st_setup
7
  from src.common import img_dir, escape_dollars
8
  from src.architectures import *
9
 
10
 
11
+ def show_side_by_side() -> None:
12
+ """
13
+ Streamlit render a prompt and the boxes to show each architecture
14
+ :return:
15
+ """
16
+ # Build the layout structure
17
+ st.divider()
18
+ header_container = st.container()
19
+ arch_outer_container = st.container()
20
+ with arch_outer_container:
21
+ arch_cols = st.columns(len(Architecture.architectures))
22
+
23
+ # Build header
24
+ with header_container:
25
+ st.write("### Side by side comparison of architectures")
26
+ st.write('Enter a question below to have it sent to all available architectures to compare timing and response')
27
+ prompt = st.chat_input("Ask a question")
28
+
29
+ # Now build the columns
30
+ with arch_outer_container:
31
+ if prompt:
32
+ # Build columns per architecture
33
+ for i, a in enumerate(Architecture.architectures):
34
+ with arch_cols[i]:
35
+ st.write(f'#### {a.name}')
36
+
37
+ # Now dispatch the messages per architecture
38
+ for i, a in enumerate(Architecture.architectures):
39
+ request = ArchitectureRequest(query=prompt)
40
+ with arch_cols[i]:
41
+ with st.spinner('Architecture processing request'):
42
+ start = time()
43
+ a(request)
44
+ elapsed_in_s = (int((time() - start) * 10))/10 # round to 1dp in seconds
45
+ st.write('##### Timing')
46
+ st.write(f'Request took **{elapsed_in_s}s**')
47
+ st.write('##### Response')
48
+ st.write(request.response)
49
+ else:
50
+ # Build columns per architecture for display only
51
+ for i, a in enumerate(Architecture.architectures):
52
+ with arch_cols[i]:
53
+ st.write(f'#### {a.name}')
54
+
55
+
56
  def show_architecture(architecture: str) -> None:
57
  """
58
+ Streamlit render an architecture details and the
59
  ability to interact with the architecture
60
  :param architecture: the name of the architecture to output
61
  """
 
122
  Architecture.load_architectures(force_reload=True)
123
 
124
  arch_names = [a.name for a in Architecture.architectures]
125
+ compare = 'Side by side comparison'
126
+ arch_names.append(compare)
127
+ print(arch_names)
128
  selected_arch = st.radio(label="Available architectures", label_visibility="hidden", options=arch_names, index=None)
129
+ print(f'Selected "{selected_arch}"')
130
  if selected_arch is None:
131
  st.info('Select an architecture from above to see details and interact with it')
132
+ elif selected_arch == compare:
133
+ show_side_by_side()
134
  else:
135
  show_architecture(selected_arch)