loubnabnl HF staff commited on
Commit
8aac646
·
1 Parent(s): 2bd7767

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from datasets import load_dataset
3
+ import os
4
+
5
+ HF_TOKEN = os.environ.get("HF_TOKEN", None)
6
+
7
+ st.set_page_config(page_title="Synthetic textbooks inspection", layout="wide")
8
+ st.title("Synthetic textbooks inspection")
9
+ st.markdown("Inspection of synthetic textbooks generated by `Falcon-180B-chat`")
10
+
11
+ @st.cache_data()
12
+ def load_data(source="all"):
13
+ ds = load_dataset("HuggingFaceTB/synthetic_textbooks_subset", split="train", use_auth_token=HF_TOKEN)
14
+ if source != "all":
15
+ ds = ds.filter(lambda x: x["source"] == source)
16
+ return ds
17
+
18
+
19
+ source = st.selectbox("Data source", ['all', 'wikihow','khan_academy', 'stanford_courses', 'rw_wikihow', 'rw_stanford'])
20
+ samples = load_data(source)
21
+ n_samples = len(samples)
22
+
23
+ index = st.number_input(f"Index of the sample (out of {n_samples}):", min_value=0, max_value=n_samples-1, value=0, step=1)
24
+ st.markdown(f"Displaying source: {source}")
25
+ st.subheader("Prompt")
26
+ st.markdown(samples[index_example]["prompt"])
27
+
28
+ st.subheader("Textbook")
29
+ st.markdown(samples[index_example]['textbook'])