diff --git a/docs/api/continuation.md b/docs/api/continuation.md index e8790a2aa..66b9a719f 100644 --- a/docs/api/continuation.md +++ b/docs/api/continuation.md @@ -1 +1 @@ -::: outlines.text.generate.continuation +::: outlines.generate.continuation diff --git a/docs/api/fsm.md b/docs/api/fsm.md index 7c8f543a9..a7cc19f57 100644 --- a/docs/api/fsm.md +++ b/docs/api/fsm.md @@ -1 +1 @@ -::: outlines.text.fsm +::: outlines.index.fsm diff --git a/docs/api/json_schema.md b/docs/api/json_schema.md index 78272c9af..575a85e8d 100644 --- a/docs/api/json_schema.md +++ b/docs/api/json_schema.md @@ -1 +1 @@ -::: outlines.text.json_schema +::: outlines.index.json_schema diff --git a/docs/api/parsing.md b/docs/api/parsing.md index 75efa8467..a5ed59f24 100644 --- a/docs/api/parsing.md +++ b/docs/api/parsing.md @@ -1 +1 @@ -::: outlines.text.parsing +::: outlines.index.parsing diff --git a/docs/api/regex.md b/docs/api/regex.md index cdfb9abd7..5ef91db46 100644 --- a/docs/api/regex.md +++ b/docs/api/regex.md @@ -1 +1 @@ -::: outlines.text.generate.regex +::: outlines.generate.regex diff --git a/docs/api/samplers.md b/docs/api/samplers.md index b5ccd47cc..c125e9a66 100644 --- a/docs/api/samplers.md +++ b/docs/api/samplers.md @@ -1 +1 @@ -::: outlines.text.generate.samplers +::: outlines.generate.samplers diff --git a/examples/dating_profile.py b/examples/dating_profile.py index 7bf2a886d..acc00126e 100644 --- a/examples/dating_profile.py +++ b/examples/dating_profile.py @@ -6,8 +6,7 @@ from pydantic import BaseModel, conlist import outlines -import outlines.models as models -import outlines.text as text +from outlines import models class QuestionChoice(str, Enum): @@ -122,7 +121,7 @@ def dating_profile_prompt(description: str, examples: list[Example]): new_description = "I'm a laid-back lawyer who spends a lot of his free-time gaming. I work in a corporate office, but ended up here after the start-up I cofounded got acquired, so still play ping pong with my cool coworkers every day. I have a bar at home where I make cocktails, which is great for entertaining friends. I secretly like to wear suits and get a new one tailored every few months. I also like weddings because I get to wear those suits, and it's a good excuse for a date. I watch the latest series because I'm paying, with my hard-earned money, for every streaming service." prompt = dating_profile_prompt(description=new_description, examples=samples) -profile = text.generate.json(model, DatingProfile)(prompt) # type: ignore +profile = outlines.generate.json(model, DatingProfile)(prompt) # type: ignore print(profile) # Sample generated profiles diff --git a/examples/parsing.py b/examples/parsing.py index dbee9ab96..0f4031822 100644 --- a/examples/parsing.py +++ b/examples/parsing.py @@ -14,7 +14,7 @@ set_seed, ) -from outlines.text.parsing import PartialLark, PartialPythonIndenter +from outlines.index.parsing import PartialLark, PartialPythonIndenter revision = None checkpoint = "Salesforce/codegen-350M-mono" diff --git a/outlines/text/generate/__init__.py b/outlines/generate/__init__.py similarity index 100% rename from outlines/text/generate/__init__.py rename to outlines/generate/__init__.py diff --git a/outlines/text/generate/continuation.py b/outlines/generate/continuation.py similarity index 97% rename from outlines/text/generate/continuation.py rename to outlines/generate/continuation.py index d55acc49f..a35767949 100644 --- a/outlines/text/generate/continuation.py +++ b/outlines/generate/continuation.py @@ -2,10 +2,10 @@ import torch -from outlines.text.generate.sequence import Sequence +from outlines.generate.sequence import Sequence if TYPE_CHECKING: - from outlines.text.generate.samplers import Sampler + from outlines.generate.samplers import Sampler class Continuation(Sequence): diff --git a/outlines/text/generator.py b/outlines/generate/generator.py similarity index 97% rename from outlines/text/generator.py rename to outlines/generate/generator.py index 12cf9ba7f..565556e62 100644 --- a/outlines/text/generator.py +++ b/outlines/generate/generator.py @@ -4,7 +4,7 @@ import torch if TYPE_CHECKING: - from outlines.text.generate.samplers import Sampler + from outlines.generate.samplers import Sampler def process(generator: Generator, index, token_ids: torch.Tensor): diff --git a/outlines/text/generate/regex.py b/outlines/generate/regex.py similarity index 97% rename from outlines/text/generate/regex.py rename to outlines/generate/regex.py index 68f9ee694..040e30f0d 100644 --- a/outlines/text/generate/regex.py +++ b/outlines/generate/regex.py @@ -6,13 +6,16 @@ import torch from pydantic import BaseModel -from outlines.text.fsm import create_fsm_index_tokenizer, make_deterministic_fsm -from outlines.text.generate.continuation import Continuation -from outlines.text.json_schema import build_regex_from_object, get_schema_from_signature -from outlines.text.types import python_types_to_regex +from outlines.generate.continuation import Continuation +from outlines.index.fsm import create_fsm_index_tokenizer, make_deterministic_fsm +from outlines.index.json_schema import ( + build_regex_from_object, + get_schema_from_signature, +) +from outlines.index.types import python_types_to_regex if TYPE_CHECKING: - from outlines.text.generate.samplers import Sampler + from outlines.generate.samplers import Sampler class Regex(Continuation): diff --git a/outlines/text/generate/samplers.py b/outlines/generate/samplers.py similarity index 100% rename from outlines/text/generate/samplers.py rename to outlines/generate/samplers.py diff --git a/outlines/text/generate/sequence.py b/outlines/generate/sequence.py similarity index 98% rename from outlines/text/generate/sequence.py rename to outlines/generate/sequence.py index 948266dcd..f293d912f 100644 --- a/outlines/text/generate/sequence.py +++ b/outlines/generate/sequence.py @@ -6,8 +6,8 @@ from outlines.models import OpenAIAPI if TYPE_CHECKING: + from outlines.generate.samplers import Sampler from outlines.models.transformers import KVCacheType, Transformers - from outlines.text.generate.samplers import Sampler class Sequence: @@ -45,7 +45,7 @@ def __init__( model.tokenizer.pad_token_id, device=model.device ) if sampler is None: - from outlines.text.generate.samplers import multinomial + from outlines.generate.samplers import multinomial self.sampler = multinomial else: diff --git a/tests/text/__init__.py b/outlines/index/__init__.py similarity index 100% rename from tests/text/__init__.py rename to outlines/index/__init__.py diff --git a/outlines/text/fsm.py b/outlines/index/fsm.py similarity index 100% rename from outlines/text/fsm.py rename to outlines/index/fsm.py diff --git a/outlines/text/json_schema.py b/outlines/index/json_schema.py similarity index 100% rename from outlines/text/json_schema.py rename to outlines/index/json_schema.py diff --git a/outlines/text/parsing.py b/outlines/index/parsing.py similarity index 99% rename from outlines/text/parsing.py rename to outlines/index/parsing.py index fc34fff7f..7e1c333a3 100644 --- a/outlines/text/parsing.py +++ b/outlines/index/parsing.py @@ -35,7 +35,7 @@ from lark.parsers.lalr_interactive_parser import InteractiveParser from lark.parsers.lalr_parser import LALR_Parser, ParseConf, ParserState, _Parser -from outlines.text.fsm import ( +from outlines.index.fsm import ( fsm_union, get_sub_fsms_from_seq, make_deterministic_fsm, diff --git a/outlines/text/types.py b/outlines/index/types.py similarity index 100% rename from outlines/text/types.py rename to outlines/index/types.py diff --git a/outlines/text/__init__.py b/outlines/text/__init__.py deleted file mode 100644 index a1189ca01..000000000 --- a/outlines/text/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .generate import continuation diff --git a/tests/generate/__init__.py b/tests/generate/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/text/generate/test_continuation.py b/tests/generate/test_continuation.py similarity index 97% rename from tests/text/generate/test_continuation.py rename to tests/generate/test_continuation.py index 944ae6df6..d6194d7e0 100644 --- a/tests/text/generate/test_continuation.py +++ b/tests/generate/test_continuation.py @@ -1,6 +1,6 @@ import torch -from outlines.text.generate.continuation import Continuation, continuation +from outlines.generate.continuation import Continuation, continuation class Tokenizer: diff --git a/tests/text/test_generator.py b/tests/generate/test_generator.py similarity index 94% rename from tests/text/test_generator.py rename to tests/generate/test_generator.py index 70512f216..59b10f664 100644 --- a/tests/text/test_generator.py +++ b/tests/generate/test_generator.py @@ -3,7 +3,7 @@ import pytest import torch -from outlines.text.generator import bias_logits, token_generator +from outlines.generate.generator import bias_logits, token_generator def test_generator_error(): @@ -133,3 +133,11 @@ def is_final(state): return True else: return False + + +def test_update_token_ids(): + raise NotImplementedError + + +def expand_attention_masks(): + raise NotImplementedError diff --git a/tests/text/generate/test_integration_transfomers.py b/tests/generate/test_integration_transfomers.py similarity index 99% rename from tests/text/generate/test_integration_transfomers.py rename to tests/generate/test_integration_transfomers.py index 9e5c28f22..850c905f7 100644 --- a/tests/text/generate/test_integration_transfomers.py +++ b/tests/generate/test_integration_transfomers.py @@ -7,10 +7,10 @@ import torch from pydantic import BaseModel, constr +import outlines.generate as generate import outlines.models as models -import outlines.text.generate as generate +from outlines.index.fsm import reduced_vocabulary from outlines.models.transformers import TransformersTokenizer -from outlines.text.fsm import reduced_vocabulary def test_transformers_integration_continuation(): diff --git a/tests/text/generate/test_regex.py b/tests/generate/test_regex.py similarity index 97% rename from tests/text/generate/test_regex.py rename to tests/generate/test_regex.py index 642e383da..ede00d687 100644 --- a/tests/text/generate/test_regex.py +++ b/tests/generate/test_regex.py @@ -4,9 +4,9 @@ import pytest import torch -import outlines.text.generate as generate -from outlines.text.fsm import create_fsm_index_tokenizer, make_deterministic_fsm -from outlines.text.generate.regex import Regex +import outlines.generate as generate +from outlines.generate.regex import Regex +from outlines.index.fsm import create_fsm_index_tokenizer, make_deterministic_fsm class Tokenizer: diff --git a/tests/text/generate/test_samplers.py b/tests/generate/test_samplers.py similarity index 95% rename from tests/text/generate/test_samplers.py rename to tests/generate/test_samplers.py index 5e1543fc7..5928a1ae0 100644 --- a/tests/text/generate/test_samplers.py +++ b/tests/generate/test_samplers.py @@ -2,11 +2,7 @@ import torch -from outlines.text.generate.samplers import ( - greedy, - multinomial, - vectorized_random_choice, -) +from outlines.generate.samplers import greedy, multinomial, vectorized_random_choice def test_greedy(): diff --git a/tests/text/generate/test_sequence.py b/tests/generate/test_sequence.py similarity index 99% rename from tests/text/generate/test_sequence.py rename to tests/generate/test_sequence.py index f4fd52c03..c1a50f15d 100644 --- a/tests/text/generate/test_sequence.py +++ b/tests/generate/test_sequence.py @@ -5,9 +5,9 @@ import pytest import torch +from outlines.generate.sequence import Sequence from outlines.models import OpenAIAPI from outlines.models.tokenizer import Tokenizer -from outlines.text.generate.sequence import Sequence def test_openai_error(): diff --git a/tests/text/partial_python.lark b/tests/index/partial_python.lark similarity index 100% rename from tests/text/partial_python.lark rename to tests/index/partial_python.lark diff --git a/tests/text/test_fsm.py b/tests/index/test_fsm.py similarity index 99% rename from tests/text/test_fsm.py rename to tests/index/test_fsm.py index f10f0f816..48dc2cd1c 100644 --- a/tests/text/test_fsm.py +++ b/tests/index/test_fsm.py @@ -2,8 +2,7 @@ import numba import pytest -from outlines.models.transformers import TransformersTokenizer -from outlines.text.fsm import ( +from outlines.index.fsm import ( _walk_fsm, create_fsm_index, create_fsm_index_end_to_end, @@ -14,6 +13,7 @@ make_deterministic_fsm, walk_fsm, ) +from outlines.models.transformers import TransformersTokenizer def walk_fsm_numba( @@ -429,7 +429,7 @@ def test_json_index_performance(): from pydantic import BaseModel, constr import outlines.models as models - from outlines.text.generate.regex import Regex, build_regex_from_object + from outlines.generate.regex import Regex, build_regex_from_object class Weapon(str, Enum): sword = "sword" diff --git a/tests/text/test_json_schema.py b/tests/index/test_json_schema.py similarity index 99% rename from tests/text/test_json_schema.py rename to tests/index/test_json_schema.py index 380392980..1935c2ca0 100644 --- a/tests/text/test_json_schema.py +++ b/tests/index/test_json_schema.py @@ -5,7 +5,7 @@ import pytest from pydantic import BaseModel, constr -from outlines.text.json_schema import ( +from outlines.index.json_schema import ( BOOLEAN, INTEGER, NULL, diff --git a/tests/text/test_parsing.py b/tests/index/test_parsing.py similarity index 98% rename from tests/text/test_parsing.py rename to tests/index/test_parsing.py index 8c7dff928..a546947c7 100644 --- a/tests/text/test_parsing.py +++ b/tests/index/test_parsing.py @@ -4,7 +4,7 @@ from lark.indenter import DedentError from lark.lexer import UnexpectedCharacters, UnexpectedToken -from outlines.text.parsing import PartialLark, PartialPythonIndenter +from outlines.index.parsing import PartialLark, PartialPythonIndenter def test_partial_parsing(): diff --git a/tests/text/test_types.py b/tests/index/test_types.py similarity index 93% rename from tests/text/test_types.py rename to tests/index/test_types.py index d70d5bd7b..606b70e69 100644 --- a/tests/text/test_types.py +++ b/tests/index/test_types.py @@ -2,7 +2,7 @@ import pytest -from outlines.text.types import ( +from outlines.index.types import ( BOOLEAN, DATE, DATETIME,