Skip to content

Commit

Permalink
vllm 0.3.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-ferenczi committed Feb 3, 2024
1 parent 689b916 commit c8b68c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion outlines/serve/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from outlines.fsm.fsm import FSMState, RegexFSM
from outlines.fsm.json_schema import build_regex_from_object

from vllm.transformers_utils.tokenizer import TokenizerGroup


def _patched_apply_logits_processors(
logits,
Expand Down Expand Up @@ -38,14 +40,16 @@ def _patched_apply_logits_processors(
return logits


def adapt_tokenizer(tokenizer):
def adapt_tokenizer(tokenizer_group):
"""Adapt vLLM's tokenizer to use to compile the FSM.
The API of Outlines tokenizers is slightly different to that of
`transformers`. In addition, we need to handle the missing spaces to
Llama's tokenizer to be able to compile FSMs for this model.
"""
assert isinstance(tokenizer_group, TokenizerGroup)
tokenizer = tokenizer_group.tokenizer
tokenizer.vocabulary = tokenizer.get_vocab()
tokenizer.special_tokens = set(tokenizer.all_special_tokens)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies = [
"referencing",
"jsonschema",
"requests",
"transformers==4.36.2", # TODO: unpin when HF fixes release (4.37.0 is broken)
"transformers",
]
dynamic = ["version"]

Expand Down

0 comments on commit c8b68c4

Please sign in to comment.