Skip to content

Commit

Permalink
[Bugfix] use diskcache in outlines _get_guide vllm-project#5436 (vllm…
Browse files Browse the repository at this point in the history
  • Loading branch information
ericperfect authored and dtrifiro committed Jul 17, 2024
1 parent e068cf6 commit 173d2fa
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Callable, DefaultDict, Dict, List, Union

import torch
from outlines.caching import cache
from outlines.fsm.guide import CFGGuide, Generate, Guide, RegexGuide, Write
from outlines.fsm.json_schema import build_regex_from_schema
from pydantic import BaseModel
Expand Down Expand Up @@ -67,7 +68,7 @@ def __call__(self, input_ids: List[int],
class RegexLogitsProcessor(BaseLogitsProcessor):

@classmethod
@lru_cache(maxsize=32)
@cache()
def _get_guide(cls, regex_string: str,
tokenizer: PreTrainedTokenizerBase) -> Guide:
tokenizer = _adapt_tokenizer(tokenizer)
Expand Down Expand Up @@ -126,7 +127,7 @@ def __init__(self, schema: Union[str, Dict, BaseModel],
class CFGLogitsProcessor(BaseLogitsProcessor):

@classmethod
@lru_cache(maxsize=32)
@cache()
def _get_guide(cls, cfg: str, tokenizer: PreTrainedTokenizerBase) -> Guide:
tokenizer = _adapt_tokenizer(tokenizer)
return CFGGuide(cfg, tokenizer)
Expand Down

0 comments on commit 173d2fa

Please sign in to comment.