Spaces:
Runtime error
Runtime error
Andreas Sünder
commited on
Commit
·
ea4e7e1
1
Parent(s):
04e920d
Integrate example topics and add fse prompt
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ import pandas as pd
|
|
| 8 |
DATASETS_PATH = 'datasets'
|
| 9 |
|
| 10 |
models = {
|
| 11 |
-
'
|
| 12 |
}
|
| 13 |
|
| 14 |
prompts = {
|
|
@@ -16,6 +16,26 @@ prompts = {
|
|
| 16 |
'''
|
| 17 |
I have topic that is described by the following keywords: [KEYWORDS]
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
Based on the information above, extract a short topic label in the following format:
|
| 20 |
topic: <topic label>
|
| 21 |
'''
|
|
@@ -23,7 +43,7 @@ prompts = {
|
|
| 23 |
}
|
| 24 |
|
| 25 |
topicsets = {
|
| 26 |
-
'
|
| 27 |
}
|
| 28 |
|
| 29 |
@st.cache_data(show_spinner=False)
|
|
@@ -61,10 +81,12 @@ if sel_model_name:
|
|
| 61 |
|
| 62 |
sel_dataset_name = col1.selectbox('Select a dataset', topicsets.keys(), index=None)
|
| 63 |
if sel_dataset_name:
|
| 64 |
-
sel_dataset = pd.read_csv(topicsets[sel_dataset_name]
|
|
|
|
|
|
|
| 65 |
col1.dataframe(sel_dataset)
|
| 66 |
|
| 67 |
-
sel_row_index = col1.selectbox('Select a
|
| 68 |
|
| 69 |
sel_prompt = col2.selectbox('Select a prompt', prompts.keys())
|
| 70 |
if sel_prompt != 'custom_prompt':
|
|
|
|
| 8 |
DATASETS_PATH = 'datasets'
|
| 9 |
|
| 10 |
models = {
|
| 11 |
+
'mistral_instruct': ReplicateModel('mistralai/mistral-7b-instruct-v0.1:83b6a56e7c828e667f21fd596c338fd4f0039b46bcfa18d973e8e70e455fda70'),
|
| 12 |
}
|
| 13 |
|
| 14 |
prompts = {
|
|
|
|
| 16 |
'''
|
| 17 |
I have topic that is described by the following keywords: [KEYWORDS]
|
| 18 |
|
| 19 |
+
Based on the information above, extract a short topic label in the following format:
|
| 20 |
+
topic: <topic label>
|
| 21 |
+
''',
|
| 22 |
+
|
| 23 |
+
'few_shot_examples':
|
| 24 |
+
'''
|
| 25 |
+
I have a topic that is described by the following keywords: [KEYWORDS]
|
| 26 |
+
|
| 27 |
+
Example 1:
|
| 28 |
+
Keywords: apple,fruit,healthy,snack,red,orchard
|
| 29 |
+
Topic label: Healthy Fruit Snacks
|
| 30 |
+
|
| 31 |
+
Example 2:
|
| 32 |
+
Keywords: computer,technology,silicon,programming,internet,hardware
|
| 33 |
+
Topic label: Computer Technology
|
| 34 |
+
|
| 35 |
+
Example 3:
|
| 36 |
+
Keywords: democracy,government,elections,vote,political,representation
|
| 37 |
+
Topic label: Democratic Governance
|
| 38 |
+
|
| 39 |
Based on the information above, extract a short topic label in the following format:
|
| 40 |
topic: <topic label>
|
| 41 |
'''
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
topicsets = {
|
| 46 |
+
'example_topics': os.path.join(DATASETS_PATH, 'topics.csv'),
|
| 47 |
}
|
| 48 |
|
| 49 |
@st.cache_data(show_spinner=False)
|
|
|
|
| 81 |
|
| 82 |
sel_dataset_name = col1.selectbox('Select a dataset', topicsets.keys(), index=None)
|
| 83 |
if sel_dataset_name:
|
| 84 |
+
sel_dataset = pd.read_csv(topicsets[sel_dataset_name])
|
| 85 |
+
sel_dataset.drop(columns=['topic_id', 'domain'], inplace=True)
|
| 86 |
+
|
| 87 |
col1.dataframe(sel_dataset)
|
| 88 |
|
| 89 |
+
sel_row_index = col1.selectbox('Select a topic', sel_dataset.index)
|
| 90 |
|
| 91 |
sel_prompt = col2.selectbox('Select a prompt', prompts.keys())
|
| 92 |
if sel_prompt != 'custom_prompt':
|