psaiops 0.0.6__tar.gz → 0.0.7__tar.gz

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.

Potentially problematic release.


This version of psaiops might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: psaiops
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary: Web apps to inspect & engineer NN activations.
5
5
  License: .github/LICENSE.md
6
6
  Author: apehex
@@ -1,3 +1,5 @@
1
+ import functools
2
+
1
3
  import gradio
2
4
  import torch
3
5
  import torch.cuda
@@ -124,10 +126,12 @@ def update_output_value(
124
126
  def create_app(title: str=TITLE, intro: str=INTRO, style: str=STYLE, model: str=MODEL) -> gradio.Blocks:
125
127
  __fields = {}
126
128
  with gradio.Blocks(theme=gradio.themes.Soft(), title=title, css=style) as __app:
127
- # init
129
+ # load the model
128
130
  __device = 'cuda' if torch.cuda.is_available() else 'cpu'
129
131
  __model = psaiops.score.attention.lib.get_model(name=model, device=__device)
130
132
  __tokenizer = psaiops.score.attention.lib.get_tokenizer(name=model, device=__device)
133
+ # adapt the scoring function
134
+ __score = functools.partial(psaiops.score.attention.lib.score_tokens, model_obj=__model, tokenizer_obj=__tokenizer, device_str=__device)
131
135
  # create the UI
132
136
  __fields.update(create_layout(intro=intro))
133
137
  # init the state
@@ -136,8 +140,8 @@ def create_app(title: str=TITLE, intro: str=INTRO, style: str=STYLE, model: str=
136
140
  __button = __fields['process_block']
137
141
  # wire the input fields
138
142
  __button.click(
139
- fn=psaiops.score.attention.lib.score_tokens,
140
- inputs=[__model, __tokenizer] + [__fields[__k] for __k in ['input_block', 'tokens_block', 'topk_block', 'topp_block', 'position_block', 'layer_block', 'head_block']] + [__device],
143
+ fn=__score,
144
+ inputs=[__fields[__k] for __k in ['input_block', 'tokens_block', 'topk_block', 'topp_block', 'position_block', 'layer_block', 'head_block']],
141
145
  outputs=__fields['output_block'],
142
146
  queue=False,
143
147
  show_progress='full')
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "psaiops"
3
- version = "0.0.6"
3
+ version = "0.0.7"
4
4
  description = "Web apps to inspect & engineer NN activations."
5
5
  license = ".github/LICENSE.md"
6
6
  readme = ".github/README.md"
File without changes
File without changes