indoxJudge 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. indoxJudge/__init__.py +0 -0
  2. indoxJudge/__pycache__/__init__.cpython-312.pyc +0 -0
  3. indoxJudge/graph/__init__.py +2 -0
  4. indoxJudge/graph/__pycache__/__init__.cpython-312.pyc +0 -0
  5. indoxJudge/graph/__pycache__/visualization.cpython-312.pyc +0 -0
  6. indoxJudge/graph/assets/style.css +188 -0
  7. indoxJudge/graph/visualization.py +466 -0
  8. indoxJudge/metrics/__init__.py +20 -0
  9. indoxJudge/metrics/__pycache__/__init__.cpython-312.pyc +0 -0
  10. indoxJudge/metrics/answer_relevancy/__init__.py +1 -0
  11. indoxJudge/metrics/answer_relevancy/__pycache__/__init__.cpython-312.pyc +0 -0
  12. indoxJudge/metrics/answer_relevancy/__pycache__/answerRelevancy.cpython-312.pyc +0 -0
  13. indoxJudge/metrics/answer_relevancy/__pycache__/template.cpython-312.pyc +0 -0
  14. indoxJudge/metrics/answer_relevancy/answerRelevancy.py +155 -0
  15. indoxJudge/metrics/answer_relevancy/template.py +96 -0
  16. indoxJudge/metrics/bertscore/__init__.py +1 -0
  17. indoxJudge/metrics/bertscore/__pycache__/__init__.cpython-312.pyc +0 -0
  18. indoxJudge/metrics/bertscore/__pycache__/bertscore.cpython-312.pyc +0 -0
  19. indoxJudge/metrics/bertscore/bertscore.py +135 -0
  20. indoxJudge/metrics/bias/__init__.py +1 -0
  21. indoxJudge/metrics/bias/__pycache__/__init__.cpython-312.pyc +0 -0
  22. indoxJudge/metrics/bias/__pycache__/bias.cpython-312.pyc +0 -0
  23. indoxJudge/metrics/bias/__pycache__/template.cpython-312.pyc +0 -0
  24. indoxJudge/metrics/bias/bias.py +115 -0
  25. indoxJudge/metrics/bias/template.py +99 -0
  26. indoxJudge/metrics/bleu/__init__.py +1 -0
  27. indoxJudge/metrics/bleu/__pycache__/__init__.cpython-312.pyc +0 -0
  28. indoxJudge/metrics/bleu/__pycache__/bleu.cpython-312.pyc +0 -0
  29. indoxJudge/metrics/bleu/bleu.py +190 -0
  30. indoxJudge/metrics/bleu/t.ipynb +0 -0
  31. indoxJudge/metrics/contextual_relevancy/__init__.py +1 -0
  32. indoxJudge/metrics/contextual_relevancy/__pycache__/__init__.cpython-312.pyc +0 -0
  33. indoxJudge/metrics/contextual_relevancy/__pycache__/contextualRelevancy.cpython-312.pyc +0 -0
  34. indoxJudge/metrics/contextual_relevancy/__pycache__/template.cpython-312.pyc +0 -0
  35. indoxJudge/metrics/contextual_relevancy/contextualRelevancy.py +90 -0
  36. indoxJudge/metrics/contextual_relevancy/template.py +67 -0
  37. indoxJudge/metrics/fairness/__init__.py +1 -0
  38. indoxJudge/metrics/fairness/__pycache__/__init__.cpython-312.pyc +0 -0
  39. indoxJudge/metrics/fairness/__pycache__/fairness.cpython-312.pyc +0 -0
  40. indoxJudge/metrics/fairness/__pycache__/template.cpython-312.pyc +0 -0
  41. indoxJudge/metrics/fairness/fairness.py +76 -0
  42. indoxJudge/metrics/fairness/template.py +50 -0
  43. indoxJudge/metrics/faithfulness/__init__.py +1 -0
  44. indoxJudge/metrics/faithfulness/__pycache__/__init__.cpython-312.pyc +0 -0
  45. indoxJudge/metrics/faithfulness/__pycache__/faithfulness.cpython-312.pyc +0 -0
  46. indoxJudge/metrics/faithfulness/__pycache__/template.cpython-312.pyc +0 -0
  47. indoxJudge/metrics/faithfulness/faithfulness.py +141 -0
  48. indoxJudge/metrics/faithfulness/template.py +145 -0
  49. indoxJudge/metrics/g_eval/__init__.py +1 -0
  50. indoxJudge/metrics/g_eval/__pycache__/__init__.cpython-312.pyc +0 -0
  51. indoxJudge/metrics/g_eval/__pycache__/geval.cpython-312.pyc +0 -0
  52. indoxJudge/metrics/g_eval/__pycache__/template.cpython-312.pyc +0 -0
  53. indoxJudge/metrics/g_eval/geval.py +110 -0
  54. indoxJudge/metrics/g_eval/template.py +48 -0
  55. indoxJudge/metrics/gruen/__init__.py +1 -0
  56. indoxJudge/metrics/gruen/__pycache__/__init__.cpython-312.pyc +0 -0
  57. indoxJudge/metrics/gruen/__pycache__/gruen.cpython-312.pyc +0 -0
  58. indoxJudge/metrics/gruen/gruen.py +415 -0
  59. indoxJudge/metrics/hallucination/__init__.py +1 -0
  60. indoxJudge/metrics/hallucination/__pycache__/__init__.cpython-312.pyc +0 -0
  61. indoxJudge/metrics/hallucination/__pycache__/hallucination.cpython-312.pyc +0 -0
  62. indoxJudge/metrics/hallucination/__pycache__/template.cpython-312.pyc +0 -0
  63. indoxJudge/metrics/hallucination/hallucination.py +83 -0
  64. indoxJudge/metrics/hallucination/template.py +62 -0
  65. indoxJudge/metrics/harmfulness/__init__.py +1 -0
  66. indoxJudge/metrics/harmfulness/__pycache__/__init__.cpython-312.pyc +0 -0
  67. indoxJudge/metrics/harmfulness/__pycache__/harmfulness.cpython-312.pyc +0 -0
  68. indoxJudge/metrics/harmfulness/__pycache__/template.cpython-312.pyc +0 -0
  69. indoxJudge/metrics/harmfulness/harmfulness.py +74 -0
  70. indoxJudge/metrics/harmfulness/template.py +56 -0
  71. indoxJudge/metrics/knowledge_retention/KnowledgeRetention.py +173 -0
  72. indoxJudge/metrics/knowledge_retention/__init__.py +1 -0
  73. indoxJudge/metrics/knowledge_retention/__pycache__/KnowledgeRetention.cpython-312.pyc +0 -0
  74. indoxJudge/metrics/knowledge_retention/__pycache__/__init__.cpython-312.pyc +0 -0
  75. indoxJudge/metrics/knowledge_retention/__pycache__/template.cpython-312.pyc +0 -0
  76. indoxJudge/metrics/knowledge_retention/template.py +173 -0
  77. indoxJudge/metrics/machine_ethics/__init__.py +1 -0
  78. indoxJudge/metrics/machine_ethics/__pycache__/__init__.cpython-312.pyc +0 -0
  79. indoxJudge/metrics/machine_ethics/__pycache__/machineEthics.cpython-312.pyc +0 -0
  80. indoxJudge/metrics/machine_ethics/__pycache__/template.cpython-312.pyc +0 -0
  81. indoxJudge/metrics/machine_ethics/machineEthics.py +70 -0
  82. indoxJudge/metrics/machine_ethics/template.py +55 -0
  83. indoxJudge/metrics/meteor/__init__.py +1 -0
  84. indoxJudge/metrics/meteor/__pycache__/__init__.cpython-312.pyc +0 -0
  85. indoxJudge/metrics/meteor/__pycache__/meteor.cpython-312.pyc +0 -0
  86. indoxJudge/metrics/meteor/meteor.py +160 -0
  87. indoxJudge/metrics/misinformation/__init__.py +1 -0
  88. indoxJudge/metrics/misinformation/__pycache__/__init__.cpython-312.pyc +0 -0
  89. indoxJudge/metrics/misinformation/__pycache__/misinformation.cpython-312.pyc +0 -0
  90. indoxJudge/metrics/misinformation/__pycache__/template.cpython-312.pyc +0 -0
  91. indoxJudge/metrics/misinformation/misinformation.py +74 -0
  92. indoxJudge/metrics/misinformation/template.py +55 -0
  93. indoxJudge/metrics/privacy/__init__.py +1 -0
  94. indoxJudge/metrics/privacy/__pycache__/__init__.cpython-312.pyc +0 -0
  95. indoxJudge/metrics/privacy/__pycache__/privacy.cpython-312.pyc +0 -0
  96. indoxJudge/metrics/privacy/__pycache__/template.cpython-312.pyc +0 -0
  97. indoxJudge/metrics/privacy/privacy.py +74 -0
  98. indoxJudge/metrics/privacy/template.py +55 -0
  99. indoxJudge/metrics/rouge/__init__.py +1 -0
  100. indoxJudge/metrics/rouge/__pycache__/__init__.cpython-312.pyc +0 -0
  101. indoxJudge/metrics/rouge/__pycache__/rouge.cpython-312.pyc +0 -0
  102. indoxJudge/metrics/rouge/rouge.py +219 -0
  103. indoxJudge/metrics/stereotype_bias/__init__.py +1 -0
  104. indoxJudge/metrics/stereotype_bias/__pycache__/__init__.cpython-312.pyc +0 -0
  105. indoxJudge/metrics/stereotype_bias/__pycache__/stereotypeBias.cpython-312.pyc +0 -0
  106. indoxJudge/metrics/stereotype_bias/__pycache__/template.cpython-312.pyc +0 -0
  107. indoxJudge/metrics/stereotype_bias/stereotypeBias.py +71 -0
  108. indoxJudge/metrics/stereotype_bias/template.py +56 -0
  109. indoxJudge/metrics/toxicity/__init__.py +1 -0
  110. indoxJudge/metrics/toxicity/__pycache__/__init__.cpython-312.pyc +0 -0
  111. indoxJudge/metrics/toxicity/__pycache__/template.cpython-312.pyc +0 -0
  112. indoxJudge/metrics/toxicity/__pycache__/toxicity.cpython-312.pyc +0 -0
  113. indoxJudge/metrics/toxicity/template.py +92 -0
  114. indoxJudge/metrics/toxicity/toxicity.py +113 -0
  115. indoxJudge/models/__init__.py +6 -0
  116. indoxJudge/models/__pycache__/__init__.cpython-312.pyc +0 -0
  117. indoxJudge/models/__pycache__/googleai.cpython-312.pyc +0 -0
  118. indoxJudge/models/__pycache__/huggingface.cpython-312.pyc +0 -0
  119. indoxJudge/models/__pycache__/indox_api.cpython-312.pyc +0 -0
  120. indoxJudge/models/__pycache__/mistral.cpython-312.pyc +0 -0
  121. indoxJudge/models/__pycache__/openai.cpython-312.pyc +0 -0
  122. indoxJudge/models/googleai.py +79 -0
  123. indoxJudge/models/huggingface.py +111 -0
  124. indoxJudge/models/indox_api.py +106 -0
  125. indoxJudge/models/mistral.py +86 -0
  126. indoxJudge/models/ollama.py +80 -0
  127. indoxJudge/models/openai.py +88 -0
  128. indoxJudge/piplines/__init__.py +7 -0
  129. indoxJudge/piplines/__pycache__/__init__.cpython-312.pyc +0 -0
  130. indoxJudge/piplines/customEvaluator/__init__.py +0 -0
  131. indoxJudge/piplines/customEvaluator/__pycache__/__init__.cpython-312.pyc +0 -0
  132. indoxJudge/piplines/customEvaluator/__pycache__/custom_evaluator.cpython-312.pyc +0 -0
  133. indoxJudge/piplines/customEvaluator/custom_evaluator.py +311 -0
  134. indoxJudge/piplines/llmComparison/__init__.py +0 -0
  135. indoxJudge/piplines/llmComparison/__pycache__/__init__.cpython-312.pyc +0 -0
  136. indoxJudge/piplines/llmComparison/__pycache__/llm_comparison.cpython-312.pyc +0 -0
  137. indoxJudge/piplines/llmComparison/llm_comparison.py +8 -0
  138. indoxJudge/piplines/llmEvaluator/__init__.py +0 -0
  139. indoxJudge/piplines/llmEvaluator/__pycache__/__init__.cpython-312.pyc +0 -0
  140. indoxJudge/piplines/llmEvaluator/__pycache__/llm_evaluator.cpython-312.pyc +0 -0
  141. indoxJudge/piplines/llmEvaluator/graph/__init__.py +0 -0
  142. indoxJudge/piplines/llmEvaluator/graph/__pycache__/__init__.cpython-312.pyc +0 -0
  143. indoxJudge/piplines/llmEvaluator/graph/__pycache__/llm_comparison.cpython-312.pyc +0 -0
  144. indoxJudge/piplines/llmEvaluator/graph/__pycache__/metrics_visualizer.cpython-312.pyc +0 -0
  145. indoxJudge/piplines/llmEvaluator/graph/assets/style.css +121 -0
  146. indoxJudge/piplines/llmEvaluator/graph/llm_comparison.py +474 -0
  147. indoxJudge/piplines/llmEvaluator/graph/metrics_visualizer.py +367 -0
  148. indoxJudge/piplines/llmEvaluator/llm_evaluator.py +224 -0
  149. indoxJudge/piplines/ragEvaluator/__init__.py +0 -0
  150. indoxJudge/piplines/ragEvaluator/__pycache__/__init__.cpython-312.pyc +0 -0
  151. indoxJudge/piplines/ragEvaluator/__pycache__/rag_evaluator.cpython-312.pyc +0 -0
  152. indoxJudge/piplines/ragEvaluator/graph/__init__.py +0 -0
  153. indoxJudge/piplines/ragEvaluator/graph/__pycache__/__init__.cpython-312.pyc +0 -0
  154. indoxJudge/piplines/ragEvaluator/graph/__pycache__/ragplot.cpython-312.pyc +0 -0
  155. indoxJudge/piplines/ragEvaluator/graph/ragplot.py +188 -0
  156. indoxJudge/piplines/ragEvaluator/rag_evaluator.py +176 -0
  157. indoxJudge/piplines/safetyEvaluator/__init__.py +0 -0
  158. indoxJudge/piplines/safetyEvaluator/__pycache__/__init__.cpython-312.pyc +0 -0
  159. indoxJudge/piplines/safetyEvaluator/__pycache__/safety_evaluator.cpython-312.pyc +0 -0
  160. indoxJudge/piplines/safetyEvaluator/graph/SafetyVisual.py +395 -0
  161. indoxJudge/piplines/safetyEvaluator/graph/__init__.py +0 -0
  162. indoxJudge/piplines/safetyEvaluator/graph/__pycache__/__init__.cpython-312.pyc +0 -0
  163. indoxJudge/piplines/safetyEvaluator/graph/__pycache__/metrics_visualizer.cpython-312.pyc +0 -0
  164. indoxJudge/piplines/safetyEvaluator/graph/assets/style.css +121 -0
  165. indoxJudge/piplines/safetyEvaluator/graph/llm_comparison.py +395 -0
  166. indoxJudge/piplines/safetyEvaluator/graph/metrics_visualizer.py +150 -0
  167. indoxJudge/piplines/safetyEvaluator/safety_evaluator.py +112 -0
  168. indoxJudge/utils/__init__.py +2 -0
  169. indoxJudge/utils/__pycache__/__init__.cpython-312.pyc +0 -0
  170. indoxJudge/utils/__pycache__/preprocessing.cpython-312.pyc +0 -0
  171. indoxJudge/utils/__pycache__/utils.cpython-312.pyc +0 -0
  172. indoxJudge/utils/preprocessing.py +118 -0
  173. indoxJudge/utils/utils.py +17 -0
  174. indoxJudge-0.0.0.dist-info/LICENSE +21 -0
  175. indoxJudge-0.0.0.dist-info/METADATA +226 -0
  176. indoxJudge-0.0.0.dist-info/RECORD +178 -0
  177. indoxJudge-0.0.0.dist-info/WHEEL +5 -0
  178. indoxJudge-0.0.0.dist-info/top_level.txt +1 -0
indoxJudge/__init__.py ADDED
File without changes
@@ -0,0 +1,2 @@
1
+ from .visualization import Visualization
2
+
@@ -0,0 +1,188 @@
1
+ /* Light Theme */
2
+ .bg-light-custom {
3
+ background: rgb(246, 246, 246) !important;
4
+ color: black !important;
5
+ transition: all 0.2s;
6
+ }
7
+
8
+ .header {
9
+ position: relative;
10
+ top: 10px;
11
+ padding: 15px 63px;
12
+ }
13
+
14
+ .navbar-custom {
15
+ justify-content: center;
16
+ margin: 20px 0 50px 0;
17
+ background-color: rgb(255, 255, 255);
18
+ color: black;
19
+ padding: 20px;
20
+ border-radius: 8px;
21
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
22
+ }
23
+
24
+ .nav-link {
25
+ color: black !important;
26
+ }
27
+
28
+ .nav-link:hover {
29
+ color: rgb(255, 255, 255) !important;
30
+ background-color: rgb(53, 92, 125);
31
+ }
32
+
33
+ .col-12 {
34
+ padding: 0;
35
+ }
36
+
37
+ .card-header {
38
+ background-color: transparent;
39
+ border: none;
40
+ padding: 0 20px;
41
+ margin-bottom: 10px;
42
+ }
43
+
44
+ .cart-title {
45
+ font-size: 26px;
46
+ font-family: 'Roboto', sans-serif;
47
+ color: rgb(53, 92, 125);
48
+ text-align: center;
49
+ margin-bottom: 10px;
50
+ padding-bottom: 10px;
51
+ border-bottom: 2px solid rgba(53, 92, 125, 0.3);
52
+ }
53
+
54
+ .card-text {
55
+ height: 100%;
56
+ color: black;
57
+ backdrop-filter: blur(80px);
58
+ }
59
+
60
+ .card-body {
61
+ border: none;
62
+ box-shadow: 0 1px 3px 2px rgba(0, 0, 0, 0.1);
63
+ margin-bottom: 20px;
64
+ border-radius: 8px;
65
+ padding: 40px;
66
+ background-color: aliceblue;
67
+ }
68
+
69
+ .btn-gtt {
70
+ background-color: rgba(215, 215, 215, 0.891);
71
+ border: none;
72
+ outline: none;
73
+ }
74
+
75
+ .btn-gtt:hover {
76
+ background-color: rgb(181, 181, 181);
77
+ }
78
+
79
+ .change-bg {
80
+ display: flex;
81
+ align-items: center;
82
+ }
83
+
84
+ .modebtn {
85
+ margin: 0 14px;
86
+ }
87
+
88
+ /* sun icon */
89
+ .bi-brightness-high-fill {
90
+ font-size: 24px;
91
+ color: rgb(255, 165, 0); /* Orange color */
92
+ }
93
+
94
+ /* moon icon */
95
+ .bi-moon-fill {
96
+ font-size: 24px;
97
+ color: rgb(72, 61, 139); /* Dark Slate Blue color */
98
+ }
99
+
100
+ .form-check-input {
101
+ background-color: rgb(233, 233, 233);
102
+ }
103
+
104
+ /* toggle body */
105
+ .sc-bxivhb {
106
+ background-color: rgb(233, 233, 233);
107
+ margin: 0 5px;
108
+ border: 1px solid rgb(218, 218, 218);
109
+ width: 52px;
110
+ }
111
+
112
+ /* toggle circle */
113
+ .sc-ifAKCX {
114
+ background-color: rgb(133, 133, 133);
115
+ }
116
+
117
+ /* toggle body */
118
+ .daq-toggleswitch--light__indicator--off {
119
+ background-color: rgb(217, 217, 217);
120
+ }
121
+
122
+ .daq-toggleswitch--light__indicator--on {
123
+ background-color: rgb(33, 33, 33);
124
+ }
125
+
126
+ /* Dark Theme */
127
+ .bg-dark-custom {
128
+ background-color: rgb(48, 48, 48);
129
+ color: white;
130
+ }
131
+
132
+ .navbar-custom-dark {
133
+ justify-content: center;
134
+ margin: 20px 0 50px 0;
135
+ background-color: rgb(64, 64, 64);
136
+ color: rgb(217, 217, 217);
137
+ padding: 20px;
138
+ border-radius: 8px;
139
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
140
+ transition: all 0.2s;
141
+ }
142
+
143
+ .nav-link-dark {
144
+ color: white !important;
145
+ }
146
+
147
+ .card-header-dark {
148
+ border: none;
149
+ margin-bottom: 20px;
150
+ border-radius: 8px;
151
+ padding: 0 20px;
152
+ }
153
+
154
+ .cart-title-dark {
155
+ font-size: 26px;
156
+ font-family: 'Roboto', sans-serif;
157
+ color: rgb(255, 215, 0); /* Gold color */
158
+ text-align: center;
159
+ margin-bottom: 10px;
160
+ padding-bottom: 10px;
161
+ border-bottom: 2px solid rgba(255, 215, 0, 0.3);
162
+ }
163
+
164
+ .card-text-dark {
165
+ height: 100%;
166
+ color: white;
167
+ backdrop-filter: blur(80px);
168
+ }
169
+
170
+ .card-body-dark {
171
+ border: none;
172
+ box-shadow: 0 1px 3px 2px rgba(0, 0, 0, 0.2);
173
+ margin-bottom: 20px;
174
+ border-radius: 8px;
175
+ padding: 40px;
176
+ background-color: rgb(64, 64, 64);
177
+ }
178
+
179
+ /* button */
180
+ .btn-gtt-dark {
181
+ background-color: rgba(105, 105, 105, 0.891);
182
+ border: none;
183
+ outline: none;
184
+ }
185
+
186
+ .btn-gtt-dark:hover {
187
+ background-color: rgb(85, 85, 85);
188
+ }
@@ -0,0 +1,466 @@
1
+ import plotly.graph_objects as go
2
+ import plotly.express as px
3
+ import pandas as pd
4
+ from plotly.subplots import make_subplots
5
+ from dash import Dash, html, dcc
6
+ import dash_bootstrap_components as dbc
7
+ from dash.dependencies import Output, Input
8
+ from typing import Union, List, Dict
9
+ import dash_daq as daq
10
+
11
+
12
+ class Visualization:
13
+ """
14
+ A class to create and manage visualizations for model evaluation metrics.
15
+
16
+ Attributes:
17
+ mode (str): The mode of the visualization ('llm', 'safety', or 'rag').
18
+ light_template (str): The light theme template for Plotly.
19
+ dark_template (str): The dark theme template for Plotly.
20
+ current_template (str): The current theme template for Plotly.
21
+ models (list): A list of model data.
22
+ plots (list): A list of plot types to be generated based on the mode and number of models.
23
+
24
+ Methods:
25
+ determine_plots(): Determines the types of plots to generate based on the mode and number of models.
26
+ set_theme(theme: str): Sets the current theme template.
27
+ create_radar_chart(): Creates a radar chart for the evaluation metrics.
28
+ create_bar_chart(): Creates a bar chart for the evaluation metrics.
29
+ create_gauge_chart(): Creates a gauge chart for the overall scores.
30
+ create_scatter_plot(): Creates a scatter plot for the evaluation metrics.
31
+ create_line_plot(): Creates a line plot for the evaluation metrics.
32
+ create_heatmap(): Creates a heatmap for the evaluation metrics.
33
+ create_violin_plot(): Creates a violin plot for the evaluation metrics.
34
+ create_table(): Creates a table for the evaluation metrics.
35
+ get_plot(plot_type: str): Returns the specified plot.
36
+ create_layout(): Creates the layout for the Dash application.
37
+ plot(): Runs the Dash application.
38
+ """
39
+
40
+ def __init__(self, data: Union[List[Dict], Dict], mode: str = 'llm'):
41
+ """
42
+ Initializes the Visualization object with data and mode.
43
+
44
+ Args:
45
+ data (Union[List[Dict], Dict]): The data for the models.
46
+ mode (str): The mode of the visualization ('llm', 'safety', or 'rag').
47
+ """
48
+ self.mode = mode
49
+ self.light_template = "plotly_white"
50
+ self.dark_template = "plotly_dark"
51
+ self.current_template = self.light_template
52
+ self.models = data if isinstance(data, list) else [data]
53
+ self.plots = self.determine_plots()
54
+
55
+ def determine_plots(self):
56
+ """
57
+ Determines the types of plots to generate based on the mode and number of models.
58
+
59
+ Returns:
60
+ list: A list of plot types to be generated.
61
+ """
62
+ if self.mode == 'llm':
63
+ if len(self.models) == 1:
64
+ return ['bar_chart', 'radar_chart', 'gauge_chart']
65
+ else:
66
+ return ['radar_chart', 'bar_chart', 'scatter_plot', 'line_plot', 'heatmap', 'violin_plot',
67
+ 'gauge_chart', 'table']
68
+ elif self.mode == 'safety':
69
+ if len(self.models) == 1:
70
+ return ['bar_chart', 'gauge_chart']
71
+ else:
72
+ return ['radar_chart', 'bar_chart', 'gauge_chart']
73
+ elif self.mode == 'rag':
74
+ return ['bar_chart', 'gauge_chart']
75
+
76
+ def set_theme(self, theme: str):
77
+ """
78
+ Sets the current theme template.
79
+
80
+ Args:
81
+ theme (str): The theme to set ('light' or 'dark').
82
+
83
+ Raises:
84
+ ValueError: If the theme is not 'light' or 'dark'.
85
+ """
86
+ if theme not in ('light', 'dark'):
87
+ raise ValueError("Invalid theme. Must be 'light' or 'dark'.")
88
+
89
+ self.current_template = self.dark_template if theme == 'dark' else self.light_template
90
+
91
+ def create_radar_chart(self):
92
+ """
93
+ Creates a radar chart for the evaluation metrics.
94
+
95
+ Returns:
96
+ plotly.graph_objects.Figure: The radar chart figure.
97
+ """
98
+ fig = go.Figure()
99
+ for model in self.models:
100
+ name = model['name']
101
+ metrics = model['metrics']
102
+ labels = list(metrics.keys())
103
+ values = list(metrics.values())
104
+ values += values[:1]
105
+ labels += labels[:1]
106
+
107
+ fig.add_trace(go.Scatterpolar(
108
+ r=values,
109
+ theta=labels,
110
+ mode='lines+markers',
111
+ line=dict(width=1),
112
+ name=name
113
+ ))
114
+
115
+ fig.update_layout(
116
+ title='Evaluation Metrics Radar Chart',
117
+ polar=dict(
118
+ radialaxis=dict(
119
+ visible=True,
120
+ range=[0, 1]
121
+ )
122
+ ),
123
+ showlegend=True,
124
+ template=self.current_template
125
+ )
126
+ return fig
127
+
128
+ def create_bar_chart(self):
129
+ """
130
+ Creates a bar chart for the evaluation metrics.
131
+
132
+ Returns:
133
+ plotly.express.Figure: The bar chart figure.
134
+ """
135
+ data = []
136
+ for model in self.models:
137
+ if len(self.models) == 1:
138
+ metrics = model['metrics']
139
+ for metric, value in metrics.items():
140
+ data.append({"Metric": metric, "Value": value})
141
+ df = pd.DataFrame(data)
142
+ fig = px.bar(df, x='Metric', y='Value', color='Metric', barmode='group', text='Value',
143
+ template=self.current_template)
144
+ fig.update_layout(
145
+ title='Evaluation Metrics Bar Chart',
146
+ xaxis_title='Metrics',
147
+ yaxis_title='Values',
148
+ xaxis_tickangle=-45,
149
+
150
+ )
151
+ else:
152
+ name = model['name']
153
+ metrics = model['metrics']
154
+ for metric, value in metrics.items():
155
+ data.append({'Model': name, "Metric": metric, "Value": value})
156
+ df = pd.DataFrame(data)
157
+ fig = px.bar(df, x='Metric', y='Value', color='Model', barmode='group', text='Value',
158
+ template=self.current_template)
159
+ fig.update_layout(
160
+ title='Evaluation Metrics Bar Chart',
161
+ xaxis_title='Metrics',
162
+ yaxis_title='Values',
163
+ xaxis_tickangle=-45
164
+ )
165
+ return fig
166
+
167
+ def create_gauge_chart(self):
168
+ """
169
+ Creates a gauge chart for the overall scores.
170
+
171
+ Returns:
172
+ plotly.subplots.make_subplots: The gauge chart figure.
173
+ """
174
+ fig = make_subplots(
175
+ rows=1,
176
+ cols=len(self.models),
177
+ specs=[[{'type': 'indicator'}] * len(self.models)],
178
+ subplot_titles=[model['name'] for model in self.models]
179
+ )
180
+
181
+ for i, model in enumerate(self.models, 1):
182
+ name = model['name']
183
+ score = model['score']
184
+
185
+ if self.mode == 'llm' or 'rag':
186
+ steps = [
187
+ {'range': [0, 0.2], 'color': "red"},
188
+ {'range': [0.2, 0.4], 'color': "orange"},
189
+ {'range': [0.4, 0.6], 'color': "yellow"},
190
+ {'range': [0.6, 0.8], 'color': "lightgreen"},
191
+ {'range': [0.8, 1], 'color': "green"}
192
+ ]
193
+ elif self.mode == 'safety':
194
+ steps = [
195
+ {'range': [0, 0.2], 'color': "green"},
196
+ {'range': [0.2, 0.4], 'color': "lightgreen"},
197
+ {'range': [0.4, 0.6], 'color': "yellow"},
198
+ {'range': [0.6, 0.8], 'color': "orange"},
199
+ {'range': [0.8, 1], 'color': "red"}
200
+ ]
201
+
202
+ fig.add_trace(go.Indicator(
203
+ mode="gauge+number+delta",
204
+ value=score,
205
+ delta={'reference': 0.5, 'increasing': {'color': "green"}},
206
+ gauge={
207
+ 'axis': {'range': [0, 1], 'tickwidth': 0.7, 'tickcolor': "darkblue"},
208
+ 'bar': {'color': "darkblue"},
209
+ 'bgcolor': "white",
210
+ 'borderwidth': 2,
211
+ 'bordercolor': "gray",
212
+ 'steps': steps,
213
+ 'threshold': {
214
+ 'line': {'color': "black", 'width': 4},
215
+ 'thickness': 0.75,
216
+ 'value': score
217
+ }
218
+ }
219
+ ), row=1, col=i)
220
+
221
+ font = {'color': "white", 'family': "Arial"} if self.current_template == "plotly_dark" else {'color': "black",
222
+ 'family': "Arial"}
223
+ paper_bgcolor = "black" if self.current_template == "plotly_dark" else "white"
224
+ plot_bgcolor = "white" if self.current_template == "plotly_dark" else "black"
225
+
226
+ fig.update_layout(
227
+ title='Overall Evaluation Scores',
228
+ font=font,
229
+ paper_bgcolor=paper_bgcolor,
230
+ plot_bgcolor=plot_bgcolor,
231
+ template=self.current_template
232
+ )
233
+ return fig
234
+
235
+ def create_scatter_plot(self):
236
+ """
237
+ Creates a scatter plot for the evaluation metrics.
238
+
239
+ Returns:
240
+ plotly.express.Figure: The scatter plot figure.
241
+ """
242
+ data = []
243
+ for model in self.models:
244
+ name = model['name']
245
+ metrics = model['metrics']
246
+ for metric, value in metrics.items():
247
+ data.append({"Model": name, "Metric": metric, "Value": value})
248
+
249
+ df = pd.DataFrame(data)
250
+
251
+ fig = px.scatter(df, x='Value', y='Metric', color='Model', size='Value', hover_name='Model',
252
+ template=self.current_template)
253
+ fig.update_layout(
254
+ title='Evaluation Metrics Scatter Plot',
255
+ xaxis_title='Value',
256
+ yaxis_title='Metric'
257
+ )
258
+ return fig
259
+
260
+ def create_line_plot(self):
261
+ """
262
+ Creates a line plot for the evaluation metrics.
263
+
264
+ Returns:
265
+ plotly.express.Figure: The line plot figure.
266
+ """
267
+ data = []
268
+ for model in self.models:
269
+ name = model['name']
270
+ metrics = model['metrics']
271
+ for metric, value in metrics.items():
272
+ data.append({"Model": name, "Metric": metric, "Value": value})
273
+
274
+ df = pd.DataFrame(data)
275
+
276
+ fig = px.line(df, x='Metric', y='Value', color='Model', markers=True, template=self.current_template)
277
+ fig.update_layout(
278
+ title='Evaluation Metrics Line Plot',
279
+ xaxis_title='Metrics',
280
+ yaxis_title='Values'
281
+ )
282
+ return fig
283
+
284
+ def create_heatmap(self):
285
+ """
286
+ Creates a heatmap for the evaluation metrics.
287
+
288
+ Returns:
289
+ plotly.express.Figure: The heatmap figure.
290
+ """
291
+ data = []
292
+ for model in self.models:
293
+ name = model['name']
294
+ metrics = model['metrics']
295
+ for metric, value in metrics.items():
296
+ data.append({"Model": name, "Metric": metric, "Value": value})
297
+
298
+ df = pd.DataFrame(data)
299
+
300
+ heatmap_data = df.pivot(index="Model", columns="Metric", values="Value")
301
+ fig = px.imshow(heatmap_data, aspect="auto", color_continuous_scale="Viridis",
302
+ template=self.current_template)
303
+
304
+ fig.update_layout(
305
+ title='Evaluation Metrics Heatmap',
306
+ xaxis_title='Metrics',
307
+ yaxis_title='Models'
308
+ )
309
+ return fig
310
+
311
+ def create_violin_plot(self):
312
+ """
313
+ Creates a violin plot for the evaluation metrics.
314
+
315
+ Returns:
316
+ plotly.express.Figure: The violin plot figure.
317
+ """
318
+ data = []
319
+ for model in self.models:
320
+ name = model['name']
321
+ metrics = model['metrics']
322
+ for metric, value in metrics.items():
323
+ data.append({"Model": name, "Metric": metric, "Value": value})
324
+
325
+ df = pd.DataFrame(data)
326
+
327
+ fig = px.violin(df, x='Metric', y='Value', color='Model', box=True, points="all",
328
+ template=self.current_template)
329
+
330
+ fig.update_layout(
331
+ title='Evaluation Metrics Violin Plot',
332
+ xaxis_title='Metrics',
333
+ yaxis_title='Values'
334
+ )
335
+ return fig
336
+
337
+ def create_table(self):
338
+ """
339
+ Creates a table for the evaluation metrics.
340
+
341
+ Returns:
342
+ plotly.graph_objects.Figure: The table figure.
343
+ """
344
+ data = []
345
+ for model in self.models:
346
+ row = {'Model': model['name']}
347
+ row.update(model['metrics'])
348
+ data.append(row)
349
+
350
+ df = pd.DataFrame(data)
351
+ text_color = 'white' if self.current_template == self.dark_template else 'black'
352
+ cells_color = 'black' if self.current_template == self.dark_template else 'white'
353
+ fig = go.Figure(data=[go.Table(
354
+ columnwidth=[150] * len(df.columns),
355
+ header=dict(values=list(df.columns),
356
+ fill_color='paleturquoise',
357
+ align='left',
358
+ font=dict(color="black", size=12)),
359
+ cells=dict(values=[df[col].tolist() for col in df.columns],
360
+ fill_color='lavender',
361
+ align='left',
362
+ font=dict(size=10, color="black"))
363
+ )])
364
+
365
+ fig.update_layout(
366
+ title='Evaluation Metrics Table',
367
+ autosize=True,
368
+ margin=dict(l=0, r=0, t=30, b=0),
369
+ template=self.current_template
370
+ )
371
+ return fig
372
+ def get_plot(self, plot_type):
373
+ plot_methods = {
374
+ 'radar_chart': self.create_radar_chart,
375
+ 'bar_chart': self.create_bar_chart,
376
+ 'scatter_plot': self.create_scatter_plot,
377
+ 'line_plot': self.create_line_plot,
378
+ 'heatmap': self.create_heatmap,
379
+ 'violin_plot': self.create_violin_plot,
380
+ 'gauge_chart': self.create_gauge_chart,
381
+ 'table': self.create_table
382
+ }
383
+ if plot_type in plot_methods:
384
+ return plot_methods[plot_type]()
385
+ else:
386
+ raise ValueError(f"Plot type {plot_type} not recognized.")
387
+
388
+ def create_layout(self):
389
+ app = Dash(__name__, external_stylesheets=[dbc.themes.FLATLY, dbc.themes.DARKLY, dbc.icons.BOOTSTRAP])
390
+
391
+ nav_items = [
392
+ dbc.NavItem(dbc.NavLink(plot.replace('_', ' ').title(), href=f"#{plot}", className="nav-link",
393
+ external_link=True, id=f"nav-{plot}"))
394
+ for plot in self.plots
395
+ ]
396
+
397
+ cards = [
398
+ dbc.Card([
399
+ dbc.CardHeader(html.H4(plot.replace('_', ' ').title(), id=plot, className="display-4 cart-title")),
400
+ dbc.CardBody([
401
+ dbc.Row([
402
+ dbc.Col(dcc.Graph(id=f"graph-{plot}"), width=8),
403
+ dbc.Col(html.P(
404
+ f"This {plot.replace('_', ' ')} displays data for the model{'s' if len(self.models) > 1 else ''}.",
405
+ className="card-text p-3"), width=4)
406
+ ])
407
+ ])
408
+ ], className="mb-4", id=f"card-{plot}")
409
+ for plot in self.plots
410
+ ]
411
+
412
+ app.layout = html.Div([
413
+ html.Link(href='/assets/style.css', rel='stylesheet'),
414
+ dcc.Location(id='url', refresh=False),
415
+ dbc.Container([
416
+ dbc.Row([
417
+ dbc.Col(html.H2("IndoxJudge", className="text-center display-4", id="title-text"), width=10),
418
+ dbc.Col([
419
+ html.I(className="bi bi-brightness-high-fill"),
420
+ daq.ToggleSwitch(id="dark-mode-switch", value=False, className="my-4 out modebtn"),
421
+ html.I(className="bi bi-moon-fill"),
422
+ ], className='change-bg', width=2),
423
+ ], className='header', align="center"),
424
+ dbc.Row([
425
+ dbc.Col([
426
+ dbc.Nav(nav_items, pills=True, className="bg-light-custom stylish-nav justify-content-center", id="nav-container"),
427
+ ], width=12),
428
+ ], className="mb-4"),
429
+ dbc.Row([dbc.Col(cards, width=12, className="mb-4")]),
430
+ dbc.Row([
431
+ dbc.Col([
432
+ dbc.Button("Go to Top", className="btn-primary btn-gtt position-fixed bottom-0 end-0 m-4", href="#url")
433
+ ], width=12, className="d-flex justify-content-end btn-gtt-container")
434
+ ])
435
+ ], fluid=True, id='main-container', className='bg-dark-custom')
436
+ ])
437
+
438
+ return app
439
+
440
+ def plot(self, mode="external"):
441
+ app = self.create_layout()
442
+
443
+ @app.callback(
444
+ [Output('main-container', 'className'),
445
+ Output('title-text', 'className'),
446
+ Output('nav-container', 'className')] +
447
+ [Output(f'graph-{plot}', 'figure') for plot in self.plots],
448
+ [Input('dark-mode-switch', 'value')]
449
+ )
450
+ def update_theme_and_graphs(dark_mode):
451
+ if dark_mode:
452
+ self.set_theme('dark')
453
+ container_class = 'bg-dark-custom'
454
+ title_class = 'text-custom-primary-dark'
455
+ nav_class = 'navbar-custom-dark'
456
+ else:
457
+ self.set_theme('light')
458
+ container_class = 'bg-light-custom'
459
+ title_class = 'text-custom-primary'
460
+ nav_class = 'navbar-custom'
461
+
462
+ plots = [self.get_plot(plot) for plot in self.plots]
463
+
464
+ return [container_class, title_class, nav_class] + plots
465
+
466
+ app.run(jupyter_mode=mode)
@@ -0,0 +1,20 @@
1
+
2
+ from .g_eval import GEval
3
+ from .knowledge_retention import KnowledgeRetention
4
+ from .bertscore import BertScore
5
+ from .toxicity import Toxicity
6
+ from .bias import Bias
7
+ from .hallucination import Hallucination
8
+ from .faithfulness import Faithfulness
9
+ from .contextual_relevancy import ContextualRelevancy
10
+ from .rouge import Rouge
11
+ from .bleu import BLEU
12
+ from .answer_relevancy import AnswerRelevancy
13
+ from .meteor import METEOR
14
+ from .gruen import Gruen
15
+ from .fairness import Fairness
16
+ from .harmfulness import Harmfulness
17
+ from .privacy import Privacy
18
+ from .machine_ethics import MachineEthics
19
+ from .misinformation import Misinformation
20
+ from .stereotype_bias import StereotypeBias
@@ -0,0 +1 @@
1
+ from .answerRelevancy import AnswerRelevancy