Skip to content

Commit

Permalink
Update factscorer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AakritiKinra authored Jan 10, 2025
1 parent e00001c commit 17dca2b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions llments/eval/factscore/factscorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import os
import logging
from typing import List, Optional, Dict, Any, Union
from typing import List, Optional, Dict, Any, Union, cast

from tqdm import tqdm
from factscore.abstain_detection import is_response_abstained
Expand Down Expand Up @@ -281,7 +281,8 @@ def get_score(
total_words = 0
for topic, generation, facts in zip(topics, generations, atomic_facts):
if facts is not None:
total_words += self._get_score(topic, generation, facts, knowledge_source, cost_estimate=self.cost_estimate)
result = self._get_score(topic, generation, facts, knowledge_source, cost_estimate=self.cost_estimate)
total_words += cast(int, result)

self.print_cost_estimates(total_words, task="factscore evaluation", model="gpt-3.5-turbo")

Expand All @@ -295,7 +296,7 @@ def get_score(
if facts is None:
decisions.append(None)
else:
decision = self._get_score(topic, generation, facts, knowledge_source)
decision = cast(List[Dict[str, bool]], self._get_score(topic, generation, facts, knowledge_source))
score = np.mean([d["is_supported"] for d in decision])

if gamma:
Expand Down

0 comments on commit 17dca2b

Please sign in to comment.