TransformerLensOrg / CircuitsVis

Mechanistic Interpretability Visualizations using React
https://alan-cooney.github.io/CircuitsVis/
MIT License
192 stars 29 forks source link

Topk tokens #21

Closed danbraunai closed 1 year ago

danbraunai commented 1 year ago

Adds the topk visualisation which shows the topk and/or bottomk activations in a table:

image
danbraunai commented 1 year ago

Hmm yeah. I think we could allow the user to select the value of k in python, including whether they want both top and bottom. Then in the python script we can count what the size of the resulting tensor would be and return an error if it will take up more than 2mb (please advise if you think we should make this smaller/bigger). Following that we calc the topk and bottomk in the python script before embedding in the JS.

I can make these changes at some point, let me know if you think something different to the above is better.

alan-cooney commented 1 year ago

Hmm yeah. I think we could allow the user to select the value of k in python, including whether they want both top and bottom. Then in the python script we can count what the size of the resulting tensor would be and return an error if it will take up more than 2mb (please advise if you think we should make this smaller/bigger). Following that we calc the topk and bottomk in the python script before embedding in the JS.

I can make these changes at some point, let me know if you think something different to the above is better.

Nice yes this makes sense. We don't have to check/error on size I don't think (as the value would be very subjective depending on use), but otherwise completely makes sense.

At some point I'm also going to add compression to the variables sent from Python -> JavaScript, but it won't save that much

danbraunai commented 1 year ago

@alan-cooney I've updated it so that the topk calculations happen in python (among other tweaks). Fair bit of a refactor so let me know if there's anything new you think needs fixing. Cheers.