From 4ec72a1e98d08114a8aa103fa322f90adf987e8f Mon Sep 17 00:00:00 2001 From: Andrew Lapp Date: Wed, 7 Feb 2024 14:24:07 -0600 Subject: [PATCH] Apply lru_cache to RegexFSM --- outlines/fsm/fsm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/outlines/fsm/fsm.py b/outlines/fsm/fsm.py index 74a972d9a..f475b8567 100644 --- a/outlines/fsm/fsm.py +++ b/outlines/fsm/fsm.py @@ -1,3 +1,4 @@ +import functools from typing import TYPE_CHECKING, List, NewType, Protocol, Tuple import interegular @@ -88,6 +89,7 @@ def copy(self) -> "StopAtEosFSM": return self +@functools.lru_cache(maxsize=1024) class RegexFSM(FSM): """FSM to generate text that is in the language of a regular expression."""