Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the Activation cache while the LLM is generating new tokens? #697

Open
Meehaohao opened this issue Aug 7, 2024 · 2 comments
Open
Labels
complexity-moderate Moderately complicated issues for people who have intermediate experience with the code

Comments

@Meehaohao
Copy link

Meehaohao commented Aug 7, 2024

Question

My prompt is "Which instrument does Henry Halstead mainly play? Please answer an instrument name. Answer: ", which is a question to LLM.
I want to get the cached hidden states of the LLM responsed tokens while LLM is generating the response. How to do it?

On one hand, the codelogits, cache = model.run_with_cache(prompt, return_cache_object=True) only cache the hidden states of the prompt, because it dosen't run the generate function.

On the other hand, the code output = model.generate(prompt, do_sample = False, max_new_tokens = 20) only get the generated tokens or sentences, I can't get the Activation_cache of the generated Answer.

So how can I obtain the model response and the Acativation_cache of the LLM response tokens at the same time during one reasoning process?

@Meehaohao Meehaohao changed the title How to get the hook while generating new tokens? How to get the Activation cache while the LLM is generating new tokens? Aug 7, 2024
@bryce13950
Copy link
Collaborator

Unfortunately, at this moment in time there is no integration of activation cache in the generate function. I don't see any reason why we can't add that as an option, but it would unfortunately be a pretty low priority given some other projects that are currently being worked on unless someone volunteers to do it.

@bryce13950 bryce13950 added the complexity-moderate Moderately complicated issues for people who have intermediate experience with the code label Aug 16, 2024
@Meehaohao
Copy link
Author

Got it, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity-moderate Moderately complicated issues for people who have intermediate experience with the code
Projects
None yet
Development

No branches or pull requests

2 participants