Catch LangChain error
Browse files- L3Score.py +10 -5
L3Score.py
CHANGED
|
@@ -149,12 +149,17 @@ class L3Score(evaluate.Metric):
|
|
| 149 |
L3Score = 0
|
| 150 |
count = 0
|
| 151 |
for question, prediction, reference in zip(questions, predictions, references):
|
| 152 |
-
|
| 153 |
-
(
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
| 156 |
)
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
| 158 |
score = self._calculate_L3Score(
|
| 159 |
response.response_metadata["logprobs"]["content"][0]["top_logprobs"]
|
| 160 |
)
|
|
|
|
| 149 |
L3Score = 0
|
| 150 |
count = 0
|
| 151 |
for question, prediction, reference in zip(questions, predictions, references):
|
| 152 |
+
try:
|
| 153 |
+
response = llm.invoke(
|
| 154 |
+
(
|
| 155 |
+
"human",
|
| 156 |
+
_PROMPT.format(question=question, gt=reference, answer=prediction),
|
| 157 |
+
)
|
| 158 |
)
|
| 159 |
+
except Exception as e:
|
| 160 |
+
print(e)
|
| 161 |
+
continue
|
| 162 |
+
|
| 163 |
score = self._calculate_L3Score(
|
| 164 |
response.response_metadata["logprobs"]["content"][0]["top_logprobs"]
|
| 165 |
)
|