-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make LlamaCppTokenizer an outlines Tokenizer
- Loading branch information
Showing
6 changed files
with
167 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from importlib import reload | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def temp_cache_dir(): | ||
import os | ||
import tempfile | ||
|
||
import outlines.caching | ||
import outlines.fsm.guide | ||
|
||
with tempfile.TemporaryDirectory() as tempdir: | ||
os.environ["OUTLINES_CACHE_DIR"] = tempdir | ||
outlines.caching.get_cache.cache_clear() | ||
reload(outlines) | ||
reload(outlines.fsm.guide) | ||
cache_status = outlines.caching._caching_enabled | ||
try: | ||
outlines.caching._caching_enabled = True | ||
yield | ||
finally: | ||
outlines.caching._caching_enabled = cache_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from outlines.fsm.guide import create_states_mapping | ||
from outlines.models.llamacpp import LlamaCppTokenizer | ||
|
||
|
||
def test_create_states_mapping_llamacpp(model): | ||
"""Minimal reproducer for #922, error passing llamacpp tokenizer to create_states_mapping""" | ||
create_states_mapping("a", LlamaCppTokenizer(model.model)) |