Skip to content

Commit e7d7090

Browse files
authored
Automatically infer whether to use a chat template or not instead of using kwargs (#885)
* chat_template automatically inferred * single system * fix * added unit tests + integ test * mock the model creation phase to go faster
1 parent bc5e450 commit e7d7090

20 files changed

+106
-42
lines changed

community_tasks/oz_evals.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
Data consists of 1k+ high-quality questions and answers which were used as part of entry exams at the Faculty of Philosophy and Faculty of Organizational Sciences, University of Belgrade.
3131
The exams test the General Knowledge of students and were used in the enrollment periods from 2003 to 2024.
3232
For more details and results see: https://huggingface.co/datasets/DjMel/oz-eval
33-
34-
In order to have comparable results to ours, please do not forget to run with --use_chat_template
3533
"""
3634

3735
from lighteval.metrics.metrics import Metrics

community_tasks/serbian_eval.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ def prompt_fn_oz_eval_task(line, task_name: str = None):
137137
or if 'answer_str' is not one of ["A", "B", "C", "D", "E"].
138138
139139
Note:
140-
This function is part of the LightEval setup, specifically for loading OZ Eval dataset questions
141-
into the evaluation environment. For consistent evaluation results, run the task with
142-
`--use_chat_template`. The OZ Eval dataset is available at https://huggingface.co/datasets/DjMel/oz-eval.
140+
The OZ Eval dataset is available at https://huggingface.co/datasets/DjMel/oz-eval.
143141
144142
"""
145143
query_template = """Pitanje: {question}\n

docs/source/use-litellm-as-backend.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ Documentation for available APIs and compatible endpoints can be found [here](ht
1212
lighteval endpoint litellm \
1313
"provider=openai,model_name=gpt-3.5-turbo" \
1414
"lighteval|gsm8k|0|0" \
15-
--use-chat-template
1615
```
1716

18-
> [!WARNING]
19-
> `--use-chat-template` is required for litellm to work properly.
20-
2117
## Using a config file
2218

2319
Litellm allows generation with any OpenAI compatible endpoint, for example you

docs/source/use-sglang-as-backend.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ model_parameters:
5252
context_length: null
5353
random_seed: 1
5454
trust_remote_code: False
55-
use_chat_template: False
5655
device: "cuda"
5756
skip_tokenizer_init: False
5857
kv_cache_dtype: "auto"

docs/source/use-vllm-as-backend.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ model_parameters:
5757
swap_space: 4
5858
seed: 1
5959
trust_remote_code: True
60-
use_chat_template: True
6160
add_special_tokens: True
6261
multichoice_continuations_start_space: True
6362
pairwise_tokenization: True
@@ -99,7 +98,6 @@ model_parameters:
9998
swap_space: 4
10099
seed: 1
101100
trust_remote_code: True
102-
use_chat_template: True
103101
add_special_tokens: True
104102
multichoice_continuations_start_space: True
105103
pairwise_tokenization: True

docs/source/using-the-python-api.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def main():
3939
model_config = VLLMModelConfig(
4040
model_name="HuggingFaceH4/zephyr-7b-beta",
4141
dtype="float16",
42-
use_chat_template=True,
4342
)
4443

4544
task = "helm|mmlu|5|1"

examples/model_configs/peft_model.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ model_parameters:
77
revision: "main" # revision to use
88
trust_remote_code: true # Trust remote code
99
model_parallel: null # Model parallel
10-
use_chat_template: true # Use chat template
1110
max_length: 2048 # maximum length of the input text and the generated text
1211

1312
# should go in generation
1413
max_generation_toks: 256 # maximum number of tokens to generate
15-
#use_chat_template: true # Use chat template
1614
batch_size: 10 # batch size to use

examples/model_configs/sglang_model_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ model_parameters:
66
context_length: null
77
random_seed: 1
88
trust_remote_code: False
9-
use_chat_template: True
109
device: "cuda"
1110
skip_tokenizer_init: False
1211
kv_cache_dtype: "auto"

examples/model_configs/transformers_model.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ model_parameters:
66
model_parallel: false
77
batch_size: 1
88
multichoice_continuations_start_space: null # If true/false, will force multiple choice continuations to start/not start with a space. If none, will do nothing
9-
use_chat_template: true
109
generation_parameters:
1110
temperature: 0.0
1211
top_p: 0.9

examples/model_configs/transformers_vlm_model.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ model_parameters:
66
model_parallel: false
77
batch_size: 1
88
use_fast_image_processor: true
9-
use_chat_template: true
109
generation_parameters:
1110
temperature: 0.0
1211
top_p: 0.9

0 commit comments

Comments
 (0)