Hasan Iqbal
commited on
Commit
•
ec53a03
1
Parent(s):
a7431bb
Made the imports more user friendly
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- requirements.txt +1 -0
- scripts/cli.sh +1 -1
- src/openfactcheck/__init__.py +3 -0
- src/openfactcheck/app/app.py +2 -1
- src/openfactcheck/app/evaluate_factchecker.py +2 -1
- src/openfactcheck/app/evaluate_llm.py +2 -1
- src/openfactcheck/app/evaluate_response.py +1 -1
- src/openfactcheck/{core/base.py → base.py} +13 -14
- src/openfactcheck/{core/cli.py → cli.py} +4 -6
- src/openfactcheck/{lib/errors.py → errors.py} +0 -0
- src/openfactcheck/evaluator/__init__.py +3 -0
- src/openfactcheck/evaluator/checker/__init__.py +1 -0
- src/openfactcheck/evaluator/{factchecker → checker}/evaluate.py +2 -2
- src/openfactcheck/evaluator/llm/__init__.py +1 -0
- src/openfactcheck/evaluator/llm/evaluate.py +2 -2
- src/openfactcheck/evaluator/llm/evaluate_freetext.py +2 -2
- src/openfactcheck/evaluator/llm/evaluate_freshqa.py +0 -1
- src/openfactcheck/evaluator/llm/evaluate_snowballing.py +0 -1
- src/openfactcheck/evaluator/llm/report.py +1 -1
- src/openfactcheck/evaluator/response/__init__.py +1 -0
- src/openfactcheck/evaluator/response/evaluate.py +5 -2
- src/openfactcheck/lib/__init__.py +2 -0
- src/openfactcheck/lib/config.py +26 -29
- src/openfactcheck/lib/openai.py +0 -0
- src/openfactcheck/{core/solver.py → solver.py} +2 -2
- src/openfactcheck/solvers/dummy/confused_claim_examiner.py +1 -2
- src/openfactcheck/solvers/dummy/fake_claim_extractor.py +1 -3
- src/openfactcheck/solvers/dummy/ignorant_search_engine_retriever.py +1 -3
- src/openfactcheck/solvers/dummy/useless_response_regenerator.py +1 -2
- src/openfactcheck/solvers/factcheckgpt/factcheckgpt_cp.py +1 -2
- src/openfactcheck/solvers/factcheckgpt/factcheckgpt_rtv.py +1 -2
- src/openfactcheck/solvers/factcheckgpt/factcheckgpt_vfr.py +1 -2
- src/openfactcheck/solvers/factool/all_pass_abstain_detector.py +1 -2
- src/openfactcheck/solvers/factool/concat_response_regenerator.py +1 -2
- src/openfactcheck/solvers/factool/factool_blackbox.py +1 -2
- src/openfactcheck/solvers/factool/factool_blackbox_post_editor.py +1 -2
- src/openfactcheck/solvers/factool/factool_claim_examiner.py +1 -2
- src/openfactcheck/solvers/factool/factool_decontextualizer.py +2 -5
- src/openfactcheck/solvers/factool/factool_evidence_retriever.py +1 -2
- src/openfactcheck/solvers/factool/factool_post_editor.py +1 -2
- src/openfactcheck/{core → solvers/rarr}/__init__.py +0 -0
- src/openfactcheck/{evaluator/factchecker → solvers/rarr/prompts}/__init__.py +0 -0
- src/openfactcheck/solvers/{rarr_solvers → rarr}/prompts/hallucination_prompts.py +0 -0
- src/openfactcheck/solvers/{rarr_solvers → rarr}/prompts/rarr_prompts.py +0 -0
- src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_agreement_gate.py +2 -8
- src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_concat_response_regenerator.py +2 -5
- src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_editor.py +3 -8
- src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_llm_retriever.py +3 -9
- src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_question_generator.py +2 -12
- src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_search_engine_retriever.py +3 -9
requirements.txt
CHANGED
@@ -4,6 +4,7 @@ en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_
|
|
4 |
evaluate
|
5 |
factool @ git+https://github.com/hasaniqbal777/factool
|
6 |
nltk
|
|
|
7 |
seaborn
|
8 |
sentence-transformers
|
9 |
spacy
|
|
|
4 |
evaluate
|
5 |
factool @ git+https://github.com/hasaniqbal777/factool
|
6 |
nltk
|
7 |
+
python-Levenshtein
|
8 |
seaborn
|
9 |
sentence-transformers
|
10 |
spacy
|
scripts/cli.sh
CHANGED
@@ -11,4 +11,4 @@ source "${BASH_SOURCE%/*}/common.sh"
|
|
11 |
|
12 |
# Executing Python script
|
13 |
export PYTHONPATH="$PYTHONPATH:src/"
|
14 |
-
python src/openfactcheck/
|
|
|
11 |
|
12 |
# Executing Python script
|
13 |
export PYTHONPATH="$PYTHONPATH:src/"
|
14 |
+
python src/openfactcheck/cli.py "$@"
|
src/openfactcheck/__init__.py
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
from . import *
|
|
|
|
|
|
|
2 |
|
3 |
# Version of the openfactcheck package
|
4 |
__version__ = '0.2.5'
|
|
|
1 |
from . import *
|
2 |
+
from .base import *
|
3 |
+
from .state import *
|
4 |
+
from .solver import *
|
5 |
|
6 |
# Version of the openfactcheck package
|
7 |
__version__ = '0.2.5'
|
src/openfactcheck/app/app.py
CHANGED
@@ -2,7 +2,8 @@ import argparse
|
|
2 |
import streamlit as st
|
3 |
from streamlit_option_menu import option_menu
|
4 |
|
5 |
-
from openfactcheck
|
|
|
6 |
from openfactcheck.app.sidebar import sidebar
|
7 |
from openfactcheck.app.evaluate_response import evaluate_response
|
8 |
from openfactcheck.app.evaluate_llm import evaluate_llm
|
|
|
2 |
import streamlit as st
|
3 |
from streamlit_option_menu import option_menu
|
4 |
|
5 |
+
from openfactcheck import OpenFactCheck
|
6 |
+
from openfactcheck.lib import OpenFactCheckConfig
|
7 |
from openfactcheck.app.sidebar import sidebar
|
8 |
from openfactcheck.app.evaluate_response import evaluate_response
|
9 |
from openfactcheck.app.evaluate_llm import evaluate_llm
|
src/openfactcheck/app/evaluate_factchecker.py
CHANGED
@@ -8,7 +8,8 @@ import matplotlib.pyplot as plt
|
|
8 |
from importlib import resources as pkg_resources
|
9 |
|
10 |
from openfactcheck.app.utils import metric_card
|
11 |
-
|
|
|
12 |
from openfactcheck.templates import factchecker as templates_dir
|
13 |
|
14 |
# Import solver configuration templates
|
|
|
8 |
from importlib import resources as pkg_resources
|
9 |
|
10 |
from openfactcheck.app.utils import metric_card
|
11 |
+
|
12 |
+
from openfactcheck import OpenFactCheck
|
13 |
from openfactcheck.templates import factchecker as templates_dir
|
14 |
|
15 |
# Import solver configuration templates
|
src/openfactcheck/app/evaluate_llm.py
CHANGED
@@ -5,8 +5,9 @@ import pandas as pd
|
|
5 |
import streamlit as st
|
6 |
from importlib import resources as pkg_resources
|
7 |
|
8 |
-
from openfactcheck.core.base import OpenFactCheck
|
9 |
from openfactcheck.app.utils import metric_card
|
|
|
|
|
10 |
from openfactcheck.templates import llm as templates_dir
|
11 |
|
12 |
# Import solver configuration templates
|
|
|
5 |
import streamlit as st
|
6 |
from importlib import resources as pkg_resources
|
7 |
|
|
|
8 |
from openfactcheck.app.utils import metric_card
|
9 |
+
|
10 |
+
from openfactcheck import OpenFactCheck
|
11 |
from openfactcheck.templates import llm as templates_dir
|
12 |
|
13 |
# Import solver configuration templates
|
src/openfactcheck/app/evaluate_response.py
CHANGED
@@ -3,7 +3,7 @@ import time
|
|
3 |
import pandas as pd
|
4 |
import streamlit as st
|
5 |
|
6 |
-
from openfactcheck.
|
7 |
from openfactcheck.app.utils import metric_card
|
8 |
|
9 |
def extract_text(claim):
|
|
|
3 |
import pandas as pd
|
4 |
import streamlit as st
|
5 |
|
6 |
+
from openfactcheck.base import OpenFactCheck
|
7 |
from openfactcheck.app.utils import metric_card
|
8 |
|
9 |
def extract_text(claim):
|
src/openfactcheck/{core/base.py → base.py}
RENAMED
@@ -1,22 +1,21 @@
|
|
1 |
import os
|
2 |
import sys
|
3 |
-
import json
|
4 |
from pathlib import Path
|
5 |
from typing import TYPE_CHECKING
|
6 |
|
7 |
-
from openfactcheck.lib
|
8 |
-
from openfactcheck.
|
9 |
-
from openfactcheck.
|
10 |
-
from openfactcheck.core.solver import SOLVER_REGISTRY, Solver
|
11 |
|
12 |
if TYPE_CHECKING:
|
13 |
-
from openfactcheck.evaluator.llm
|
14 |
-
from openfactcheck.evaluator.response
|
15 |
-
from openfactcheck.evaluator.
|
16 |
|
17 |
class OpenFactCheck:
|
18 |
"""
|
19 |
-
|
|
|
20 |
|
21 |
Parameters
|
22 |
----------
|
@@ -105,23 +104,23 @@ class OpenFactCheck:
|
|
105 |
"""
|
106 |
Return the LLM Evaluator
|
107 |
"""
|
108 |
-
from openfactcheck.evaluator.llm
|
109 |
return LLMEvaluator(self)
|
110 |
|
111 |
@property
|
112 |
-
def FactCheckerEvaluator(self) -> '
|
113 |
"""
|
114 |
Return the FactChecker Evaluator
|
115 |
"""
|
116 |
-
from openfactcheck.evaluator.
|
117 |
-
return
|
118 |
|
119 |
@property
|
120 |
def ResponseEvaluator(self) -> 'ResponseEvaluator':
|
121 |
"""
|
122 |
Return the LLM Response Evaluator
|
123 |
"""
|
124 |
-
from openfactcheck.evaluator.response
|
125 |
return ResponseEvaluator(self)
|
126 |
|
127 |
@staticmethod
|
|
|
1 |
import os
|
2 |
import sys
|
|
|
3 |
from pathlib import Path
|
4 |
from typing import TYPE_CHECKING
|
5 |
|
6 |
+
from openfactcheck.lib import logger
|
7 |
+
from openfactcheck.lib import OpenFactCheckConfig
|
8 |
+
from openfactcheck.solver import SOLVER_REGISTRY, Solver
|
|
|
9 |
|
10 |
if TYPE_CHECKING:
|
11 |
+
from openfactcheck.evaluator.llm import LLMEvaluator
|
12 |
+
from openfactcheck.evaluator.response import ResponseEvaluator
|
13 |
+
from openfactcheck.evaluator.checker import CheckerEvaluator
|
14 |
|
15 |
class OpenFactCheck:
|
16 |
"""
|
17 |
+
Base class for OpenFactCheck that initializes the solvers and pipeline
|
18 |
+
with the given configuration.
|
19 |
|
20 |
Parameters
|
21 |
----------
|
|
|
104 |
"""
|
105 |
Return the LLM Evaluator
|
106 |
"""
|
107 |
+
from openfactcheck.evaluator.llm import LLMEvaluator
|
108 |
return LLMEvaluator(self)
|
109 |
|
110 |
@property
|
111 |
+
def FactCheckerEvaluator(self) -> 'CheckerEvaluator':
|
112 |
"""
|
113 |
Return the FactChecker Evaluator
|
114 |
"""
|
115 |
+
from openfactcheck.evaluator.checker import CheckerEvaluator
|
116 |
+
return CheckerEvaluator(self)
|
117 |
|
118 |
@property
|
119 |
def ResponseEvaluator(self) -> 'ResponseEvaluator':
|
120 |
"""
|
121 |
Return the LLM Response Evaluator
|
122 |
"""
|
123 |
+
from openfactcheck.evaluator.response import ResponseEvaluator
|
124 |
return ResponseEvaluator(self)
|
125 |
|
126 |
@staticmethod
|
src/openfactcheck/{core/cli.py → cli.py}
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
import argparse
|
2 |
|
3 |
-
from openfactcheck
|
4 |
-
from openfactcheck.lib
|
5 |
|
6 |
def parse_args():
|
7 |
parser = argparse.ArgumentParser(description='Initialize OpenFactCheck with custom configuration.')
|
@@ -23,7 +23,5 @@ if __name__ == "__main__":
|
|
23 |
print(f"Callback: {index}, {sample_name}, {solver_name}, {input_name}, {output_name}, {input}, {output}, {continue_run}")
|
24 |
|
25 |
config = OpenFactCheckConfig(args.config_path)
|
26 |
-
results = OpenFactCheck(config).
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
1 |
import argparse
|
2 |
|
3 |
+
from openfactcheck import OpenFactCheck
|
4 |
+
from openfactcheck.lib import OpenFactCheckConfig
|
5 |
|
6 |
def parse_args():
|
7 |
parser = argparse.ArgumentParser(description='Initialize OpenFactCheck with custom configuration.')
|
|
|
23 |
print(f"Callback: {index}, {sample_name}, {solver_name}, {input_name}, {output_name}, {input}, {output}, {continue_run}")
|
24 |
|
25 |
config = OpenFactCheckConfig(args.config_path)
|
26 |
+
results = OpenFactCheck(config).ResponseEvaluator.evaluate("Abraham Lincoln was the first president of the United States.",
|
27 |
+
callback=callback)
|
|
|
|
src/openfactcheck/{lib/errors.py → errors.py}
RENAMED
File without changes
|
src/openfactcheck/evaluator/__init__.py
CHANGED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
from .response import ResponseEvaluator
|
2 |
+
from .llm import LLMEvaluator
|
3 |
+
from .checker import CheckerEvaluator
|
src/openfactcheck/evaluator/checker/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
from .evaluate import CheckerEvaluator
|
src/openfactcheck/evaluator/{factchecker → checker}/evaluate.py
RENAMED
@@ -5,14 +5,14 @@ from importlib import resources as pkg_resources
|
|
5 |
from sklearn.metrics import accuracy_score, precision_score, f1_score, recall_score
|
6 |
from sklearn.metrics import classification_report, confusion_matrix
|
7 |
|
8 |
-
from openfactcheck
|
9 |
from openfactcheck.templates import factchecker as templates_dir
|
10 |
|
11 |
# Import solver configuration templates
|
12 |
gold_claims_template_path = str(pkg_resources.files(templates_dir) / "gold/claims.jsonl")
|
13 |
gold_documents_template_path = str(pkg_resources.files(templates_dir) / "gold/documents.jsonl")
|
14 |
|
15 |
-
class
|
16 |
"""
|
17 |
This class is used to evaluate the performance of a FactChecker.
|
18 |
|
|
|
5 |
from sklearn.metrics import accuracy_score, precision_score, f1_score, recall_score
|
6 |
from sklearn.metrics import classification_report, confusion_matrix
|
7 |
|
8 |
+
from openfactcheck import OpenFactCheck
|
9 |
from openfactcheck.templates import factchecker as templates_dir
|
10 |
|
11 |
# Import solver configuration templates
|
12 |
gold_claims_template_path = str(pkg_resources.files(templates_dir) / "gold/claims.jsonl")
|
13 |
gold_documents_template_path = str(pkg_resources.files(templates_dir) / "gold/documents.jsonl")
|
14 |
|
15 |
+
class CheckerEvaluator():
|
16 |
"""
|
17 |
This class is used to evaluate the performance of a FactChecker.
|
18 |
|
src/openfactcheck/evaluator/llm/__init__.py
CHANGED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
from .evaluate import LLMEvaluator
|
src/openfactcheck/evaluator/llm/evaluate.py
CHANGED
@@ -4,8 +4,8 @@ import uuid
|
|
4 |
import pandas as pd
|
5 |
from importlib import resources as pkg_resources
|
6 |
|
7 |
-
from openfactcheck
|
8 |
-
from openfactcheck.
|
9 |
from openfactcheck.evaluator.llm.evaluate_snowballing import SnowballingEvaluator
|
10 |
from openfactcheck.evaluator.llm.evaluate_selfaware import SelfAwareEvaluator
|
11 |
from openfactcheck.evaluator.llm.evaluate_freshqa import FreshQAEvaluator
|
|
|
4 |
import pandas as pd
|
5 |
from importlib import resources as pkg_resources
|
6 |
|
7 |
+
from openfactcheck import OpenFactCheck
|
8 |
+
from openfactcheck.lib import logger
|
9 |
from openfactcheck.evaluator.llm.evaluate_snowballing import SnowballingEvaluator
|
10 |
from openfactcheck.evaluator.llm.evaluate_selfaware import SelfAwareEvaluator
|
11 |
from openfactcheck.evaluator.llm.evaluate_freshqa import FreshQAEvaluator
|
src/openfactcheck/evaluator/llm/evaluate_freetext.py
CHANGED
@@ -7,8 +7,8 @@ import seaborn as sns
|
|
7 |
from hashlib import md5
|
8 |
import matplotlib.pyplot as plt
|
9 |
|
10 |
-
from openfactcheck
|
11 |
-
from openfactcheck.
|
12 |
|
13 |
class FreeTextEvaluator():
|
14 |
def __init__(self, ofc: OpenFactCheck):
|
|
|
7 |
from hashlib import md5
|
8 |
import matplotlib.pyplot as plt
|
9 |
|
10 |
+
from openfactcheck import OpenFactCheck
|
11 |
+
from openfactcheck.lib import logger
|
12 |
|
13 |
class FreeTextEvaluator():
|
14 |
def __init__(self, ofc: OpenFactCheck):
|
src/openfactcheck/evaluator/llm/evaluate_freshqa.py
CHANGED
@@ -3,7 +3,6 @@ import re
|
|
3 |
import pytz
|
4 |
import datetime
|
5 |
import pandas as pd
|
6 |
-
import seaborn as sns
|
7 |
from openai import OpenAI
|
8 |
import matplotlib.pyplot as plt
|
9 |
|
|
|
3 |
import pytz
|
4 |
import datetime
|
5 |
import pandas as pd
|
|
|
6 |
from openai import OpenAI
|
7 |
import matplotlib.pyplot as plt
|
8 |
|
src/openfactcheck/evaluator/llm/evaluate_snowballing.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import os
|
2 |
import re
|
3 |
-
import numpy as np
|
4 |
import seaborn as sns
|
5 |
import matplotlib.pyplot as plt
|
6 |
from sklearn.metrics import classification_report, confusion_matrix
|
|
|
1 |
import os
|
2 |
import re
|
|
|
3 |
import seaborn as sns
|
4 |
import matplotlib.pyplot as plt
|
5 |
from sklearn.metrics import classification_report, confusion_matrix
|
src/openfactcheck/evaluator/llm/report.py
CHANGED
@@ -5,7 +5,7 @@ from jinja2 import Environment, FileSystemLoader
|
|
5 |
|
6 |
from importlib import resources as pkg_resources
|
7 |
|
8 |
-
from openfactcheck.lib
|
9 |
from openfactcheck.templates import report as report_dir
|
10 |
|
11 |
# Import latex template
|
|
|
5 |
|
6 |
from importlib import resources as pkg_resources
|
7 |
|
8 |
+
from openfactcheck.lib import logger
|
9 |
from openfactcheck.templates import report as report_dir
|
10 |
|
11 |
# Import latex template
|
src/openfactcheck/evaluator/response/__init__.py
CHANGED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
from .evaluate import ResponseEvaluator
|
src/openfactcheck/evaluator/response/evaluate.py
CHANGED
@@ -6,10 +6,13 @@ import traceback
|
|
6 |
from typing import Callable
|
7 |
|
8 |
from openfactcheck.lib.logger import logger
|
9 |
-
from openfactcheck.
|
10 |
-
from openfactcheck.
|
11 |
|
12 |
class ResponseEvaluator:
|
|
|
|
|
|
|
13 |
def __init__(self, ofc: OpenFactCheck):
|
14 |
"""
|
15 |
Initialize the ResponseEvaluator object.
|
|
|
6 |
from typing import Callable
|
7 |
|
8 |
from openfactcheck.lib.logger import logger
|
9 |
+
from openfactcheck.base import OpenFactCheck
|
10 |
+
from openfactcheck.state import FactCheckerState
|
11 |
|
12 |
class ResponseEvaluator:
|
13 |
+
"""
|
14 |
+
This class is used to evaluate the factuality of a response using the pipeline of solvers.
|
15 |
+
"""
|
16 |
def __init__(self, ofc: OpenFactCheck):
|
17 |
"""
|
18 |
Initialize the ResponseEvaluator object.
|
src/openfactcheck/lib/__init__.py
CHANGED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
from .config import *
|
2 |
+
from .logger import *
|
src/openfactcheck/lib/config.py
CHANGED
@@ -1,18 +1,15 @@
|
|
1 |
import os
|
2 |
import json
|
3 |
import yaml
|
4 |
-
import openai
|
5 |
-
import asyncio
|
6 |
import logging
|
7 |
import datasets
|
8 |
import transformers
|
9 |
from pathlib import Path
|
10 |
-
from typing import Union
|
11 |
from collections import namedtuple
|
12 |
from importlib import resources as pkg_resources
|
13 |
|
14 |
from openfactcheck.lib.logger import logger, set_logger_level
|
15 |
-
from openfactcheck.
|
16 |
from openfactcheck import templates as solver_config_templates_dir
|
17 |
from openfactcheck import solvers as solver_templates_dir
|
18 |
|
@@ -34,7 +31,7 @@ class OpenFactCheckConfig:
|
|
34 |
|
35 |
Parameters
|
36 |
----------
|
37 |
-
|
38 |
The path to the configuration file.
|
39 |
|
40 |
Attributes
|
@@ -65,10 +62,10 @@ class OpenFactCheckConfig:
|
|
65 |
--------
|
66 |
>>> config = OpenFactCheckConfig("config.json")
|
67 |
"""
|
68 |
-
def __init__(self,
|
69 |
# Setup Logger
|
70 |
self.logger = logger
|
71 |
-
self.
|
72 |
|
73 |
# Define namedtuple structures
|
74 |
Secrets = namedtuple("Secrets", ["openai_api_key",
|
@@ -87,14 +84,14 @@ class OpenFactCheckConfig:
|
|
87 |
|
88 |
try:
|
89 |
# Check if the file exists
|
90 |
-
if Path(self.
|
91 |
# Loading Config File
|
92 |
-
with open(self.
|
93 |
self.config = json.load(file)
|
94 |
-
self.logger.info(f"Config file loaded successfully from {self.
|
95 |
else:
|
96 |
# Create a dummy configuration file
|
97 |
-
self.logger.warning(f"Config file not found: {self.
|
98 |
self.config = {}
|
99 |
|
100 |
# Initialize Retries
|
@@ -185,12 +182,12 @@ class OpenFactCheckConfig:
|
|
185 |
logging.getLogger("asyncio").setLevel(logging.CRITICAL)
|
186 |
|
187 |
except FileNotFoundError:
|
188 |
-
self.logger.error(f"Config file not found: {self.
|
189 |
-
raise FileNotFoundError(f"Config file not found: {self.
|
190 |
|
191 |
except json.JSONDecodeError:
|
192 |
-
self.logger.error(f"Invalid JSON in config file: {self.
|
193 |
-
raise ValueError(f"Invalid JSON in config file: {self.
|
194 |
|
195 |
except ConfigValidationError as e:
|
196 |
self.logger.error(f"Configuration validation failed: {e}")
|
@@ -270,35 +267,35 @@ class SolversConfig:
|
|
270 |
|
271 |
Parameters
|
272 |
----------
|
273 |
-
filename(s): str,
|
274 |
The path to the solvers configuration or a list of paths to multiple solvers configurations.
|
275 |
"""
|
276 |
-
def __init__(self,
|
277 |
self.logger = logger
|
278 |
-
self.
|
279 |
self.solvers = {}
|
280 |
|
281 |
try:
|
282 |
-
if isinstance(self.
|
283 |
-
self.load_config(self.
|
284 |
-
elif isinstance(self.
|
285 |
-
for filename in self.
|
286 |
self.load_config(filename)
|
287 |
else:
|
288 |
-
self.logger.error(f"Invalid filename type: {type(self.
|
289 |
-
raise ValueError(f"Invalid filename type: {type(self.
|
290 |
|
291 |
except FileNotFoundError:
|
292 |
-
self.logger.error(f"Solvers file not found: {self.
|
293 |
-
raise FileNotFoundError(f"Solvers file not found: {self.
|
294 |
except json.JSONDecodeError:
|
295 |
-
self.logger.error(f"Invalid JSON in solvers file: {self.
|
296 |
-
raise ValueError(f"Invalid JSON in solvers file: {self.
|
297 |
except Exception as e:
|
298 |
self.logger.error(f"Unexpected error loading solvers file: {e}")
|
299 |
raise Exception(f"Unexpected error loading solvers file: {e}")
|
300 |
|
301 |
-
def load_config(self, filename:
|
302 |
with open(filename, encoding="utf-8") as file:
|
303 |
if filename.endswith(".yaml"):
|
304 |
file_data = yaml.load(file, Loader=yaml.FullLoader)
|
|
|
1 |
import os
|
2 |
import json
|
3 |
import yaml
|
|
|
|
|
4 |
import logging
|
5 |
import datasets
|
6 |
import transformers
|
7 |
from pathlib import Path
|
|
|
8 |
from collections import namedtuple
|
9 |
from importlib import resources as pkg_resources
|
10 |
|
11 |
from openfactcheck.lib.logger import logger, set_logger_level
|
12 |
+
from openfactcheck.errors import ConfigValidationError
|
13 |
from openfactcheck import templates as solver_config_templates_dir
|
14 |
from openfactcheck import solvers as solver_templates_dir
|
15 |
|
|
|
31 |
|
32 |
Parameters
|
33 |
----------
|
34 |
+
filename_or_path: str or path object
|
35 |
The path to the configuration file.
|
36 |
|
37 |
Attributes
|
|
|
62 |
--------
|
63 |
>>> config = OpenFactCheckConfig("config.json")
|
64 |
"""
|
65 |
+
def __init__(self, filename_or_path: str | Path = "config.json"):
|
66 |
# Setup Logger
|
67 |
self.logger = logger
|
68 |
+
self.filename_or_path = filename_or_path
|
69 |
|
70 |
# Define namedtuple structures
|
71 |
Secrets = namedtuple("Secrets", ["openai_api_key",
|
|
|
84 |
|
85 |
try:
|
86 |
# Check if the file exists
|
87 |
+
if Path(self.filename_or_path).exists():
|
88 |
# Loading Config File
|
89 |
+
with open(self.filename_or_path, encoding="utf-8") as file:
|
90 |
self.config = json.load(file)
|
91 |
+
self.logger.info(f"Config file loaded successfully from {self.filename_or_path}")
|
92 |
else:
|
93 |
# Create a dummy configuration file
|
94 |
+
self.logger.warning(f"Config file not found: {self.filename_or_path}")
|
95 |
self.config = {}
|
96 |
|
97 |
# Initialize Retries
|
|
|
182 |
logging.getLogger("asyncio").setLevel(logging.CRITICAL)
|
183 |
|
184 |
except FileNotFoundError:
|
185 |
+
self.logger.error(f"Config file not found: {self.filename_or_path}")
|
186 |
+
raise FileNotFoundError(f"Config file not found: {self.filename_or_path}")
|
187 |
|
188 |
except json.JSONDecodeError:
|
189 |
+
self.logger.error(f"Invalid JSON in config file: {self.filename_or_path}")
|
190 |
+
raise ValueError(f"Invalid JSON in config file: {self.filename_or_path}")
|
191 |
|
192 |
except ConfigValidationError as e:
|
193 |
self.logger.error(f"Configuration validation failed: {e}")
|
|
|
267 |
|
268 |
Parameters
|
269 |
----------
|
270 |
+
filename(s): str, list or path object
|
271 |
The path to the solvers configuration or a list of paths to multiple solvers configurations.
|
272 |
"""
|
273 |
+
def __init__(self, filename_or_path_s: str | Path | list):
|
274 |
self.logger = logger
|
275 |
+
self.filename_or_path_or_path_s = filename_or_path_s
|
276 |
self.solvers = {}
|
277 |
|
278 |
try:
|
279 |
+
if isinstance(self.filename_or_path_or_path_s, (str, Path)):
|
280 |
+
self.load_config(self.filename_or_path_or_path_s)
|
281 |
+
elif isinstance(self.filename_or_path_or_path_s, list):
|
282 |
+
for filename in self.filename_or_path_or_path_s:
|
283 |
self.load_config(filename)
|
284 |
else:
|
285 |
+
self.logger.error(f"Invalid filename type: {type(self.filename_or_path_or_path_s)}")
|
286 |
+
raise ValueError(f"Invalid filename type: {type(self.filename_or_path_or_path_s)}")
|
287 |
|
288 |
except FileNotFoundError:
|
289 |
+
self.logger.error(f"Solvers file not found: {self.filename_or_path_or_path_s}")
|
290 |
+
raise FileNotFoundError(f"Solvers file not found: {self.filename_or_path_or_path_s}")
|
291 |
except json.JSONDecodeError:
|
292 |
+
self.logger.error(f"Invalid JSON in solvers file: {self.filename_or_path_or_path_s}")
|
293 |
+
raise ValueError(f"Invalid JSON in solvers file: {self.filename_or_path_or_path_s}")
|
294 |
except Exception as e:
|
295 |
self.logger.error(f"Unexpected error loading solvers file: {e}")
|
296 |
raise Exception(f"Unexpected error loading solvers file: {e}")
|
297 |
|
298 |
+
def load_config(self, filename: str | Path):
|
299 |
with open(filename, encoding="utf-8") as file:
|
300 |
if filename.endswith(".yaml"):
|
301 |
file_data = yaml.load(file, Loader=yaml.FullLoader)
|
src/openfactcheck/lib/openai.py
DELETED
File without changes
|
src/openfactcheck/{core/solver.py → solver.py}
RENAMED
@@ -2,8 +2,8 @@ import sys
|
|
2 |
import os
|
3 |
import importlib
|
4 |
|
5 |
-
from openfactcheck.lib
|
6 |
-
from openfactcheck.
|
7 |
|
8 |
# Global solver registry
|
9 |
SOLVER_REGISTRY = {}
|
|
|
2 |
import os
|
3 |
import importlib
|
4 |
|
5 |
+
from openfactcheck.lib import logger
|
6 |
+
from openfactcheck.state import FactCheckerState
|
7 |
|
8 |
# Global solver registry
|
9 |
SOLVER_REGISTRY = {}
|
src/openfactcheck/solvers/dummy/confused_claim_examiner.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import random
|
2 |
|
3 |
-
from openfactcheck
|
4 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
5 |
|
6 |
@Solver.register("confused_claim_examiner", "claims_with_evidences", "claims_with_tags")
|
7 |
class ConfusedClaimExaminer(StandardTaskSolver):
|
|
|
1 |
import random
|
2 |
|
3 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
4 |
|
5 |
@Solver.register("confused_claim_examiner", "claims_with_evidences", "claims_with_tags")
|
6 |
class ConfusedClaimExaminer(StandardTaskSolver):
|
src/openfactcheck/solvers/dummy/fake_claim_extractor.py
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
import random
|
2 |
|
3 |
-
from openfactcheck
|
4 |
-
from openfactcheck.core.state import FactCheckerState
|
5 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
6 |
|
7 |
@Solver.register("fake_claim_extractor", "response", "claims")
|
8 |
class FakeClaimExtractor(StandardTaskSolver):
|
|
|
1 |
import random
|
2 |
|
3 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
|
|
4 |
|
5 |
@Solver.register("fake_claim_extractor", "response", "claims")
|
6 |
class FakeClaimExtractor(StandardTaskSolver):
|
src/openfactcheck/solvers/dummy/ignorant_search_engine_retriever.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
import random
|
2 |
import string
|
3 |
|
4 |
-
from openfactcheck
|
5 |
-
from openfactcheck.core.state import FactCheckerState
|
6 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
7 |
|
8 |
@Solver.register("ignorant_search_engine_retriever", "claims", "claims_with_evidences")
|
9 |
class IgnorantSearchEngineRetriever(StandardTaskSolver):
|
|
|
1 |
import random
|
2 |
import string
|
3 |
|
4 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
|
|
5 |
|
6 |
@Solver.register("ignorant_search_engine_retriever", "claims", "claims_with_evidences")
|
7 |
class IgnorantSearchEngineRetriever(StandardTaskSolver):
|
src/openfactcheck/solvers/dummy/useless_response_regenerator.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
from openfactcheck
|
2 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
3 |
|
4 |
@Solver.register("useless_response_regenerator", "claims_with_tags", "output")
|
5 |
class UselessResponseRegenerator(StandardTaskSolver):
|
|
|
1 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
2 |
|
3 |
@Solver.register("useless_response_regenerator", "claims_with_tags", "output")
|
4 |
class UselessResponseRegenerator(StandardTaskSolver):
|
src/openfactcheck/solvers/factcheckgpt/factcheckgpt_cp.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
import nltk
|
2 |
import spacy
|
3 |
|
4 |
-
from openfactcheck
|
5 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
6 |
|
7 |
from .factcheckgpt_utils.openai_api import gpt
|
8 |
from .factcheckgpt_utils.data_util import save_to_file
|
|
|
1 |
import nltk
|
2 |
import spacy
|
3 |
|
4 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
5 |
|
6 |
from .factcheckgpt_utils.openai_api import gpt
|
7 |
from .factcheckgpt_utils.data_util import save_to_file
|
src/openfactcheck/solvers/factcheckgpt/factcheckgpt_rtv.py
CHANGED
@@ -11,8 +11,7 @@ from copy import deepcopy
|
|
11 |
from openai import RateLimitError
|
12 |
from sentence_transformers import CrossEncoder
|
13 |
|
14 |
-
from openfactcheck
|
15 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
16 |
|
17 |
from .factcheckgpt_utils.openai_api import gpt
|
18 |
from .factcheckgpt_utils.prompt import QGEN_PROMPT, QGEN_PROMPT_FMT
|
|
|
11 |
from openai import RateLimitError
|
12 |
from sentence_transformers import CrossEncoder
|
13 |
|
14 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
15 |
|
16 |
from .factcheckgpt_utils.openai_api import gpt
|
17 |
from .factcheckgpt_utils.prompt import QGEN_PROMPT, QGEN_PROMPT_FMT
|
src/openfactcheck/solvers/factcheckgpt/factcheckgpt_vfr.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
import json
|
2 |
from typing import Any
|
3 |
|
4 |
-
from openfactcheck
|
5 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
6 |
|
7 |
from .factcheckgpt_utils.prompt import VERIFY_PROMPT
|
8 |
from .factcheckgpt_utils.openai_api import gpt
|
|
|
1 |
import json
|
2 |
from typing import Any
|
3 |
|
4 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
5 |
|
6 |
from .factcheckgpt_utils.prompt import VERIFY_PROMPT
|
7 |
from .factcheckgpt_utils.openai_api import gpt
|
src/openfactcheck/solvers/factool/all_pass_abstain_detector.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
from openfactcheck
|
2 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
3 |
|
4 |
@Solver.register("all_pass_abstain_detector", "response", "response")
|
5 |
class AllPassAbstainDetector(StandardTaskSolver):
|
|
|
1 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
2 |
|
3 |
@Solver.register("all_pass_abstain_detector", "response", "response")
|
4 |
class AllPassAbstainDetector(StandardTaskSolver):
|
src/openfactcheck/solvers/factool/concat_response_regenerator.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
from openfactcheck
|
2 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
3 |
|
4 |
@Solver.register("concat_response_generator", "claim_info", "output")
|
5 |
class ConcatResponseRegenerator(StandardTaskSolver):
|
|
|
1 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
2 |
|
3 |
@Solver.register("concat_response_generator", "claim_info", "output")
|
4 |
class ConcatResponseRegenerator(StandardTaskSolver):
|
src/openfactcheck/solvers/factool/factool_blackbox.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
from factool import Factool
|
2 |
|
3 |
-
from openfactcheck
|
4 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
5 |
|
6 |
@Solver.register("factool_blackbox", "response", "claim_info")
|
7 |
class FactoolBlackboxSolver(StandardTaskSolver):
|
|
|
1 |
from factool import Factool
|
2 |
|
3 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
4 |
|
5 |
@Solver.register("factool_blackbox", "response", "claim_info")
|
6 |
class FactoolBlackboxSolver(StandardTaskSolver):
|
src/openfactcheck/solvers/factool/factool_blackbox_post_editor.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import json
|
2 |
|
3 |
-
from openfactcheck
|
4 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
5 |
|
6 |
@Solver.register("factool_blackbox_post_editor", "claim_info", "claim_info")
|
7 |
class FactoolBlackboxPostEditor(StandardTaskSolver):
|
|
|
1 |
import json
|
2 |
|
3 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
4 |
|
5 |
@Solver.register("factool_blackbox_post_editor", "claim_info", "claim_info")
|
6 |
class FactoolBlackboxPostEditor(StandardTaskSolver):
|
src/openfactcheck/solvers/factool/factool_claim_examiner.py
CHANGED
@@ -3,8 +3,7 @@ import json
|
|
3 |
from .factool_utils.chat_api import OpenAIChat
|
4 |
from .factool_utils.prompt import VERIFICATION_PROMPT
|
5 |
|
6 |
-
from openfactcheck
|
7 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
8 |
|
9 |
@Solver.register("factool_claim_examiner", "evidences", "claim_info")
|
10 |
class FactoolClaimExaminer(StandardTaskSolver):
|
|
|
3 |
from .factool_utils.chat_api import OpenAIChat
|
4 |
from .factool_utils.prompt import VERIFICATION_PROMPT
|
5 |
|
6 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
7 |
|
8 |
@Solver.register("factool_claim_examiner", "evidences", "claim_info")
|
9 |
class FactoolClaimExaminer(StandardTaskSolver):
|
src/openfactcheck/solvers/factool/factool_decontextualizer.py
CHANGED
@@ -1,10 +1,7 @@
|
|
1 |
-
import os
|
2 |
-
import yaml
|
3 |
-
|
4 |
from .factool_utils.chat_api import OpenAIChat
|
5 |
from .factool_utils.prompt import CLAIM_EXTRACTION_PROMPT
|
6 |
-
|
7 |
-
from openfactcheck
|
8 |
|
9 |
@Solver.register("factool_decontextualizer", "response", "claims")
|
10 |
class FactoolDecontextualizer(StandardTaskSolver):
|
|
|
|
|
|
|
|
|
1 |
from .factool_utils.chat_api import OpenAIChat
|
2 |
from .factool_utils.prompt import CLAIM_EXTRACTION_PROMPT
|
3 |
+
|
4 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
5 |
|
6 |
@Solver.register("factool_decontextualizer", "response", "claims")
|
7 |
class FactoolDecontextualizer(StandardTaskSolver):
|
src/openfactcheck/solvers/factool/factool_evidence_retriever.py
CHANGED
@@ -5,8 +5,7 @@ from .factool_utils.chat_api import OpenAIChat
|
|
5 |
from .factool_utils.search_api import GoogleSerperAPIWrapper
|
6 |
from .factool_utils.prompt import QUERY_GENERATION_PROMPT
|
7 |
|
8 |
-
from openfactcheck
|
9 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
10 |
|
11 |
@Solver.register("factool_evidence_retriever", "claims", "evidences")
|
12 |
class FactoolEvidenceRetriever(StandardTaskSolver):
|
|
|
5 |
from .factool_utils.search_api import GoogleSerperAPIWrapper
|
6 |
from .factool_utils.prompt import QUERY_GENERATION_PROMPT
|
7 |
|
8 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
9 |
|
10 |
@Solver.register("factool_evidence_retriever", "claims", "evidences")
|
11 |
class FactoolEvidenceRetriever(StandardTaskSolver):
|
src/openfactcheck/solvers/factool/factool_post_editor.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
from openfactcheck
|
2 |
-
from openfactcheck.core.solver import StandardTaskSolver, Solver
|
3 |
|
4 |
@Solver.register("factool_post_editor", "claim_info", "claim_info")
|
5 |
class FactoolPostEditor(StandardTaskSolver):
|
|
|
1 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
2 |
|
3 |
@Solver.register("factool_post_editor", "claim_info", "claim_info")
|
4 |
class FactoolPostEditor(StandardTaskSolver):
|
src/openfactcheck/{core → solvers/rarr}/__init__.py
RENAMED
File without changes
|
src/openfactcheck/{evaluator/factchecker → solvers/rarr/prompts}/__init__.py
RENAMED
File without changes
|
src/openfactcheck/solvers/{rarr_solvers → rarr}/prompts/hallucination_prompts.py
RENAMED
File without changes
|
src/openfactcheck/solvers/{rarr_solvers → rarr}/prompts/rarr_prompts.py
RENAMED
File without changes
|
src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_agreement_gate.py
RENAMED
@@ -1,15 +1,9 @@
|
|
1 |
-
import logging
|
2 |
-
|
3 |
-
from core.fact_check_state import FactCheckerState
|
4 |
-
from core.task_solver import StandardTaskSolver
|
5 |
-
from core import register_solver
|
6 |
-
import random
|
7 |
-
import string
|
8 |
from .rarr_utils import agreement_gate
|
9 |
from .prompts import rarr_prompts
|
10 |
|
|
|
11 |
|
12 |
-
@
|
13 |
class RARRAgreementGate(StandardTaskSolver):
|
14 |
def __init__(self, args):
|
15 |
super().__init__(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from .rarr_utils import agreement_gate
|
2 |
from .prompts import rarr_prompts
|
3 |
|
4 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
5 |
|
6 |
+
@Solver.register("rarr_agreement_gate", "claims_with_evidences", "claims_with_gates")
|
7 |
class RARRAgreementGate(StandardTaskSolver):
|
8 |
def __init__(self, args):
|
9 |
super().__init__(args)
|
src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_concat_response_regenerator.py
RENAMED
@@ -1,9 +1,6 @@
|
|
1 |
-
from
|
2 |
-
from core.task_solver import StandardTaskSolver
|
3 |
-
from core import register_solver
|
4 |
|
5 |
-
|
6 |
-
@register_solver("rarr_concat_response_generator", "revised_claims", "output")
|
7 |
class RARRConcatResponseRegenerator(StandardTaskSolver):
|
8 |
def __init__(self, args):
|
9 |
super().__init__(args)
|
|
|
1 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
|
|
|
|
2 |
|
3 |
+
@Solver.register("rarr_concat_response_generator", "revised_claims", "output")
|
|
|
4 |
class RARRConcatResponseRegenerator(StandardTaskSolver):
|
5 |
def __init__(self, args):
|
6 |
super().__init__(args)
|
src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_editor.py
RENAMED
@@ -1,16 +1,11 @@
|
|
1 |
-
import
|
2 |
|
3 |
-
from core.fact_check_state import FactCheckerState
|
4 |
-
from core.task_solver import StandardTaskSolver
|
5 |
-
from core import register_solver
|
6 |
-
import random
|
7 |
-
import string
|
8 |
from .rarr_utils import agreement_gate, editor, evidence_selection
|
9 |
from .prompts import rarr_prompts
|
10 |
-
import Levenshtein
|
11 |
|
|
|
12 |
|
13 |
-
@
|
14 |
class RARREditor(StandardTaskSolver):
|
15 |
def __init__(self, args):
|
16 |
super().__init__(args)
|
|
|
1 |
+
import Levenshtein
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
from .rarr_utils import agreement_gate, editor, evidence_selection
|
4 |
from .prompts import rarr_prompts
|
|
|
5 |
|
6 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
7 |
|
8 |
+
@Solver.register("rarr_editor", "claims_with_evidences", "revised_claims")
|
9 |
class RARREditor(StandardTaskSolver):
|
10 |
def __init__(self, args):
|
11 |
super().__init__(args)
|
src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_llm_retriever.py
RENAMED
@@ -1,16 +1,10 @@
|
|
1 |
-
import logging
|
2 |
-
|
3 |
-
from core.fact_check_state import FactCheckerState
|
4 |
-
from core.task_solver import StandardTaskSolver
|
5 |
-
from core import register_solver
|
6 |
-
import random
|
7 |
-
import string
|
8 |
from .rarr_utils.hallucination import run_evidence_hallucination
|
9 |
from .prompts.hallucination_prompts import EVIDENCE_HALLUCINATION
|
10 |
|
|
|
11 |
|
12 |
-
@
|
13 |
-
class
|
14 |
def __init__(self, args):
|
15 |
super().__init__(args)
|
16 |
self.model = self.global_config.get("model", "gpt-3.5-turbo-instruct")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from .rarr_utils.hallucination import run_evidence_hallucination
|
2 |
from .prompts.hallucination_prompts import EVIDENCE_HALLUCINATION
|
3 |
|
4 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
5 |
|
6 |
+
@Solver.register("llm_retriever", "claims_with_questions", "claims_with_evidences")
|
7 |
+
class RARRLLMRetriever(StandardTaskSolver):
|
8 |
def __init__(self, args):
|
9 |
super().__init__(args)
|
10 |
self.model = self.global_config.get("model", "gpt-3.5-turbo-instruct")
|
src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_question_generator.py
RENAMED
@@ -1,19 +1,9 @@
|
|
1 |
-
import logging
|
2 |
-
|
3 |
-
from core.fact_check_state import FactCheckerState
|
4 |
-
from core.task_solver import StandardTaskSolver
|
5 |
-
from core import register_solver
|
6 |
-
import random
|
7 |
-
import string
|
8 |
-
import os
|
9 |
-
import time
|
10 |
-
from typing import List
|
11 |
-
import openai
|
12 |
from .rarr_utils.question_generation import run_rarr_question_generation
|
13 |
from .prompts import rarr_prompts
|
14 |
|
|
|
15 |
|
16 |
-
@
|
17 |
class RARRQuestionGenerator(StandardTaskSolver):
|
18 |
def __init__(self, args):
|
19 |
super().__init__(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from .rarr_utils.question_generation import run_rarr_question_generation
|
2 |
from .prompts import rarr_prompts
|
3 |
|
4 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
5 |
|
6 |
+
@Solver.register("rarr_question_generator", "claims_with_context", "claims_with_questions")
|
7 |
class RARRQuestionGenerator(StandardTaskSolver):
|
8 |
def __init__(self, args):
|
9 |
super().__init__(args)
|
src/openfactcheck/solvers/{rarr_solvers → rarr}/rarr_search_engine_retriever.py
RENAMED
@@ -1,15 +1,9 @@
|
|
1 |
-
import logging
|
2 |
-
|
3 |
-
from core.fact_check_state import FactCheckerState
|
4 |
-
from core.task_solver import StandardTaskSolver
|
5 |
-
from core import register_solver
|
6 |
-
import random
|
7 |
-
import string
|
8 |
from .rarr_utils import search
|
9 |
|
|
|
10 |
|
11 |
-
@
|
12 |
-
class
|
13 |
def __init__(self, args):
|
14 |
super().__init__(args)
|
15 |
self.max_search_results_per_query = args.get("max_search_results_per_query", 5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from .rarr_utils import search
|
2 |
|
3 |
+
from openfactcheck import FactCheckerState, StandardTaskSolver, Solver
|
4 |
|
5 |
+
@Solver.register("search_engine_retriever", "claims_with_questions", "claims_with_evidences")
|
6 |
+
class RARRSearchEngineRetriever(StandardTaskSolver):
|
7 |
def __init__(self, args):
|
8 |
super().__init__(args)
|
9 |
self.max_search_results_per_query = args.get("max_search_results_per_query", 5)
|