Find how to set arguments for backend tokenizer
- User
Find how to set arguments for backend tokenizer
Assistant
Based on the provided documentation, specifically the
TemplateAPIusage guide and theHFLMclass implementation inlm_eval/models/huggingface.py, here's how you can set arguments for the backend tokenizer:1. Using the
tokenizerargument:- When initializing a
TemplateAPIsubclass or anHFLMinstance, you can specify thetokenizerargument as a string. This string can be:- The name or path of a pretrained tokenizer.
- An already initialized tokenizer object.
- Example:
python
# For TemplateAPI based models class MyAPIModel(TemplateAPI): def __init__(self, **kwargs): super().__init__( model="my-model", base_url="https://api.mymodel.com/v1/completions", tokenizer="EleutherAI/gpt-neox-20b", tokenizer_backend="huggingface", **kwargs ) # For HuggingFace models HFLM(pretrained="gpt2", tokenizer="EleutherAI/gpt-neox-20b") - If you don't provide the
tokenizerargument, it will default to the same tokenizer name as the model.
2. Using the
tokenizer_backendargument:- You can set the
tokenizer_backendargument to specify which tokenization library to use. - Options are
"tiktoken","huggingface", orNone. - This argument is required for loglikelihood or MCQ based tasks.
- Example:
python
class MyAPIModel(TemplateAPI): def __init__(self, **kwargs): super().__init__( model="my-model", base_url="https://api.mymodel.com/v1/completions", tokenizer_backend="tiktoken", **kwargs )python
- When initializing a
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.