dhuynh95 commited on
Commit
02e0932
·
verified ·
1 Parent(s): b16680f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -125,12 +125,16 @@ examples = [
125
 
126
  topk = 5
127
 
128
- def get_features(text):
129
-
130
  inputs = tokenizer.encode(text, return_tensors="pt", add_special_tokens=True).to("cuda")
131
 
132
  target_act = gather_residual_activations(model, layer, inputs)
133
  sae_act = sae.encode(target_act)
 
 
 
 
134
  sae_act_aggregated = ((sae_act[:,:,:] > 0).sum(1) > 0).cpu().numpy()
135
 
136
  X = pd.DataFrame(sae_act_aggregated)
 
125
 
126
  topk = 5
127
 
128
+ # Function to wrap in a FastAPI in case of
129
+ def get_activations(text):
130
  inputs = tokenizer.encode(text, return_tensors="pt", add_special_tokens=True).to("cuda")
131
 
132
  target_act = gather_residual_activations(model, layer, inputs)
133
  sae_act = sae.encode(target_act)
134
+ return sae_act
135
+
136
+ def get_features(text):
137
+ sae_act = get_activations(text)
138
  sae_act_aggregated = ((sae_act[:,:,:] > 0).sum(1) > 0).cpu().numpy()
139
 
140
  X = pd.DataFrame(sae_act_aggregated)