Spaces:
Runtime error
Runtime error
print gpt metrics before trf metrics
Browse files
app.py
CHANGED
@@ -95,24 +95,30 @@ My latest exclusive for The Hill : Conservative frustration over Republican effo
|
|
95 |
def find_orgs(uploaded_file):
|
96 |
uploaded_data = json.loads(uploaded_file)
|
97 |
all_metrics = {}
|
98 |
-
all_metrics['trf'] = get_metrics_trf(uploaded_data)
|
99 |
-
|
100 |
-
print(all_metrics)
|
101 |
|
102 |
sample_data = store_sample_data(uploaded_data)
|
103 |
-
|
104 |
-
# sample_data = json.load(f)
|
105 |
-
|
106 |
gpt_orgs, true_orgs = [], []
|
107 |
|
108 |
for sent in sample_data:
|
109 |
gpt_orgs.append(find_orgs_gpt(sent['text']))
|
110 |
true_orgs.append(sent['orgs'])
|
111 |
-
|
112 |
|
113 |
-
# sim_model = SimCSE('sentence-transformers/all-MiniLM-L6-v2')
|
114 |
sim_model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
115 |
all_metrics['gpt'] = calc_metrics(true_orgs, gpt_orgs, sim_model, threshold=0.85)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
print(all_metrics)
|
117 |
return all_metrics
|
118 |
# radio_btn = gr.Radio(choices=['GPT', 'iSemantics'], value='iSemantics', label='Available models', show_label=True)
|
|
|
95 |
def find_orgs(uploaded_file):
|
96 |
uploaded_data = json.loads(uploaded_file)
|
97 |
all_metrics = {}
|
|
|
|
|
|
|
98 |
|
99 |
sample_data = store_sample_data(uploaded_data)
|
100 |
+
|
|
|
|
|
101 |
gpt_orgs, true_orgs = [], []
|
102 |
|
103 |
for sent in sample_data:
|
104 |
gpt_orgs.append(find_orgs_gpt(sent['text']))
|
105 |
true_orgs.append(sent['orgs'])
|
|
|
106 |
|
|
|
107 |
sim_model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
108 |
all_metrics['gpt'] = calc_metrics(true_orgs, gpt_orgs, sim_model, threshold=0.85)
|
109 |
+
print(all_metrics)
|
110 |
+
|
111 |
+
all_metrics['trf'] = get_metrics_trf(uploaded_data)
|
112 |
+
|
113 |
+
|
114 |
+
# with open('./data/sample_data.json', 'r') as f:
|
115 |
+
# sample_data = json.load(f)
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
|
120 |
+
# sim_model = SimCSE('sentence-transformers/all-MiniLM-L6-v2')
|
121 |
+
|
122 |
print(all_metrics)
|
123 |
return all_metrics
|
124 |
# radio_btn = gr.Radio(choices=['GPT', 'iSemantics'], value='iSemantics', label='Available models', show_label=True)
|