Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port necessary interegular functionality #38

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# enables `cargo build -F python-bindings -v` on arm macs
[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]
3 changes: 2 additions & 1 deletion python/outlines_core/fsm/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
Union,
)

import interegular
import torch
from outlines_core.fsm.regex import (
create_fsm_index_tokenizer,
make_byte_level_fsm,
make_deterministic_fsm,
)

import interegular

if TYPE_CHECKING:
from outlines_core.models.tokenizer import Tokenizer

Expand Down
4 changes: 3 additions & 1 deletion python/outlines_core/fsm/outlines_core_rs.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, List, Optional, Set, Tuple
from typing import Any, Dict, List, Optional, Set, Tuple

class FSMInfo:
initial: int
Expand Down Expand Up @@ -52,6 +52,8 @@ def create_fsm_index_end_to_end(
vocabulary: Vocabulary,
frozen_tokens: frozenset[str],
) -> Dict[int, Dict[int, int]]: ...
def parse_pattern(pattern: str) -> Any: ...
def parse_pattern_to_fsm(pattern: str) -> Any: ...

BOOLEAN: str
DATE: str
Expand Down
4 changes: 3 additions & 1 deletion python/outlines_core/fsm/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
anything_else,
)

from .outlines_core_rs import ( # noqa: F401
from .outlines_core_rs import ( # noqa: F401; TODO: likely temporary; just to ensure that the fsm creation works
FSMInfo,
Vocabulary,
_walk_fsm,
create_fsm_index_end_to_end,
get_token_transition_keys,
get_vocabulary_transition_keys,
parse_pattern,
parse_pattern_to_fsm,
state_scan_tokens,
)

Expand Down
Loading