Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,19 +23,19 @@ llama = LanguageModel("meta-llama/Meta-Llama-3.1-8B", token=access_token)
|
|
23 |
#placeholder for reset
|
24 |
prompts_with_probs = pd.DataFrame(
|
25 |
{
|
26 |
-
"prompt": ['
|
27 |
"layer": [0],
|
28 |
-
"results": ['
|
29 |
"probs": [0],
|
30 |
-
"expected": ['
|
31 |
})
|
32 |
prompts_with_ranks = pd.DataFrame(
|
33 |
{
|
34 |
-
"prompt": ['
|
35 |
"layer": [0],
|
36 |
-
"results": ['
|
37 |
"ranks": [0],
|
38 |
-
"expected": ['
|
39 |
})
|
40 |
|
41 |
def run_lens(model,PROMPT):
|
@@ -94,15 +94,6 @@ def process_file(prompts_data,file_path):
|
|
94 |
|
95 |
return prompts
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
#problem with using gr.LinePlot instead of a plt.figure is that text labels cannot be added for each individual point
|
100 |
-
# def plot_prob(prompts_with_probs):
|
101 |
-
# return gr.LinePlot(prompts_with_probs, x="layer", y="probs",color="prompt", title="Probability of Expected Token",label="results",show_label=True,key="results")
|
102 |
-
import matplotlib.pyplot as plt
|
103 |
-
import pandas as pd
|
104 |
-
import io
|
105 |
-
from PIL import Image
|
106 |
def plot_prob(prompts_with_probs):
|
107 |
plt.figure(figsize=(10, 6))
|
108 |
|
@@ -134,13 +125,6 @@ def plot_prob(prompts_with_probs):
|
|
134 |
img = Image.open(buf)
|
135 |
plt.close() # Close the figure to free memory
|
136 |
return img
|
137 |
-
# Example usage
|
138 |
-
# prompts_with_probs should be a DataFrame with 'prompt', 'layer', and 'probs' columns
|
139 |
-
|
140 |
-
import matplotlib.pyplot as plt
|
141 |
-
import pandas as pd
|
142 |
-
import io
|
143 |
-
from PIL import Image
|
144 |
|
145 |
def plot_rank(prompts_with_ranks):
|
146 |
plt.figure(figsize=(10, 6))
|
@@ -174,11 +158,6 @@ def plot_rank(prompts_with_ranks):
|
|
174 |
plt.close() # Close the figure to free memory
|
175 |
return img
|
176 |
|
177 |
-
import matplotlib.pyplot as plt
|
178 |
-
import pandas as pd
|
179 |
-
import io
|
180 |
-
from PIL import Image
|
181 |
-
|
182 |
def plot_prob_mean(prompts_with_probs):
|
183 |
# Calculate mean probabilities and variance
|
184 |
summary_stats = prompts_with_probs.groupby("prompt")["probs"].agg(
|
@@ -213,9 +192,6 @@ def plot_prob_mean(prompts_with_probs):
|
|
213 |
plt.close() # Close the figure to free memory
|
214 |
return img
|
215 |
|
216 |
-
# Example usage
|
217 |
-
# prompts_with_probs should be a DataFrame with 'prompt' and 'probs' columns
|
218 |
-
|
219 |
def plot_rank_mean(prompts_with_ranks):
|
220 |
# Calculate mean ranks and variance
|
221 |
summary_stats = prompts_with_ranks.groupby("prompt")["ranks"].agg(
|
|
|
23 |
#placeholder for reset
|
24 |
prompts_with_probs = pd.DataFrame(
|
25 |
{
|
26 |
+
"prompt": [''],
|
27 |
"layer": [0],
|
28 |
+
"results": [''],
|
29 |
"probs": [0],
|
30 |
+
"expected": [''],
|
31 |
})
|
32 |
prompts_with_ranks = pd.DataFrame(
|
33 |
{
|
34 |
+
"prompt": [''],
|
35 |
"layer": [0],
|
36 |
+
"results": [''],
|
37 |
"ranks": [0],
|
38 |
+
"expected": [''],
|
39 |
})
|
40 |
|
41 |
def run_lens(model,PROMPT):
|
|
|
94 |
|
95 |
return prompts
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
def plot_prob(prompts_with_probs):
|
98 |
plt.figure(figsize=(10, 6))
|
99 |
|
|
|
125 |
img = Image.open(buf)
|
126 |
plt.close() # Close the figure to free memory
|
127 |
return img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
def plot_rank(prompts_with_ranks):
|
130 |
plt.figure(figsize=(10, 6))
|
|
|
158 |
plt.close() # Close the figure to free memory
|
159 |
return img
|
160 |
|
|
|
|
|
|
|
|
|
|
|
161 |
def plot_prob_mean(prompts_with_probs):
|
162 |
# Calculate mean probabilities and variance
|
163 |
summary_stats = prompts_with_probs.groupby("prompt")["probs"].agg(
|
|
|
192 |
plt.close() # Close the figure to free memory
|
193 |
return img
|
194 |
|
|
|
|
|
|
|
195 |
def plot_rank_mean(prompts_with_ranks):
|
196 |
# Calculate mean ranks and variance
|
197 |
summary_stats = prompts_with_ranks.groupby("prompt")["ranks"].agg(
|