Spaces:
Running
Running
Update predictors.py
Browse files- predictors.py +15 -14
predictors.py
CHANGED
@@ -60,16 +60,16 @@ text_bc_model = BetterTransformer.transform(text_bc_model)
|
|
60 |
text_mc_model = BetterTransformer.transform(text_mc_model)
|
61 |
quillbot_model = BetterTransformer.transform(quillbot_model)
|
62 |
|
63 |
-
bias_model_checker = AutoModelForSequenceClassification.from_pretrained(bias_checker_model_name)
|
64 |
-
tokenizer = AutoTokenizer.from_pretrained(bias_checker_model_name)
|
65 |
-
bias_model_checker = BetterTransformer.transform(bias_model_checker, keep_original_model=False)
|
66 |
-
bias_checker = pipeline(
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
)
|
71 |
-
gc.collect()
|
72 |
-
bias_corrector = pipeline( "text2text-generation", model=bias_corrector_model_name, accelerator="ort")
|
73 |
|
74 |
# model score calibration
|
75 |
iso_reg = joblib.load("isotonic_regression_model.joblib")
|
@@ -105,10 +105,11 @@ def update(text: str):
|
|
105 |
return corrections_display
|
106 |
|
107 |
def update_main(text: str):
|
108 |
-
text = clean(text, lower=False)
|
109 |
-
corrected_text, corrections = correct_text(text, bias_checker, bias_corrector)
|
110 |
-
corrections_display = "\n\n".join([f"Original: {orig}\nCorrected: {corr}" for orig, corr in corrections])
|
111 |
-
return corrected_text, corrections_display
|
|
|
112 |
|
113 |
def split_text(text: str) -> list:
|
114 |
sentences = sent_tokenize(text)
|
|
|
60 |
text_mc_model = BetterTransformer.transform(text_mc_model)
|
61 |
quillbot_model = BetterTransformer.transform(quillbot_model)
|
62 |
|
63 |
+
# bias_model_checker = AutoModelForSequenceClassification.from_pretrained(bias_checker_model_name)
|
64 |
+
# tokenizer = AutoTokenizer.from_pretrained(bias_checker_model_name)
|
65 |
+
# bias_model_checker = BetterTransformer.transform(bias_model_checker, keep_original_model=False)
|
66 |
+
# bias_checker = pipeline(
|
67 |
+
# "text-classification",
|
68 |
+
# model=bias_checker_model_name,
|
69 |
+
# tokenizer=bias_checker_model_name,
|
70 |
+
# )
|
71 |
+
# gc.collect()
|
72 |
+
# bias_corrector = pipeline( "text2text-generation", model=bias_corrector_model_name, accelerator="ort")
|
73 |
|
74 |
# model score calibration
|
75 |
iso_reg = joblib.load("isotonic_regression_model.joblib")
|
|
|
105 |
return corrections_display
|
106 |
|
107 |
def update_main(text: str):
|
108 |
+
# text = clean(text, lower=False)
|
109 |
+
# corrected_text, corrections = correct_text(text, bias_checker, bias_corrector)
|
110 |
+
# corrections_display = "\n\n".join([f"Original: {orig}\nCorrected: {corr}" for orig, corr in corrections])
|
111 |
+
# return corrected_text, corrections_display
|
112 |
+
return text, "Unavailable"
|
113 |
|
114 |
def split_text(text: str) -> list:
|
115 |
sentences = sent_tokenize(text)
|