Skip to content

Commit

Permalink
Fix llamacpp caching by making LlamaCppTokenizer pickleable
Browse files Browse the repository at this point in the history
  • Loading branch information
lapp0 committed May 29, 2024
1 parent 538f77a commit 4a99aa3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions outlines/integrations/llamacpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ def __init__(self, model: "Llama"):
def convert_token_to_string(self, token: str) -> str:
return token

def __getstate__(self):
"""Allow tokenizer to be used as hash key by excluding self.decode"""
return (
sorted(self.vocabulary.items()),
self.eos_token_id,
self.eos_token,
self.pad_token_id,
sorted(self.special_tokens),
)


class LogitsProcessor:
"""Bias LlamaCpp generation using a finite state machine.
Expand Down

0 comments on commit 4a99aa3

Please sign in to comment.