LejlaKantar commited on
Commit
faef160
β€’
1 Parent(s): 247356e
Files changed (1) hide show
  1. app.py +70 -0
app.py CHANGED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from matplotlib.pyplot import get
2
+ from matplotlib.style import available
3
+ import streamlit as st
4
+ import numpy as np
5
+ import pandas as pd
6
+ import streamlit.components.v1 as components
7
+
8
+ from millify import millify
9
+
10
+ from utils.utils_display import get_current_date, get_json_from_date, get_available_dates, render_st_from_chapter_number, get_current_global_step
11
+ from utils.constants import preface_disclaimer
12
+
13
+ st.set_page_config(page_title="Bloom Book",layout='wide')
14
+
15
+ BATCH_SIZE=2048
16
+ SEQ_LENGTH=2048
17
+
18
+ curr_date = get_current_date()
19
+
20
+ # set_png_as_page_bg("data/image/bloom-book-bg.png") #
21
+ st.markdown("<h1 style='text-align: center; color: grey;'>πŸ“– BLOOM Book πŸ“– </h1>", unsafe_allow_html=True)
22
+
23
+ available_dates = get_available_dates()
24
+ available_chapters = ("Preface", ) + tuple(available_dates)
25
+
26
+ st.sidebar.image(
27
+ "https://assets.website-files.com/6139f3cdcbbff3a68486761d/613cd8997b270da063e230c5_Tekengebied%201-p-2000.png",
28
+ use_column_width=True
29
+ )
30
+
31
+ st.sidebar.title(
32
+ "Chapters browser"
33
+ )
34
+
35
+ st.sidebar.markdown(
36
+ "You can freely browse the different chapters - ie example prompts from different people - and see the results."
37
+ )
38
+
39
+ selected_date = st.sidebar.selectbox(
40
+ "Please select the chapter you want to read:",
41
+ available_chapters
42
+ )
43
+
44
+ if selected_date != "Preface":
45
+ current_global_step = get_current_global_step(selected_date)
46
+ seen_tokens = BATCH_SIZE * SEQ_LENGTH * current_global_step
47
+ st.markdown("<h2 style='text-align: center; color: grey;'> Chapter {} </h2>".format(selected_date), unsafe_allow_html=True)
48
+ st.markdown("<h3 style='text-align: center; color: grey;'> Global step: {} - Seen tokens: {} </h3>".format(current_global_step, millify(seen_tokens)), unsafe_allow_html=True)
49
+ st.markdown("<h5 style='text-align: center; color: grey;'> Click into the text cards to visualize the answers </h5>", unsafe_allow_html=True)
50
+
51
+ selected_format = st.sidebar.selectbox('Visualize as:', ["HTML","JSON"])
52
+ suffixes = ["greedy", "nucleus"]
53
+
54
+ if selected_format == "HTML":
55
+ user_input = st.sidebar.text_input("Search for a specific prompt: ", "")
56
+ render_st_from_chapter_number(selected_date, suffixes, user_input)
57
+ elif selected_format == "JSON":
58
+ suffix = st.sidebar.selectbox('Decoding strategy:', ["greedy","nucleus"])
59
+ json_output = get_json_from_date(selected_date, suffix)
60
+ st.json(json_output)
61
+ else:
62
+ st.markdown("<h3 style='text-align: center; color: grey;'> Welcome to the <i> BLOOM Book </i>. Here you can read generations from the main model based on prompts provided by the community. </h3> ", unsafe_allow_html=True)
63
+ st.markdown("""<h3 style='text-align: center; color: grey;'> Follow the main model's training <a href='https://huggingface.co/bigscience/tr11-176B-ml-logs' target="_blank"> here </a> </h3> """, unsafe_allow_html=True)
64
+ st.markdown("""<h3 style='text-align: center; color: grey;'> Try your own prompts? Check the <a href='https://forms.gle/2L7jkZt8MS8VDy2ZA' target="_blank"> Google Form </a> </h3> """, unsafe_allow_html=True)
65
+ st.markdown("{}".format(preface_disclaimer), unsafe_allow_html=True)
66
+ final_html =""" """ #TODO: add preface
67
+ chapter = components.html(
68
+ final_html,
69
+ height=600,
70
+ )