You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importjsonfromoutlines_core.json_schemaimportbuild_regex_from_schemafromoutlines_core.fsm.guideimportGuide, Index, Vocabularyschema= {
"title": "Foo",
"type": "object",
"properties": {"date": {"type": "string", "format": "date"}}
}
regex=build_regex_from_schema(json.dumps(schema))
vocabulary=Vocabulary.from_pretrained("openai-community/gpt2")
index=Index(regex, vocabulary)
guide=Guide(index)
# Get current state of the Guide:current_state=guide.get_state()
# Get allowed tokens for the current state of the Guide:allowed_tokens=guide.get_tokens()
# Advance Guide to the next state via some token_id and return allowed tokens for that new state:next_allowed_tokens=guide.advance(allowed_tokens[-1])
# To check if Guide is finished:guide.is_finished()
# If it's finished then this assertion holds:assertguide.get_tokens() == [vocabulary.get_eos_token_id()]
Some previously imported structures like Write and Generate might make sense to move back to outlines and adapt them, if they'll be used in other Guides. How best to proceed there is open for discussion.
The text was updated successfully, but these errors were encountered:
outlines-core
v0.2 introduces major interface changes, which require additional work on theoutlines
side.Currently in
outlines
we're importing these fromoutlines_core
:Now we're providing interfaces and usage like:
More interface details for
Vocabulary
,Index
andGuide
will be available at: https://github.com/dottxt-ai/outlines-core/blob/main/python/outlines_core/outlines_core_rs.pyiSome previously imported structures like
Write
andGenerate
might make sense to move back tooutlines
and adapt them, if they'll be used in other Guides. How best to proceed there is open for discussion.The text was updated successfully, but these errors were encountered: