1

I have been using tfjs qna model, repo here for doing some question answering tasks. I wanted to access the internal model states for this model, specifically attention matrices for the intermediate layers that I want to display.

My constraints are that I cannot use python or ajax, this needs to work in a browser environment (thus using something like bertviz is not possible).

I found the part that calls the tf model which is linked here.

It does a model.execute(...) on the question, passage to get a series of start and end logits. The aforementioned model has an executor key that looks as follows:

executor ss

I see in this a keepTensorForDebug argument that I tried turning to true, but that seems to just retain the output logits related to the question-answering only, and not the intermediate attention tensors of the mobilebert model that it is using. What I essentially need access to is a way to stop the execute function from disposing the intermediate tensors, but I have not been able to find a way of doing this. I did find the source code for the executor function, but was unable to understand how to change it to retain the tensors that it is disposing.

Please let me know and I can provide any additional details. Any help is appreciated. Thank you.

n404
  • 13
  • 2

0 Answers0