Spaces:
Build error
Build error
Upload 10 Files
Browse files- Models/ArbiterModel/arbiter_xgboost_model.json +0 -0
- Pipeline/CorrectionLLMs.py +116 -0
- Pipeline/HallucinationPipeline.py +333 -0
- Pipeline/__pycache__/CorrectionLLMs.cpython-310.pyc +0 -0
- Pipeline/__pycache__/HallucinationPipeline.cpython-310.pyc +0 -0
- dist/assets/index-Bi8UhOSM.js +0 -0
- dist/assets/index-CEHSERXf.js +0 -0
- dist/assets/index-Ep_udfjn.css +1 -0
- dist/index.html +14 -0
- dist/vite.svg +1 -0
Models/ArbiterModel/arbiter_xgboost_model.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
Pipeline/CorrectionLLMs.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import google.generativeai as genai
|
| 2 |
+
from llama_cpp import Llama
|
| 3 |
+
from openai import OpenAI
|
| 4 |
+
|
| 5 |
+
class GeminiLLM:
|
| 6 |
+
def __init__(self,api_key):
|
| 7 |
+
genai.configure(api_key=api_key)
|
| 8 |
+
self.model=genai.GenerativeModel('gemini-1.5-flash')
|
| 9 |
+
|
| 10 |
+
def correct(self,article,summary):
|
| 11 |
+
prompt=f"""
|
| 12 |
+
Here is a summary with hallucinated parts marked using <xx> tags.
|
| 13 |
+
|
| 14 |
+
Please correct only the text inside the <xx> tags to make it factually accurate based on the original article. Leave the rest of the summary unchanged and remove the <xx> tags after correction.
|
| 15 |
+
|
| 16 |
+
Return the summary with hallucinated parts fixed and you can remove those <xx></xx> tags. Don't remove that entire sentence.
|
| 17 |
+
|
| 18 |
+
Original Article:
|
| 19 |
+
{article}
|
| 20 |
+
|
| 21 |
+
Summary:
|
| 22 |
+
{summary}
|
| 23 |
+
|
| 24 |
+
"""
|
| 25 |
+
output=self.model.generate_content(prompt)
|
| 26 |
+
return output.text.strip()
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class OfflineLLMs:
|
| 31 |
+
def __init__(self,model_name,max_tokens=50):
|
| 32 |
+
self.model=Llama(model_name,n_ctx=512,gpu_layers=0)
|
| 33 |
+
self.max_tokens=max_tokens
|
| 34 |
+
|
| 35 |
+
def correct(self,premise,summary):
|
| 36 |
+
# prompt=f"""
|
| 37 |
+
# Rewrite the following sentence to be factually correct based on the provided information. Output should be Only one single sentence that is the factually correct part of hallucinated sentence.
|
| 38 |
+
# Its a request give only the output don't rewrite the article and sentence to correct again.
|
| 39 |
+
|
| 40 |
+
# Information:
|
| 41 |
+
# {premise}
|
| 42 |
+
|
| 43 |
+
# Sentence to correct:
|
| 44 |
+
# {summary}
|
| 45 |
+
|
| 46 |
+
# Corrected sentence:
|
| 47 |
+
# """
|
| 48 |
+
prompt=f"""
|
| 49 |
+
Please rewrite the correct text only the text inside the <xx>..</xx> tags to make it factually accurate based on the original article. Leave the rest of the summary unchanged and remove the <xx> tags after correction.
|
| 50 |
+
Return the summary with hallucinated parts fixed. Don't remove that entire sentence. Keep the length of summary same as hallucinated summary.
|
| 51 |
+
Don't add any explanation of the cause.
|
| 52 |
+
|
| 53 |
+
Original Article:
|
| 54 |
+
{premise}
|
| 55 |
+
|
| 56 |
+
Hallucinated Summary:
|
| 57 |
+
{summary}
|
| 58 |
+
|
| 59 |
+
Corrected Summary:
|
| 60 |
+
|
| 61 |
+
"""
|
| 62 |
+
|
| 63 |
+
output=self.model(prompt,max_tokens=self.max_tokens)
|
| 64 |
+
return output["choices"][0]["text"]
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def create(self,article):
|
| 68 |
+
prompt=f"""
|
| 69 |
+
Create the summary of the following article given below. Stick to the article for summary. Only give the summary output.
|
| 70 |
+
Article:
|
| 71 |
+
{article}
|
| 72 |
+
|
| 73 |
+
Summary:
|
| 74 |
+
"""
|
| 75 |
+
|
| 76 |
+
output=self.model(prompt,max_tokens=self.max_tokens)
|
| 77 |
+
return output["choices"][0]["text"]
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class DeepseekAPI:
|
| 81 |
+
def __init__(self,api_key):
|
| 82 |
+
self.client = OpenAI(
|
| 83 |
+
base_url="https://openrouter.ai/api/v1",
|
| 84 |
+
api_key=api_key
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
def correct(self,premise,summary):
|
| 88 |
+
prompt=f"""
|
| 89 |
+
Here is a summary with hallucinated parts marked using <xx> tags.
|
| 90 |
+
|
| 91 |
+
Please correct only the text inside the <xx> tags to make it factually accurate based on the original article. Leave the rest of the summary unchanged and remove the <xx> tags after correction.
|
| 92 |
+
|
| 93 |
+
Return the summary with hallucinated parts fixed and you can remove those <xx></xx> tags. Don't remove that entire sentence.
|
| 94 |
+
Output only corrected summary, don't give any title.
|
| 95 |
+
|
| 96 |
+
Original Article:
|
| 97 |
+
{premise}
|
| 98 |
+
|
| 99 |
+
Hallucinated Summary:
|
| 100 |
+
{summary}
|
| 101 |
+
|
| 102 |
+
Corrected Summary:
|
| 103 |
+
|
| 104 |
+
"""
|
| 105 |
+
response = self.client.chat.completions.create(
|
| 106 |
+
model="deepseek/deepseek-chat-v3-0324:free",
|
| 107 |
+
# model="deepseek/deepseek-r1-0528:free" ,
|
| 108 |
+
messages=[
|
| 109 |
+
{"role": "system", "content": "You are a helpful assistant that corrects factual errors in summaries."},
|
| 110 |
+
{"role": "user", "content": f"{prompt}"}
|
| 111 |
+
|
| 112 |
+
]
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
return response.choices[0].message.content
|
Pipeline/HallucinationPipeline.py
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer,AutoModelForSequenceClassification
|
| 2 |
+
import torch.nn.functional as F
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pandas as pd
|
| 5 |
+
from nltk.tokenize import sent_tokenize
|
| 6 |
+
import torch
|
| 7 |
+
import requests
|
| 8 |
+
import torch
|
| 9 |
+
import xgboost as xgb
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class HallucinationPipeline:
|
| 13 |
+
def __init__(self,nli_model_name,device,llm_model=None):
|
| 14 |
+
# NLI Models Setting
|
| 15 |
+
self.tokenizer=AutoTokenizer.from_pretrained(nli_model_name)
|
| 16 |
+
self.nli_model=AutoModelForSequenceClassification.from_pretrained(nli_model_name).to(device)
|
| 17 |
+
self.labels=["CONTRADICTION","NEUTRAL","ENTAILMENT"]
|
| 18 |
+
self.device=device
|
| 19 |
+
self.arbiter=False
|
| 20 |
+
|
| 21 |
+
# Large NLI model
|
| 22 |
+
|
| 23 |
+
self.roberta_large=BatchNLI("roberta-large-mnli",device=device)
|
| 24 |
+
# self.roberta_large_ynie=BatchNLI("ynie/roberta-large-snli_mnli_fever_anli_R1_R2_R3-nli",device=device)
|
| 25 |
+
self.roberta_large_ynie=BatchNLI("MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli",device=device)
|
| 26 |
+
# self.roberta_large_ynie=BatchNLI("facebook/bart-large-mnli",device=device)
|
| 27 |
+
# self.roberta_large_ynie=BatchNLI("microsoft/deberta-v2-xxlarge-mnli",device=device)
|
| 28 |
+
|
| 29 |
+
# Correction models
|
| 30 |
+
self.llm=llm_model
|
| 31 |
+
|
| 32 |
+
# Arbiter Model
|
| 33 |
+
# self.arbiter=torch.load("./Arbiter-dataset/best_model.pt")
|
| 34 |
+
# self.arbiterModel=NeuralNetwork()
|
| 35 |
+
self.arbiter_model=xgb.XGBClassifier()
|
| 36 |
+
self.arbiter_model.load_model("./Models/ArbiterModel/arbiter_xgboost_model.json")
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
# Storing the results of the predicted models
|
| 40 |
+
self.detection_predicted_labels=[]
|
| 41 |
+
self.detection_predicted_labels_after_correction=[]
|
| 42 |
+
self.corrected_summary=[]
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
# -------------------------------------------------------------
|
| 47 |
+
# | FUNCTION 1 : Detecting the hallucinated parts using NLI. |
|
| 48 |
+
# -------------------------------------------------------------
|
| 49 |
+
def Detection(self,premise,hypothesis):
|
| 50 |
+
inputs=self.tokenizer(premise,hypothesis,return_tensors="pt",truncation=True,padding=True)
|
| 51 |
+
inputs = {key: val.to(self.device) for key, val in inputs.items()}
|
| 52 |
+
|
| 53 |
+
with torch.no_grad():
|
| 54 |
+
logit=self.nli_model(**inputs).logits
|
| 55 |
+
prob=F.softmax(logit,dim=-1)
|
| 56 |
+
prediction=torch.argmax(prob,dim=-1)
|
| 57 |
+
entailment_score=prob[:,2]
|
| 58 |
+
contra_score=prob[:,0]
|
| 59 |
+
# print("Logits : ",logit)
|
| 60 |
+
# print("Probability : \n",prob)
|
| 61 |
+
# print("Label : ",[self.labels[i] for i in prediction])
|
| 62 |
+
# print("\n")
|
| 63 |
+
# return prediction.tolist()
|
| 64 |
+
return prediction.cpu().tolist(),entailment_score.cpu().tolist(), contra_score.cpu().tolist()
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
# ----------------------------------------------------------------------
|
| 69 |
+
# | FUNCTION 2 : This involves using the LLM to correct the summaries. |
|
| 70 |
+
# ----------------------------------------------------------------------
|
| 71 |
+
def Correction(self,premise,prompt):
|
| 72 |
+
correction=self.llm.correct(premise,prompt)
|
| 73 |
+
return correction
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
# ---------------------------------------------------------------------------
|
| 77 |
+
# | FUNCTION 3 : This involves adding the Tag to the summary <xx>...</xx> |
|
| 78 |
+
# ---------------------------------------------------------------------------
|
| 79 |
+
def addTags(self,sentences_list,sent_predicted_labels,size):
|
| 80 |
+
for i in range(size):
|
| 81 |
+
if sent_predicted_labels[i]==0:
|
| 82 |
+
sentences_list[i]=f"<xx> {sentences_list[i]} </xx>"
|
| 83 |
+
|
| 84 |
+
prompt_ready_summary=" ".join(sentences_list)
|
| 85 |
+
return prompt_ready_summary
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
# ------------------------------------------------------------------------------------------------------
|
| 89 |
+
# | FUNCTION 4 : This function helps to chunk the article, because max token for base nli model is 256.|
|
| 90 |
+
# ------------------------------------------------------------------------------------------------------
|
| 91 |
+
def chunk_article(self,article,chunk_size=240,stride=128):
|
| 92 |
+
input_ids=self.tokenizer.encode(article)
|
| 93 |
+
chunks=[]
|
| 94 |
+
for i in range(0,len(input_ids),stride):
|
| 95 |
+
new_token=input_ids[i:i+chunk_size]
|
| 96 |
+
decoded_article=self.tokenizer.decode(new_token)
|
| 97 |
+
chunks.append(decoded_article)
|
| 98 |
+
return chunks
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
# -------------------------------------------------------------------------------------------
|
| 103 |
+
# | FUNCTION 5 : Decider neural network which combines the scores and give the final result |
|
| 104 |
+
# -------------------------------------------------------------------------------------------
|
| 105 |
+
# def arbiterNeuralNetwork(self,data):
|
| 106 |
+
# data=torch.Tensor(data).to(self.device)
|
| 107 |
+
# self.arbiterModel=self.arbiterModel.to(self.device)
|
| 108 |
+
# self.arbiterModel.load_state_dict(self.arbiter["model_state_dict"])
|
| 109 |
+
# results=self.arbiterModel(data)
|
| 110 |
+
# return (torch.argmax(results,dim=-1).tolist(),torch.mean(results[::,0]).item(),torch.mean(results[::,2]).item())
|
| 111 |
+
def arbiterModel(self,data):
|
| 112 |
+
result=self.arbiter_model.predict_proba(data)
|
| 113 |
+
sent_pred_label=np.argmax(result,axis=1)
|
| 114 |
+
sent_pred_label=np.where(sent_pred_label==1,2,0)
|
| 115 |
+
return sent_pred_label,result[::,0],result[::,1]
|
| 116 |
+
|
| 117 |
+
# --------------------------------------------------
|
| 118 |
+
# | FUNCTION 6 : Integrated all the above methods. |
|
| 119 |
+
# --------------------------------------------------
|
| 120 |
+
# Input : DataFrame(Premise, Hypothesis, labels[Optional])
|
| 121 |
+
def process(self,df,correct_the_summary=False,arbiter=False):
|
| 122 |
+
|
| 123 |
+
# Empty previous outputs.
|
| 124 |
+
self.arbiter=arbiter
|
| 125 |
+
self.detection_predicted_labels=[]
|
| 126 |
+
self.detection_predicted_labels_after_correction=[]
|
| 127 |
+
self.corrected_summary=[]
|
| 128 |
+
sentence_predicted_labels=[]
|
| 129 |
+
summary_factual_score=[]
|
| 130 |
+
summary_contradiction_score=[]
|
| 131 |
+
all_features=[]
|
| 132 |
+
count=1
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
# Starting the Pipeline of Detection and Correction
|
| 136 |
+
for premise,hypo in np.array(df):
|
| 137 |
+
|
| 138 |
+
# | Step 1 |: Splitting and detecting each sentence.
|
| 139 |
+
splitting_sentences= sent_tokenize(hypo)
|
| 140 |
+
size_of_sentence=len(splitting_sentences)
|
| 141 |
+
chunks=self.chunk_article(premise,chunk_size=384,stride=256)
|
| 142 |
+
chunk_sent_pred=[]
|
| 143 |
+
chunk_sent_score=[]
|
| 144 |
+
chunk_contra_score=[]
|
| 145 |
+
|
| 146 |
+
chunk_roberta_large_entail=[]
|
| 147 |
+
chunk_roberta_large_neutral=[]
|
| 148 |
+
chunk_roberta_large_contra=[]
|
| 149 |
+
|
| 150 |
+
chunk_roberta_large_ynie_contra=[]
|
| 151 |
+
chunk_roberta_large_ynie_neutral=[]
|
| 152 |
+
chunk_roberta_large_ynie_entail=[]
|
| 153 |
+
|
| 154 |
+
for article_part in chunks:
|
| 155 |
+
premises=[article_part]*size_of_sentence
|
| 156 |
+
|
| 157 |
+
# NLI Model output.
|
| 158 |
+
sent_predicted_labels,sent_predicted_scores, sent_contra_scores= self.Detection(premises, splitting_sentences)
|
| 159 |
+
|
| 160 |
+
chunk_sent_pred.append(sent_predicted_labels)
|
| 161 |
+
chunk_sent_score.append(sent_predicted_scores)
|
| 162 |
+
chunk_contra_score.append(sent_contra_scores)
|
| 163 |
+
|
| 164 |
+
# Other metrics score
|
| 165 |
+
if arbiter:
|
| 166 |
+
# rouge,entity_overlap,sbert,tfidf=self.metrics.calculate_all(premises,splitting_sentences)
|
| 167 |
+
contra,neutral,entail=self.roberta_large.predict(premises,splitting_sentences)
|
| 168 |
+
chunk_roberta_large_contra.append(contra)
|
| 169 |
+
chunk_roberta_large_neutral.append(neutral)
|
| 170 |
+
chunk_roberta_large_entail.append(entail)
|
| 171 |
+
|
| 172 |
+
entail,neutral,contra=self.roberta_large_ynie.predict(premises,splitting_sentences)
|
| 173 |
+
chunk_roberta_large_ynie_contra.append(contra)
|
| 174 |
+
chunk_roberta_large_ynie_neutral.append(neutral)
|
| 175 |
+
chunk_roberta_large_ynie_entail.append(entail)
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
# Stacking scores of all chunks. [Columns: Chunks, Row:summary_sentences]
|
| 181 |
+
chunk_sent_pred=np.stack(chunk_sent_pred,axis=1)
|
| 182 |
+
chunk_sent_score=np.stack(chunk_sent_score,axis=1)
|
| 183 |
+
chunk_contra_score=np.stack(chunk_contra_score,axis=1)
|
| 184 |
+
|
| 185 |
+
sent_predicted_labels=np.max(chunk_sent_pred,axis=1)
|
| 186 |
+
factual_score=np.max(chunk_sent_score,axis=1)
|
| 187 |
+
contra_score=np.min(chunk_contra_score,axis=1)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
# Taking the score which gives more information.
|
| 192 |
+
if arbiter:
|
| 193 |
+
chunk_roberta_large_entail = np.stack(chunk_roberta_large_entail, axis=1)
|
| 194 |
+
chunk_roberta_large_neutral = np.stack(chunk_roberta_large_neutral, axis=1)
|
| 195 |
+
chunk_roberta_large_contra = np.stack(chunk_roberta_large_contra, axis=1)
|
| 196 |
+
|
| 197 |
+
# DeBERTa
|
| 198 |
+
chunk_roberta_large_ynie_entail = np.stack(chunk_roberta_large_ynie_entail, axis=1)
|
| 199 |
+
chunk_roberta_large_ynie_neutral = np.stack(chunk_roberta_large_ynie_neutral, axis=1)
|
| 200 |
+
chunk_roberta_large_ynie_contra = np.stack(chunk_roberta_large_ynie_contra, axis=1)
|
| 201 |
+
|
| 202 |
+
roberta_large_contra=np.min(chunk_roberta_large_contra,axis=1)
|
| 203 |
+
roberta_large_neutral=np.median(chunk_roberta_large_neutral,axis=1)
|
| 204 |
+
roberta_large_entail=np.max(chunk_roberta_large_entail,axis=1)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
roberta_large_ynie_contra=np.min(chunk_roberta_large_ynie_contra,axis=1)
|
| 208 |
+
roberta_large_ynie_neutral=np.median(chunk_roberta_large_ynie_neutral,axis=1)
|
| 209 |
+
roberta_large_ynie_entail=np.max(chunk_roberta_large_ynie_entail,axis=1)
|
| 210 |
+
|
| 211 |
+
# COMBINING FEATURES
|
| 212 |
+
features=np.stack([factual_score,contra_score,
|
| 213 |
+
roberta_large_contra,roberta_large_neutral,roberta_large_entail,
|
| 214 |
+
roberta_large_ynie_contra,roberta_large_ynie_neutral,roberta_large_ynie_entail
|
| 215 |
+
],
|
| 216 |
+
|
| 217 |
+
axis=1)
|
| 218 |
+
# all_features.append(features)
|
| 219 |
+
|
| 220 |
+
# Arbiter Neural Network Output
|
| 221 |
+
sent_predicted_labels,contra_score,factual_score=self.arbiterModel(features)
|
| 222 |
+
# sent_predicted_labels,contra_score,factual_score=self.arbiterNeuralNetwork(features)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
# summary_factual_score.append(np.mean(factual_score))
|
| 227 |
+
# summary_contradiction_score.append(np.mean(contra_score))
|
| 228 |
+
summary_factual_score.append(np.mean(factual_score))
|
| 229 |
+
summary_contradiction_score.append(np.mean(contra_score))
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
# Label whether summary is factually correct or not
|
| 233 |
+
# SummaryPrediction=2 if factual_score>contra_score else 0
|
| 234 |
+
SummaryPrediction=0 if 0 in sent_predicted_labels else 2
|
| 235 |
+
sentence_predicted_labels.append(sent_predicted_labels)
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
self.detection_predicted_labels.append(int(SummaryPrediction))
|
| 240 |
+
|
| 241 |
+
# | Step 2 |: Correction of the Summary using LLMs, if parameter correct_the_summary=True.
|
| 242 |
+
if correct_the_summary:
|
| 243 |
+
if SummaryPrediction<=1:
|
| 244 |
+
prompt=self.addTags(splitting_sentences,sent_predicted_labels,size_of_sentence)
|
| 245 |
+
corrected_result=self.Correction(premise,prompt)
|
| 246 |
+
self.corrected_summary.append(corrected_result)
|
| 247 |
+
else:
|
| 248 |
+
self.corrected_summary.append(None)
|
| 249 |
+
|
| 250 |
+
print("Detected : ",count)
|
| 251 |
+
count+=1
|
| 252 |
+
|
| 253 |
+
output={
|
| 254 |
+
"predictions":self.detection_predicted_labels,
|
| 255 |
+
"corrected_summary":self.corrected_summary,
|
| 256 |
+
"sent_predicted":sentence_predicted_labels,
|
| 257 |
+
"factual_score":summary_factual_score,
|
| 258 |
+
"contradiction_score":summary_contradiction_score,
|
| 259 |
+
"features":all_features
|
| 260 |
+
}
|
| 261 |
+
return output
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
# ---------------------------------------------------------
|
| 267 |
+
# | Optional FUNCTION : Integrated all the above methods. |
|
| 268 |
+
# ---------------------------------------------------------
|
| 269 |
+
def fetchData(self,url,depth=[],articleFieldName=None,summaryFieldName=None,limit=None):
|
| 270 |
+
try:
|
| 271 |
+
data=requests.get(url)
|
| 272 |
+
data=data.json()
|
| 273 |
+
article=[]
|
| 274 |
+
summary=[]
|
| 275 |
+
count=limit
|
| 276 |
+
|
| 277 |
+
for field in depth:
|
| 278 |
+
data=data[field]
|
| 279 |
+
|
| 280 |
+
if type(data)!=list:
|
| 281 |
+
data=[data]
|
| 282 |
+
|
| 283 |
+
for index,i in enumerate(data):
|
| 284 |
+
print("Index : ",index)
|
| 285 |
+
|
| 286 |
+
if i.get(articleFieldName):
|
| 287 |
+
article.append(str(i[articleFieldName]))
|
| 288 |
+
if summaryFieldName and i[summaryFieldName]:
|
| 289 |
+
summary.append(str(i[summaryFieldName]))
|
| 290 |
+
else:
|
| 291 |
+
#Create Summary and append
|
| 292 |
+
result=self.llm.create(str(i[articleFieldName]))
|
| 293 |
+
summary.append(result)
|
| 294 |
+
if count:
|
| 295 |
+
count-=1
|
| 296 |
+
if count<1:
|
| 297 |
+
break
|
| 298 |
+
|
| 299 |
+
# Detection and getting Factual Score.
|
| 300 |
+
data=np.column_stack([article,summary])
|
| 301 |
+
result=self.process(data,correct_the_summary=False)
|
| 302 |
+
data=np.column_stack([data,result["predictions"],result["factual_score"]])
|
| 303 |
+
|
| 304 |
+
df=pd.DataFrame(data,columns=["Article","Summary","Prediction","Factuality"])
|
| 305 |
+
return df
|
| 306 |
+
|
| 307 |
+
except Exception as e:
|
| 308 |
+
print("Failed to fetch data:", e)
|
| 309 |
+
return None
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
class BatchNLI:
|
| 314 |
+
def __init__(self, model_name, device="cpu"):
|
| 315 |
+
self.device = device
|
| 316 |
+
self.tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 317 |
+
self.model = AutoModelForSequenceClassification.from_pretrained(model_name,num_labels=3,use_safetensors=True)
|
| 318 |
+
self.model.to(self.device)
|
| 319 |
+
self.model.eval()
|
| 320 |
+
|
| 321 |
+
def predict(self, premises, hypotheses):
|
| 322 |
+
# Tokenize entire batch at once
|
| 323 |
+
inputs = self.tokenizer(premises, hypotheses, return_tensors="pt", padding=True, truncation=True)
|
| 324 |
+
inputs = {k: v.to(self.device) for k, v in inputs.items()}
|
| 325 |
+
|
| 326 |
+
# Forward pass
|
| 327 |
+
with torch.no_grad():
|
| 328 |
+
logits = self.model(**inputs).logits
|
| 329 |
+
probs = F.softmax(logits, dim=-1)
|
| 330 |
+
contra=probs[::,0].cpu().tolist()
|
| 331 |
+
neutral=probs[::,1].cpu().tolist()
|
| 332 |
+
entail=probs[::,2].cpu().tolist()
|
| 333 |
+
return contra,neutral,entail
|
Pipeline/__pycache__/CorrectionLLMs.cpython-310.pyc
ADDED
|
Binary file (4.35 kB). View file
|
|
|
Pipeline/__pycache__/HallucinationPipeline.cpython-310.pyc
ADDED
|
Binary file (7.4 kB). View file
|
|
|
dist/assets/index-Bi8UhOSM.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/index-CEHSERXf.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/index-Ep_udfjn.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
:root{font-family:system-ui,Avenir,Helvetica,Arial,sans-serif;line-height:1.5;font-weight:400;color-scheme:light dark;color:#ffffffde;background-color:#242424;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme: light){:root{color:#213547;background-color:#fff}}.main-parent{display:flex;flex-direction:column;align-items:center;position:absolute;width:99.9%;height:99%;left:0;top:0;overflow:hidden}.stacking-enabled{box-shadow:0 0 20px 1.5px red inset;transition:.75s}.stacking-disabled{box-shadow:0 0 #f000 inset;transition:.75s}.highlight-parent{position:relative;padding:0 .1cm;transform-origin:left;z-index:3}.highlighter-div{position:absolute;top:0;left:0;width:100%;height:100%;transform-origin:left;animation-name:highlighter;animation-delay:.5s;animation-duration:.5s;animation-iteration-count:1;animation-fill-mode:forwards;z-index:2}@keyframes highlighter{0%{transform:scaleX(0);background-color:#cec66c5b}to{transform:scaleX(1);background-color:#cec66c5b}}.animated-highlight{background:linear-gradient(to right,rgba(109,109,21,.7) 100%,transparent 0%);background-size:0% 100%;background-repeat:no-repeat;animation:fillHighlight 1s forwards;padding:.1em .2em;display:inline;cursor:pointer}.animated-highlight:hover{background-color:#ce4100}@keyframes fillHighlight{to{background-size:100% 100%}}.loading-main{display:flex;justify-content:center;align-items:center;flex-direction:column;border-radius:.1cm;width:4cm;height:4cm;position:relative;scale:1;-webkit-user-select:none;user-select:none}.loading-animation{width:120px;height:120px;position:relative}.box{position:absolute;width:60px;height:60px;top:0;left:0}.box2{position:absolute;width:60px;height:60px;bottom:0;right:0;scale:.5}.bx-color-red{background-color:#ca3a3a}.bx-color-2-red{background-color:#8f2929}.bx-color{background-color:#2d4566}.bx-color-2{background-color:#466a9d}:root{--toastify-color-light: #fff;--toastify-color-dark: #121212;--toastify-color-info: #3498db;--toastify-color-success: #07bc0c;--toastify-color-warning: #f1c40f;--toastify-color-error: hsl(6, 78%, 57%);--toastify-color-transparent: rgba(255, 255, 255, .7);--toastify-icon-color-info: var(--toastify-color-info);--toastify-icon-color-success: var(--toastify-color-success);--toastify-icon-color-warning: var(--toastify-color-warning);--toastify-icon-color-error: var(--toastify-color-error);--toastify-container-width: fit-content;--toastify-toast-width: 320px;--toastify-toast-offset: 16px;--toastify-toast-top: max(var(--toastify-toast-offset), env(safe-area-inset-top));--toastify-toast-right: max(var(--toastify-toast-offset), env(safe-area-inset-right));--toastify-toast-left: max(var(--toastify-toast-offset), env(safe-area-inset-left));--toastify-toast-bottom: max(var(--toastify-toast-offset), env(safe-area-inset-bottom));--toastify-toast-background: #fff;--toastify-toast-padding: 14px;--toastify-toast-min-height: 64px;--toastify-toast-max-height: 800px;--toastify-toast-bd-radius: 6px;--toastify-toast-shadow: 0px 4px 12px rgba(0, 0, 0, .1);--toastify-font-family: sans-serif;--toastify-z-index: 9999;--toastify-text-color-light: #757575;--toastify-text-color-dark: #fff;--toastify-text-color-info: #fff;--toastify-text-color-success: #fff;--toastify-text-color-warning: #fff;--toastify-text-color-error: #fff;--toastify-spinner-color: #616161;--toastify-spinner-color-empty-area: #e0e0e0;--toastify-color-progress-light: linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55);--toastify-color-progress-dark: #bb86fc;--toastify-color-progress-info: var(--toastify-color-info);--toastify-color-progress-success: var(--toastify-color-success);--toastify-color-progress-warning: var(--toastify-color-warning);--toastify-color-progress-error: var(--toastify-color-error);--toastify-color-progress-bgo: .2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translate3d(0,0,var(--toastify-z-index));position:fixed;width:var(--toastify-container-width);box-sizing:border-box;color:#fff;display:flex;flex-direction:column}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translate(-50%);align-items:center}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right);align-items:end}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translate(-50%);align-items:center}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right);align-items:end}.Toastify__toast{--y: 0;position:relative;touch-action:none;width:var(--toastify-toast-width);min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:var(--toastify-toast-padding);border-radius:var(--toastify-toast-bd-radius);box-shadow:var(--toastify-toast-shadow);max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);z-index:0;display:flex;flex:1 auto;align-items:center;word-break:break-word}@media only screen and (max-width: 480px){.Toastify__toast-container{width:100vw;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-left,.Toastify__toast-container--top-center,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translate(0)}.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translate(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:initial}.Toastify__toast{--toastify-toast-width: 100%;margin-bottom:0;border-radius:0}}.Toastify__toast-container[data-stacked=true]{width:var(--toastify-toast-width)}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body,.Toastify__toast--stacked[data-collapsed] .Toastify__close-button{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-icon{margin-inline-end:10px;width:22px;flex-shrink:0;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--light,.Toastify__toast-theme--colored.Toastify__toast--default{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;position:absolute;top:6px;right:6px;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;z-index:1}.Toastify__toast--rtl .Toastify__close-button{left:6px;right:unset}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:hover,.Toastify__close-button:focus{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:1;opacity:.7;transform-origin:left}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:initial;transform-origin:right;border-bottom-left-radius:initial}.Toastify__progress-bar--wrp{position:absolute;overflow:hidden;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius);border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--top-left,.Toastify__bounce-enter--bottom-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--top-right,.Toastify__bounce-enter--bottom-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--top-left,.Toastify__bounce-exit--bottom-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--top-right,.Toastify__bounce-exit--bottom-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--top-left,.Toastify__slide-enter--bottom-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--top-right,.Toastify__slide-enter--bottom-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--top-left,.Toastify__slide-exit--bottom-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-right,.Toastify__slide-exit--bottom-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.result-main{display:flex;justify-content:center;width:99%;height:99%;margin-top:.25cm;max-width:50cm;background-color:#1e1e1e}.result-div{width:99%;display:flex;flex-direction:row;align-items:center;padding:0 .5cm}.result-left-part{border:.2mm solid rgba(255,255,255,.251);box-shadow:0 0 2px #f5f5f5;background-color:#2a2a2a;height:90%;width:70%;overflow:hidden}.result-right-part{border:.2mm solid rgba(255,255,255,.251);box-shadow:0 0 2px #f5f5f5;height:90%;width:30%;margin-left:.3cm}.result-loading{display:flex;justify-content:center;align-items:center;width:100%;height:100%}.result-display{padding:.5cm;overflow-y:auto;height:90%}.left-part-heading,.right-part-heading{border:.2mm solid rgba(195,195,195,.46);padding:.5cm;background-color:#313b4d;-webkit-user-select:none;user-select:none}.result-report-score-div{display:flex;align-items:center;border:.2mm solid rgba(156,156,156,.437);background-color:#232324;height:3cm;overflow:hidden;padding:.2cm 0;margin:.1cm}.score-circle{display:flex;justify-content:center;align-items:center;flex-direction:column;border:1mm solid rgb(191,191,191);background-color:#b61717;border-radius:2cm;width:2.5cm;height:2.5cm;font-size:.55cm;margin-left:.3cm}.result-sentences-report{display:flex;flex-direction:column;border:.2mm solid rgb(82,82,82);background-color:#252b36;height:fit-content;width:65%;margin-left:.7cm}.result-sentences-report td{padding:.05cm;font-weight:400;font-size:.38cm}.correction-div-copy-prompt{display:flex;flex-direction:row;align-items:center;padding:.15cm;border:.2mm solid rgb(175,175,175);background-color:#383838;overflow:hidden;font-weight:250;line-height:1;font-size:.35cm;-webkit-user-select:none;user-select:none;margin:.1cm}.copy-prompt-button{display:flex;align-items:center;border:.2mm solid rgba(57,57,57,.274);background-color:#919191;box-shadow:0 0 45px #000 inset;font-size:.6cm;padding:.2cm;margin-left:.3cm;cursor:pointer}.copy-prompt-button:hover{background-color:#c9c9c9;box-shadow:0 0 45px #000 inset;border:.2mm solid rgba(105,105,105,.521)}.correction-div-through-models{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:.15cm;border:.2mm solid rgb(175,175,175);background-color:#374c61;overflow:hidden;font-weight:350;line-height:1;font-size:.35cm;-webkit-user-select:none;user-select:none;margin:.1cm}.correction-div-through-models-settings{display:flex;align-items:center;width:100%;padding:.1cm;margin-top:.1cm}.correction-div-through-models-settings button{display:flex;align-items:center;justify-content:center;font-size:.44cm;background-color:#272e39;color:#f5f5f5;border:.1mm solid rgba(255,255,255,.515);margin-left:.5cm;width:100%;cursor:pointer}.correction-div-through-models-settings button:hover{background-color:#f5f5f5;color:#000}.correction-div-through-models-settings select{background-color:#f5f5f5;color:#000;padding:.1cm;width:100%}.correction-result-heading{border:.2mm solid whitesmoke;margin:.1cm;font-weight:700;padding:.1cm .2cm;background-color:#2a3e53}.navbar-parent{display:flex;align-items:center;position:relative;width:99.9%;height:1.2cm;padding:.2cm 0;background-color:#212833;background-color:#252d3c;border-bottom:.4mm ridge rgb(163,163,163)}.stacking-enabled-navbar{box-shadow:0 0 20px 1.5px red inset;transition:.75s}.stacking-disabled-navbar{box-shadow:0 0 #f000 inset;transition:.75s}.home-parent{width:99.5%;max-width:50cm;height:100%;display:flex;flex-direction:column;align-items:center;background-color:#151515}.home-model-settings{display:flex;border:.2mm solid rgba(195,195,195,.27);background-color:#1f1e1e;margin-top:.3cm;width:95%;height:1cm;align-items:center;z-index:1}.stacking-setting{display:flex;flex-direction:row;align-items:center;border:.2mm solid rgb(97,113,135);padding:.1cm .2cm;background-color:#214c71;z-index:0;-webkit-user-select:none;user-select:none;border-radius:.05cm;transition:.75s}.home-inputs-parent{display:flex;flex-direction:row;justify-content:center;align-items:center;border:.1mm solid rgba(245,245,245,.175);border-radius:.1cm;height:fit-content;width:95%;margin-top:.4cm;background-color:#1f1e1e;transition:.75s}.home-parts{display:flex;justify-content:center;width:45%;height:98%}.home-buttons{display:flex;justify-content:center;width:95%;margin-top:.2cm}.detect-button{background-color:#1567ba;border:.1mm solid rgb(131,131,131);width:5cm;font-size:.45cm;border-radius:.05cm;cursor:pointer}.detect-button:hover{background-color:#1778da}.stacking-enabled-btn{box-shadow:0 0 25px 1px red inset;transition:.5s}.stacking-enabled-btn:hover{box-shadow:0 0 25px 2px #ff3c3c inset}.stacking-disabled-btn{transition:1s}@media only screen and (max-device-width:950px){.home-inputs-parent{display:flex;flex-direction:column;height:fit-content;justify-content:flex-start;align-items:center;padding-bottom:.5cm}.home-parts{width:100%}.home-parent{overflow-y:auto}.home-buttons{position:absolute;bottom:0}.home-buttons button{margin-top:.1cm;width:90%;position:sticky}}.dark-textarea-wrapper{width:100%;max-width:800px;margin:2rem auto;display:flex;flex-direction:column;padding:0 1rem}.dark-textarea-label{color:#e0e0e0;font-weight:600;margin-bottom:.5rem;border-radius:.1cm;background-color:#313b4d;font-size:.55cm;font-family:Lucida Sans,Lucida Sans Regular,Lucida Grande,Lucida Sans Unicode,Geneva,Verdana,sans-serif;padding:0 .2cm;-webkit-user-select:none;user-select:none}.dark-textarea{background-color:#2d2d2d;color:#f1f1f1;border:1px solid #333;border-radius:8px;padding:1rem;font-size:1rem;resize:none;outline:none;transition:border .2s ease;font-family:Arial,Helvetica,sans-serif}.dark-textarea::placeholder{color:#888}.switch{position:relative;display:inline-block;width:50px;height:24px}.switch input{opacity:0;width:0;height:0}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.4s;transition:.4s}.slider:before{position:absolute;content:"";height:20px;width:20px;left:3px;bottom:3px;background-color:#fff;-webkit-transition:.4s;transition:.4s}input:checked+.slider{background-color:red}input:focus+.slider{box-shadow:0 0 1px red}input:checked+.slider:before{-webkit-transform:translateX(26px);-ms-transform:translateX(26px);transform:translate(26px)}.slider.round{border-radius:34px}.slider.round:before{border-radius:50%}
|
dist/index.html
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
+
<title>Vite + React</title>
|
| 8 |
+
<script type="module" crossorigin src="/assets/index-CEHSERXf.js"></script>
|
| 9 |
+
<link rel="stylesheet" crossorigin href="/assets/index-Ep_udfjn.css">
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<div id="root"></div>
|
| 13 |
+
</body>
|
| 14 |
+
</html>
|
dist/vite.svg
ADDED
|
|