nazneen commited on
Commit
e542ede
1 Parent(s): 0fef2cc

add app file

Browse files
Files changed (3) hide show
  1. .env +2 -0
  2. app.py +49 -0
  3. requirements.txt +2 -0
.env ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ HF_TOKEN="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"
2
+
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pathlib import Path
3
+
4
+ import pandas as pd
5
+ import streamlit as st
6
+ from datasets import load_dataset
7
+ from dotenv import load_dotenv
8
+
9
+ if Path(".env").is_file():
10
+ load_dotenv(".env")
11
+
12
+ st.set_page_config(layout="wide")
13
+
14
+ HF_TOKEN = os.getenv("HF_TOKEN")
15
+
16
+ ds = load_dataset("HuggingFaceH4/instruction-model-outputs-filtered", split="train", use_auth_token=HF_TOKEN)
17
+
18
+ st.markdown("# Instruction Model Outputs")
19
+ st.markdown(
20
+ """This app shows the outputs of various open-souce, instruction-trained models from a [dataset](https://huggingface.co/datasets/HuggingFaceH4/instruction-model-outputs-filtered) of human demonstrations filtered for overlap with the original prompt and canned responses. Hit the button below to view a few random samples from the generated outputs."""
21
+ )
22
+ st.markdown(
23
+ """**Notes**
24
+ * Some outputs contain a `Human:` prefix - this is likely due to the fact each model was prompted to be a dialogue agent.
25
+ * The outputs were generated deterministically with `temperature=0` and `max_new_tokens=100`
26
+ """
27
+ )
28
+
29
+ button = st.button("Show me what you got!")
30
+
31
+ if button is True:
32
+ sample_ds = ds.shuffle().select(range(5))
33
+
34
+ for sample in sample_ds:
35
+ st.markdown(f'**Prompt:** {sample["prompt"]}')
36
+
37
+ df = pd.DataFrame.from_records(sample["outputs"])
38
+
39
+ # CSS to inject contained in a string
40
+ hide_table_row_index = """
41
+ <style>
42
+ thead tr th:first-child {display:none}
43
+ tbody th {display:none}
44
+ </style>
45
+ """
46
+
47
+ # Inject CSS with Markdown
48
+ st.markdown(hide_table_row_index, unsafe_allow_html=True)
49
+ st.table(df)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ datasets
2
+ python-dotenv