Update metric.py
Browse files
metric.py
CHANGED
@@ -74,21 +74,22 @@ def compute(params):
|
|
74 |
print('label:', label)
|
75 |
|
76 |
prompt=f"Give me a score from 1 to 10 (higher is better) judging how similar these two captions are. Caption one: {answer}. Caption two: {label}\nScore:"
|
77 |
-
|
78 |
-
|
79 |
-
response = client.completions.create(
|
80 |
engine="gpt-3.5-turbo-instruct",
|
81 |
prompt=prompt,
|
82 |
temperature=0,
|
83 |
max_tokens=1,
|
84 |
)
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
|
89 |
-
except:
|
90 |
-
|
91 |
-
|
92 |
|
93 |
return score
|
94 |
|
|
|
74 |
print('label:', label)
|
75 |
|
76 |
prompt=f"Give me a score from 1 to 10 (higher is better) judging how similar these two captions are. Caption one: {answer}. Caption two: {label}\nScore:"
|
77 |
+
|
78 |
+
response = client.completions.create(
|
|
|
79 |
engine="gpt-3.5-turbo-instruct",
|
80 |
prompt=prompt,
|
81 |
temperature=0,
|
82 |
max_tokens=1,
|
83 |
)
|
84 |
+
eval_result = response.choices[0].text.strip()
|
85 |
+
print('eval_result', eval_result)
|
86 |
+
score = int(eval_result)
|
87 |
+
# try:
|
88 |
+
|
89 |
|
90 |
+
# except:
|
91 |
+
# print("Error: API Calling")
|
92 |
+
# return
|
93 |
|
94 |
return score
|
95 |
|