chibuzordev commited on
Commit
a4689b0
·
verified ·
1 Parent(s): d3ae497

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -25
app.py CHANGED
@@ -1,15 +1,5 @@
1
- # -*- coding: utf-8 -*-
2
- """FULL WORKFLOW
3
 
4
- Automatically generated by Colab.
5
-
6
- Original file is located at
7
- https://colab.research.google.com/drive/1I9KysFRYpSZfkL7FIxbodBYUgudQRejA
8
- """
9
-
10
-
11
-
12
- !pip install transformers faiss-cpu gradio sentence-transformers nlpaug scikit-learn
13
 
14
  # rag_module.py
15
 
@@ -22,18 +12,10 @@ from transformers import AutoTokenizer, T5ForConditionalGeneration
22
  import gradio as gr
23
 
24
  from rag_pipeline import RAGPipeline
25
-
26
  from adversarial_framework import *
27
 
28
- # Example Usage:
29
- rag = RAGPipeline()
30
- #print(rag.generate_answer("Who is the president of NACOS?"))
31
-
32
 
33
-
34
- adv_pipeline = AdversarialAttackPipeline(answer_generator=rag.generate_answer)
35
-
36
- # Gradio function
37
  def gradio_wrapper(query, method, k):
38
  stats_text, auc, fig, pert_q, pert_r, adv_r = adv_pipeline.evaluate_adversarial_robustness(
39
  query=query,
@@ -50,7 +32,6 @@ def gradio_wrapper(query, method, k):
50
  f"🔴 Directly Perturbed Response of Normal Output:\n\n{adv_r}"
51
  )
52
 
53
- # Build Interface
54
  gr.Interface(
55
  fn=gradio_wrapper,
56
  inputs=[
@@ -68,7 +49,4 @@ gr.Interface(
68
  ],
69
  title="Adversarial Testing on RAGiant System",
70
  description="Evaluate robustness against textual attacks and visualize degradation with ARI & PSC-AUC."
71
- ).launch()
72
-
73
-
74
-
 
 
 
1
 
2
+ # !pip install transformers faiss-cpu gradio sentence-transformers nlpaug scikit-learn
 
 
 
 
 
 
 
 
3
 
4
  # rag_module.py
5
 
 
12
  import gradio as gr
13
 
14
  from rag_pipeline import RAGPipeline
 
15
  from adversarial_framework import *
16
 
17
+ adv_pipeline = AdversarialAttackPipeline(answer_generator=RAGPipeline().generate_answer)
 
 
 
18
 
 
 
 
 
19
  def gradio_wrapper(query, method, k):
20
  stats_text, auc, fig, pert_q, pert_r, adv_r = adv_pipeline.evaluate_adversarial_robustness(
21
  query=query,
 
32
  f"🔴 Directly Perturbed Response of Normal Output:\n\n{adv_r}"
33
  )
34
 
 
35
  gr.Interface(
36
  fn=gradio_wrapper,
37
  inputs=[
 
49
  ],
50
  title="Adversarial Testing on RAGiant System",
51
  description="Evaluate robustness against textual attacks and visualize degradation with ARI & PSC-AUC."
52
+ ).launch()