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

Support for LongLLaMA tensor format of _past_key_values #390

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guidance/llms/_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async def __call__(self, prompt, stop=None, stop_regex=None, temperature=None, n

# trim the cache to what we can use
if prefix_match_len < len(self._prefix_cache): # prefix_match_len > 0 and
self._past_key_values = tuple((key[:,:,:prefix_match_len,:],value[:,:,:prefix_match_len,:]) for key,value in self._past_key_values) # TODO: this is specific to the GPT2 tensor layout
self._past_key_values = tuple(tuple(key_value[:,:,:prefix_match_len,:] for key_value in key_values) for key_values in self._past_key_values) # TODO: this works for GPT2 and Long Llama tensor layout.
self._prefix_cache = self._prefix_cache[:prefix_match_len]

# add support for pattern guidance
Expand Down