Skip to content

Commit

Permalink
get_index_dict -> get_transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
torymur committed Oct 31, 2024
1 parent 9c0868f commit 19f5450
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/outlines_core/fsm/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,4 @@ def copy(self):

def get_index_dict(self):
"""Returns the Index as a Python Dict object."""
return self.states_to_token_maps.get_index_dict()
return self.states_to_token_maps.get_transitions()
4 changes: 2 additions & 2 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl FSMInfo {

#[derive(Debug)]
pub struct Index {
pub(crate) initial: u32,
initial: u32,
finals: HashSet<u32>,
states_to_token_subsets: HashMap<u32, HashMap<u32, u32>>,
eos_token_id: u32,
Expand Down Expand Up @@ -126,7 +126,7 @@ impl Index {
self.finals.contains(&state)
}

pub(crate) fn index(&self) -> &HashMap<u32, HashMap<u32, u32>> {
pub(crate) fn transitions(&self) -> &HashMap<u32, HashMap<u32, u32>> {
&self.states_to_token_subsets
}
}
4 changes: 2 additions & 2 deletions src/python_bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ impl PyIndex {
self.0.is_final(state)
}

fn get_index_dict(&self) -> HashMap<u32, HashMap<u32, u32>> {
self.0.index().clone()
fn get_transitions(&self) -> HashMap<u32, HashMap<u32, u32>> {
self.0.transitions().clone()
}

fn get_initial_state(&self) -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion tests/fsm/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def test_create_fsm_index_tokenizer(hf_tokenizer_uri, revision):
)

assert not empty_token_ids
assert len(states_to_token_subsets.get_index_dict()) / num_fsm_states > 0.94
assert len(states_to_token_subsets.get_transitions()) / num_fsm_states > 0.94


@pytest.mark.parametrize(
Expand Down

0 comments on commit 19f5450

Please sign in to comment.