Compare commits
26 Commits
flan-no-bo
...
openorca
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6721baf10 | ||
|
|
33814cc94e | ||
|
|
50254a7ccc | ||
|
|
3a783c04e4 | ||
|
|
1e5014acec | ||
|
|
a10da1caff | ||
|
|
4066c78631 | ||
|
|
78a1e1fa12 | ||
|
|
bc8a2e5547 | ||
|
|
910ebe47f5 | ||
|
|
c146880a75 | ||
|
|
77bdb7d144 | ||
|
|
530809fd74 | ||
|
|
924bbfddec | ||
|
|
f150c027e3 | ||
|
|
5c39c006c9 | ||
|
|
612aabd8c4 | ||
|
|
af05883f75 | ||
|
|
05ab9092e3 | ||
|
|
7b57ed7618 | ||
|
|
3a38271276 | ||
|
|
8d20e0a3d3 | ||
|
|
de8ed229c3 | ||
|
|
478d8c7b8e | ||
|
|
645c13592c | ||
|
|
47d601fa23 |
2
.github/workflows/base.yml
vendored
2
.github/workflows/base.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
|||||||
pytorch: 2.0.0
|
pytorch: 2.0.0
|
||||||
axolotl_extras:
|
axolotl_extras:
|
||||||
- cuda: "117"
|
- cuda: "117"
|
||||||
cuda_version: 11.7.0
|
cuda_version: 11.7.1
|
||||||
python_version: "3.9"
|
python_version: "3.9"
|
||||||
pytorch: 1.13.1
|
pytorch: 1.13.1
|
||||||
axolotl_extras:
|
axolotl_extras:
|
||||||
|
|||||||
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
|||||||
pytorch: 2.0.0
|
pytorch: 2.0.0
|
||||||
axolotl_extras: gptq
|
axolotl_extras: gptq
|
||||||
- cuda: cu117
|
- cuda: cu117
|
||||||
cuda_version: 11.7.0
|
cuda_version: 11.7.1
|
||||||
python_version: "3.9"
|
python_version: "3.9"
|
||||||
pytorch: 1.13.1
|
pytorch: 1.13.1
|
||||||
axolotl_extras:
|
axolotl_extras:
|
||||||
@@ -85,7 +85,7 @@ jobs:
|
|||||||
pytorch: 2.0.0
|
pytorch: 2.0.0
|
||||||
axolotl_extras: gptq
|
axolotl_extras: gptq
|
||||||
- cuda: cu117
|
- cuda: cu117
|
||||||
cuda_version: 11.7.0
|
cuda_version: 11.7.1
|
||||||
python_version: "3.9"
|
python_version: "3.9"
|
||||||
pytorch: 1.13.1
|
pytorch: 1.13.1
|
||||||
axolotl_extras:
|
axolotl_extras:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
default_language_version:
|
default_language_version:
|
||||||
python: python3.9
|
python: python3
|
||||||
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ Have dataset(s) in one of the following format (JSONL recommended):
|
|||||||
```json
|
```json
|
||||||
{"message_1": "...", "message_2": "..."}
|
{"message_1": "...", "message_2": "..."}
|
||||||
```
|
```
|
||||||
|
- `alpaca_w_system.load_open_orca`: support for open orca datasets with included system prompts, instruct
|
||||||
|
```json
|
||||||
|
{"system_prompt": "...", "question": "...", "response": "..."}
|
||||||
|
```
|
||||||
- `context_qa`: in context question answering from an article
|
- `context_qa`: in context question answering from an article
|
||||||
```json
|
```json
|
||||||
{"article": "...", "question": "...", "answer": "..."}
|
{"article": "...", "question": "...", "answer": "..."}
|
||||||
@@ -302,6 +306,8 @@ model_type: AutoModelForCausalLM
|
|||||||
tokenizer_type: AutoTokenizer
|
tokenizer_type: AutoTokenizer
|
||||||
# Trust remote code for untrusted source
|
# Trust remote code for untrusted source
|
||||||
trust_remote_code:
|
trust_remote_code:
|
||||||
|
# use_fast option for tokenizer loading from_pretrained, default to True
|
||||||
|
tokenizer_use_fast:
|
||||||
|
|
||||||
# whether you are training a 4-bit GPTQ quantized model
|
# whether you are training a 4-bit GPTQ quantized model
|
||||||
gptq: true
|
gptq: true
|
||||||
@@ -334,6 +340,8 @@ datasets:
|
|||||||
dataset_prepared_path: data/last_run_prepared
|
dataset_prepared_path: data/last_run_prepared
|
||||||
# push prepared dataset to hub
|
# push prepared dataset to hub
|
||||||
push_dataset_to_hub: # repo path
|
push_dataset_to_hub: # repo path
|
||||||
|
# push checkpoints to hub
|
||||||
|
push_to_hub_model_id: # repo path
|
||||||
# whether to use hf `use_auth_token` for loading datasets. Useful for fetching private datasets
|
# whether to use hf `use_auth_token` for loading datasets. Useful for fetching private datasets
|
||||||
# required to be true when used in combination with `push_dataset_to_hub`
|
# required to be true when used in combination with `push_dataset_to_hub`
|
||||||
hf_use_auth_token: # boolean
|
hf_use_auth_token: # boolean
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ FROM base-builder
|
|||||||
RUN python3 -m pip uninstall -y apex
|
RUN python3 -m pip uninstall -y apex
|
||||||
RUN git clone https://github.com/NVIDIA/apex
|
RUN git clone https://github.com/NVIDIA/apex
|
||||||
# `MAX_JOBS=1` disables parallel building to avoid cpu memory OOM when building image on GitHub Action (standard) runners
|
# `MAX_JOBS=1` disables parallel building to avoid cpu memory OOM when building image on GitHub Action (standard) runners
|
||||||
RUN cd apex && MAX_JOBS=1 python3 -m pip install --global-option="--cpp_ext" --global-option="--cuda_ext" --no-cache -v --disable-pip-version-check .
|
RUN cd apex && MAX_JOBS=1 python3 -m pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" ./
|
||||||
|
|
||||||
RUN mkdir -p /workspace/builds
|
RUN mkdir -p /workspace/builds
|
||||||
COPY --from=bnb-builder /workspace/bitsandbytes /workspace/builds/bitsandbytes
|
COPY --from=bnb-builder /workspace/bitsandbytes /workspace/builds/bitsandbytes
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ class ConstantLengthDataset(IterableDataset):
|
|||||||
buffer_len = 0
|
buffer_len = 0
|
||||||
|
|
||||||
if example:
|
if example:
|
||||||
|
# FIXME
|
||||||
# just going to drop data points that are too long
|
# just going to drop data points that are too long
|
||||||
if len(example["input_ids"]) <= self.seq_length:
|
if len(example["input_ids"]) <= self.seq_length:
|
||||||
input_ids = example["input_ids"]
|
input_ids = example["input_ids"]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from axolotl.prompt_tokenizers import (
|
|||||||
AlpacaPromptTokenizingStrategy,
|
AlpacaPromptTokenizingStrategy,
|
||||||
InstructionPromptTokenizingStrategy,
|
InstructionPromptTokenizingStrategy,
|
||||||
)
|
)
|
||||||
from axolotl.prompters import AlpacaPrompter, PromptStyle
|
from axolotl.prompters import AlpacaPrompter, PromptStyle, UnpromptedPrompter
|
||||||
|
|
||||||
|
|
||||||
def load(tokenizer, cfg):
|
def load(tokenizer, cfg):
|
||||||
@@ -45,8 +45,10 @@ class NoSystemPrompter(AlpacaPrompter):
|
|||||||
Null Prompter with no system prompts
|
Null Prompter with no system prompts
|
||||||
"""
|
"""
|
||||||
|
|
||||||
prompt_input = "{instruction} {input} "
|
system_prompt = ""
|
||||||
prompt_no_input = "{instruction} "
|
system_no_input_prompt = ""
|
||||||
|
turn_format = "{instruction} {input} "
|
||||||
|
turn_no_input_format = "{instruction} "
|
||||||
|
|
||||||
def __init__(self): # pylint: disable=super-init-not-called
|
def __init__(self): # pylint: disable=super-init-not-called
|
||||||
pass
|
pass
|
||||||
@@ -103,3 +105,12 @@ def load_camel_ai(tokenizer, cfg):
|
|||||||
cfg.train_on_inputs,
|
cfg.train_on_inputs,
|
||||||
cfg.sequence_len,
|
cfg.sequence_len,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def load_no_prompt(tokenizer, cfg):
|
||||||
|
return AlpacaPromptTokenizingStrategy(
|
||||||
|
UnpromptedPrompter(PromptStyle.CHAT.value),
|
||||||
|
tokenizer,
|
||||||
|
cfg.train_on_inputs,
|
||||||
|
cfg.sequence_len,
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""Module loading the AlpacaInstructPromptTokenizingStrategy class"""
|
"""Module loading the AlpacaInstructPromptTokenizingStrategy class"""
|
||||||
|
|
||||||
from axolotl.prompt_tokenizers import AlpacaPromptTokenizingStrategy
|
from axolotl.prompt_tokenizers import AlpacaPromptTokenizingStrategy
|
||||||
from axolotl.prompters import AlpacaPrompter, PromptStyle
|
from axolotl.prompters import AlpacaPrompter, PromptStyle, UnpromptedPrompter
|
||||||
|
|
||||||
|
|
||||||
def load(tokenizer, cfg):
|
def load(tokenizer, cfg):
|
||||||
@@ -11,3 +11,12 @@ def load(tokenizer, cfg):
|
|||||||
cfg.train_on_inputs,
|
cfg.train_on_inputs,
|
||||||
cfg.sequence_len,
|
cfg.sequence_len,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def load_no_prompt(tokenizer, cfg):
|
||||||
|
return AlpacaPromptTokenizingStrategy(
|
||||||
|
UnpromptedPrompter(PromptStyle.INSTRUCT.value),
|
||||||
|
tokenizer,
|
||||||
|
cfg.train_on_inputs,
|
||||||
|
cfg.sequence_len,
|
||||||
|
)
|
||||||
|
|||||||
120
src/axolotl/prompt_strategies/alpaca_w_system.py
Normal file
120
src/axolotl/prompt_strategies/alpaca_w_system.py
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
"""
|
||||||
|
Prompt strategies loader for alpaca instruction datasets with system prompts
|
||||||
|
"""
|
||||||
|
from typing import Generator, Tuple, Union
|
||||||
|
|
||||||
|
from axolotl.prompt_tokenizers import PromptTokenizingStrategy
|
||||||
|
from axolotl.prompters import AlpacaPrompter, PromptStyle
|
||||||
|
|
||||||
|
|
||||||
|
class InstructionWSystemPromptTokenizingStrategy(PromptTokenizingStrategy):
|
||||||
|
"""
|
||||||
|
Tokenizing strategy for instruction-based prompts.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def parse_instruction_fields(self, prompt) -> Tuple[str, str, str, str]:
|
||||||
|
return (
|
||||||
|
prompt["instruction"],
|
||||||
|
prompt["input"] if "input" in prompt else "",
|
||||||
|
prompt["output"],
|
||||||
|
prompt["system"],
|
||||||
|
)
|
||||||
|
|
||||||
|
def tokenize_prompt(self, prompt):
|
||||||
|
# pylint: disable=duplicate-code
|
||||||
|
(
|
||||||
|
instruction,
|
||||||
|
input, # pylint: disable=redefined-builtin
|
||||||
|
response,
|
||||||
|
system,
|
||||||
|
) = self.parse_instruction_fields(prompt)
|
||||||
|
user_prompt = next(
|
||||||
|
iter(
|
||||||
|
self.prompter.build_prompt_w_system(
|
||||||
|
system,
|
||||||
|
instruction,
|
||||||
|
input,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
tokenized_prompt = self._tokenize(user_prompt, add_eos_token=False)
|
||||||
|
if not self.train_on_inputs:
|
||||||
|
user_prompt_len = len(tokenized_prompt["input_ids"])
|
||||||
|
# TODO this could be sped up using numpy array slicing
|
||||||
|
tokenized_prompt["labels"] = [-100] * user_prompt_len
|
||||||
|
tokenized_res_prompt = self._tokenize(
|
||||||
|
response, strip_bos_token=True, add_eos_token=True
|
||||||
|
)
|
||||||
|
tokenized_prompt["input_ids"] += tokenized_res_prompt["input_ids"]
|
||||||
|
tokenized_prompt["attention_mask"] += tokenized_res_prompt["attention_mask"]
|
||||||
|
tokenized_prompt["labels"] += tokenized_res_prompt["input_ids"]
|
||||||
|
|
||||||
|
return tokenized_prompt
|
||||||
|
|
||||||
|
|
||||||
|
class SystemDataPrompter(AlpacaPrompter):
|
||||||
|
"""
|
||||||
|
Alpaca Style Prompter that uses system prompts from the dataset
|
||||||
|
"""
|
||||||
|
|
||||||
|
def build_prompt_w_system(
|
||||||
|
self,
|
||||||
|
system: str,
|
||||||
|
instruction: str,
|
||||||
|
input: Union[None, str] = None, # pylint: disable=redefined-builtin
|
||||||
|
output: Union[None, str] = None,
|
||||||
|
) -> Generator[str, None, None]:
|
||||||
|
# returns the full prompt from instruction and optional input
|
||||||
|
# if a label (=response, =output) is provided, it's also appended.
|
||||||
|
if input:
|
||||||
|
res = system + self.turn_format.format(instruction=instruction, input=input)
|
||||||
|
else:
|
||||||
|
res = system + self.turn_no_input_format.format(instruction=instruction)
|
||||||
|
if output:
|
||||||
|
res = f"{res}{output}"
|
||||||
|
yield res
|
||||||
|
|
||||||
|
|
||||||
|
class OpenOrcaPromptTokenizingStrategy(InstructionWSystemPromptTokenizingStrategy):
|
||||||
|
"""
|
||||||
|
Tokenizing strategy for OpenOrca datasets
|
||||||
|
"""
|
||||||
|
|
||||||
|
def parse_instruction_fields(self, prompt) -> Tuple[str, str, str, str]:
|
||||||
|
return (
|
||||||
|
prompt["question"],
|
||||||
|
"",
|
||||||
|
prompt["response"],
|
||||||
|
prompt["system_prompt"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def load(tokenizer, cfg):
|
||||||
|
return load_chat(tokenizer, cfg)
|
||||||
|
|
||||||
|
|
||||||
|
def load_instruct(tokenizer, cfg):
|
||||||
|
return InstructionWSystemPromptTokenizingStrategy(
|
||||||
|
SystemDataPrompter(PromptStyle.INSTRUCT.value),
|
||||||
|
tokenizer,
|
||||||
|
cfg.train_on_inputs,
|
||||||
|
cfg.sequence_len,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def load_chat(tokenizer, cfg):
|
||||||
|
return InstructionWSystemPromptTokenizingStrategy(
|
||||||
|
SystemDataPrompter(PromptStyle.CHAT.value),
|
||||||
|
tokenizer,
|
||||||
|
cfg.train_on_inputs,
|
||||||
|
cfg.sequence_len,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def load_open_orca(tokenizer, cfg):
|
||||||
|
return OpenOrcaPromptTokenizingStrategy(
|
||||||
|
SystemDataPrompter(PromptStyle.INSTRUCT.value),
|
||||||
|
tokenizer,
|
||||||
|
cfg.train_on_inputs,
|
||||||
|
cfg.sequence_len,
|
||||||
|
)
|
||||||
@@ -87,7 +87,9 @@ class InstructionPromptTokenizingStrategy(PromptTokenizingStrategy):
|
|||||||
Tokenizing strategy for instruction-based prompts.
|
Tokenizing strategy for instruction-based prompts.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def parse_instruction_fields(self, prompt) -> Tuple[str, str, str]:
|
def parse_instruction_fields(
|
||||||
|
self, prompt
|
||||||
|
) -> Union[Tuple[str, str, str], Tuple[str, str, str, str]]:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def tokenize_prompt(self, prompt):
|
def tokenize_prompt(self, prompt):
|
||||||
@@ -438,7 +440,7 @@ def parse_tokenized_to_result(
|
|||||||
result: Dict[str, List[int]],
|
result: Dict[str, List[int]],
|
||||||
current_len: int,
|
current_len: int,
|
||||||
res: Dict[str, List[int]],
|
res: Dict[str, List[int]],
|
||||||
labels: list[int],
|
labels: List[int],
|
||||||
pad_token_id: Union[int, None] = None,
|
pad_token_id: Union[int, None] = None,
|
||||||
) -> Tuple[Dict[str, List[int]], int]:
|
) -> Tuple[Dict[str, List[int]], int]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ class AlpacaPrompter:
|
|||||||
|
|
||||||
system_prompt = "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n"
|
system_prompt = "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n"
|
||||||
system_no_input_prompt = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n"
|
system_no_input_prompt = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n"
|
||||||
|
turn_format: str
|
||||||
|
turn_no_input_format: str
|
||||||
prompt_style: Optional[PromptStyle] = None
|
prompt_style: Optional[PromptStyle] = None
|
||||||
|
|
||||||
def __init__(self, prompt_style=PromptStyle.INSTRUCT.value):
|
def __init__(self, prompt_style=PromptStyle.INSTRUCT.value):
|
||||||
@@ -32,23 +34,13 @@ class AlpacaPrompter:
|
|||||||
|
|
||||||
def match_prompt_style(self):
|
def match_prompt_style(self):
|
||||||
if self.prompt_style == PromptStyle.INSTRUCT.value:
|
if self.prompt_style == PromptStyle.INSTRUCT.value:
|
||||||
self.prompt_input = (
|
self.turn_format = "### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
|
||||||
self.system_prompt
|
self.turn_no_input_format = (
|
||||||
+ "### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
|
"### Instruction:\n{instruction}\n\n### Response:\n"
|
||||||
)
|
)
|
||||||
self.prompt_no_input = (
|
|
||||||
self.system_no_input_prompt
|
|
||||||
+ "### Instruction:\n{instruction}\n\n### Response:\n"
|
|
||||||
)
|
|
||||||
self.response_split = "### Response:"
|
|
||||||
if self.prompt_style == PromptStyle.CHAT.value:
|
if self.prompt_style == PromptStyle.CHAT.value:
|
||||||
self.prompt_input = (
|
self.turn_format = "USER: {instruction}\n{input}\nASSISTANT:"
|
||||||
self.system_prompt + "USER: {instruction}\n{input}\nASSISTANT:"
|
self.turn_no_input_format = "USER: {instruction}\nASSISTANT:"
|
||||||
)
|
|
||||||
self.prompt_no_input = (
|
|
||||||
self.system_no_input_prompt + "USER: {instruction}\nASSISTANT:"
|
|
||||||
)
|
|
||||||
self.response_split = "ASSISTANT:"
|
|
||||||
|
|
||||||
def build_prompt(
|
def build_prompt(
|
||||||
self,
|
self,
|
||||||
@@ -59,16 +51,17 @@ class AlpacaPrompter:
|
|||||||
# returns the full prompt from instruction and optional input
|
# returns the full prompt from instruction and optional input
|
||||||
# if a label (=response, =output) is provided, it's also appended.
|
# if a label (=response, =output) is provided, it's also appended.
|
||||||
if input:
|
if input:
|
||||||
res = self.prompt_input.format(instruction=instruction, input=input)
|
res = self.system_prompt + self.turn_format.format(
|
||||||
|
instruction=instruction, input=input
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
res = self.prompt_no_input.format(instruction=instruction)
|
res = self.system_no_input_prompt + self.turn_no_input_format.format(
|
||||||
|
instruction=instruction
|
||||||
|
)
|
||||||
if output:
|
if output:
|
||||||
res = f"{res}{output}"
|
res = f"{res}{output}"
|
||||||
yield res
|
yield res
|
||||||
|
|
||||||
def get_response(self, output: str) -> str:
|
|
||||||
return output.split(self.response_split)[1].strip()
|
|
||||||
|
|
||||||
|
|
||||||
class UnpromptedPrompter(AlpacaPrompter):
|
class UnpromptedPrompter(AlpacaPrompter):
|
||||||
"""
|
"""
|
||||||
@@ -93,7 +86,10 @@ class MultipleChoiceExplainPrompter(AlpacaPrompter):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
system_prompt = (
|
system_prompt = (
|
||||||
"Choose the answer that best answers the question. Explain your reasoning."
|
"Choose the answer that best answers the question. Explain your reasoning.\n"
|
||||||
|
)
|
||||||
|
system_no_input_prompt = (
|
||||||
|
"Choose the answer that best answers the question. Explain your reasoning.\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +98,12 @@ class MultipleChoiceConcisePrompter(AlpacaPrompter):
|
|||||||
Prompter for multiple choice concise
|
Prompter for multiple choice concise
|
||||||
"""
|
"""
|
||||||
|
|
||||||
prompt_input = "Choose the answer that best answers the question. Be concise in your response.\n\nUSER: {instruction}\n{input}\nASSISTANT:\n"
|
system_prompt = "Choose the answer that best answers the question. Be concise in your response.\n\n"
|
||||||
|
system_no_input_prompt = "Choose the answer that best answers the question. Be concise in your response.\n\n"
|
||||||
|
|
||||||
|
def match_prompt_style(self):
|
||||||
|
self.turn_format = "USER: {instruction}\n{input}\nASSISTANT:"
|
||||||
|
self.turn_no_input_format = "USER: {instruction}\nASSISTANT:"
|
||||||
|
|
||||||
|
|
||||||
class SummarizeTLDRPrompter(AlpacaPrompter):
|
class SummarizeTLDRPrompter(AlpacaPrompter):
|
||||||
@@ -110,9 +111,12 @@ class SummarizeTLDRPrompter(AlpacaPrompter):
|
|||||||
Prompter for summarize TLDR
|
Prompter for summarize TLDR
|
||||||
"""
|
"""
|
||||||
|
|
||||||
prompt_no_input = (
|
system_prompt = ""
|
||||||
"USER: Summarize the following article as a TL;DR.\n{instruction}\nASSISTANT:"
|
system_no_input_prompt = ""
|
||||||
)
|
|
||||||
|
def match_prompt_style(self):
|
||||||
|
self.turn_format = "USER: Summarize the following article as a TL;DR.\n{instruction}\n{input}\nASSISTANT:"
|
||||||
|
self.turn_no_input_format = "USER: Summarize the following article as a TL;DR.\n{instruction}\nASSISTANT:"
|
||||||
|
|
||||||
|
|
||||||
class CompletionPrompter:
|
class CompletionPrompter:
|
||||||
@@ -128,9 +132,6 @@ class CompletionPrompter:
|
|||||||
) -> Generator[str, None, None]:
|
) -> Generator[str, None, None]:
|
||||||
yield instruction
|
yield instruction
|
||||||
|
|
||||||
def get_response(self, output: str) -> str:
|
|
||||||
return output.strip()
|
|
||||||
|
|
||||||
|
|
||||||
class GPTeacherPrompter(AlpacaPrompter):
|
class GPTeacherPrompter(AlpacaPrompter):
|
||||||
"""
|
"""
|
||||||
@@ -210,9 +211,6 @@ class ReflectAlpacaPrompter:
|
|||||||
res = f"{res}{label}"
|
res = f"{res}{label}"
|
||||||
yield res
|
yield res
|
||||||
|
|
||||||
def get_response(self, output: str) -> str:
|
|
||||||
return output.split(self.response_split)[1].strip()
|
|
||||||
|
|
||||||
|
|
||||||
class SeparatorStyle(Enum):
|
class SeparatorStyle(Enum):
|
||||||
"""Different separator style."""
|
"""Different separator style."""
|
||||||
@@ -289,12 +287,6 @@ class ShareGPTPrompter: # pylint: disable=too-few-public-methods
|
|||||||
sep2=" ",
|
sep2=" ",
|
||||||
)
|
)
|
||||||
|
|
||||||
# def match_prompt_style(self):
|
|
||||||
# if self.prompt_style == PromptStyle.chat.value:
|
|
||||||
# self.prompt_input = self.system_prompt + "USER: {instruction}\n{input}\nASSISTANT:"
|
|
||||||
# self.prompt_no_input = self.system_no_input_prompt + "USER: {instruction}\nASSISTANT:"
|
|
||||||
# self.response_split = "ASSISTANT:"
|
|
||||||
|
|
||||||
def build_prompt(self, source) -> Generator[str, None, None]:
|
def build_prompt(self, source) -> Generator[str, None, None]:
|
||||||
# ignore the system prompt if provided
|
# ignore the system prompt if provided
|
||||||
if source[0]["from"] == "system":
|
if source[0]["from"] == "system":
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ from axolotl.prompters import (
|
|||||||
|
|
||||||
|
|
||||||
def load_tokenized_prepared_datasets(
|
def load_tokenized_prepared_datasets(
|
||||||
tokenizer, cfg, default_dataset_prepared_path
|
split, tokenizer, cfg, default_dataset_prepared_path
|
||||||
) -> DatasetDict:
|
) -> DatasetDict:
|
||||||
tokenizer_name = tokenizer.__class__.__name__
|
tokenizer_name = tokenizer.__class__.__name__
|
||||||
ds_hash = str(
|
ds_hash = str(
|
||||||
@@ -49,6 +49,8 @@ def load_tokenized_prepared_datasets(
|
|||||||
sorted([f"{d.path}:{d.type}:{d.shards}" for d in cfg.datasets])
|
sorted([f"{d.path}:{d.type}:{d.shards}" for d in cfg.datasets])
|
||||||
)
|
)
|
||||||
+ "|"
|
+ "|"
|
||||||
|
+ split
|
||||||
|
+ "|"
|
||||||
+ tokenizer_name
|
+ tokenizer_name
|
||||||
).encode("utf-8")
|
).encode("utf-8")
|
||||||
).hexdigest()
|
).hexdigest()
|
||||||
@@ -66,7 +68,7 @@ def load_tokenized_prepared_datasets(
|
|||||||
f"{cfg.push_dataset_to_hub}/{ds_hash}",
|
f"{cfg.push_dataset_to_hub}/{ds_hash}",
|
||||||
use_auth_token=use_auth_token,
|
use_auth_token=use_auth_token,
|
||||||
)
|
)
|
||||||
dataset = dataset["train"]
|
dataset = dataset[split]
|
||||||
except Exception: # pylint: disable=broad-except # nosec
|
except Exception: # pylint: disable=broad-except # nosec
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -134,8 +136,8 @@ def load_tokenized_prepared_datasets(
|
|||||||
raise ValueError("unhandled dataset load")
|
raise ValueError("unhandled dataset load")
|
||||||
# support for using a subset of the data
|
# support for using a subset of the data
|
||||||
if d.shards:
|
if d.shards:
|
||||||
if "train" in ds:
|
if split in ds:
|
||||||
ds = ds.shuffle(seed=seed)["train"].shard(
|
ds = ds.shuffle(seed=seed)[split].shard(
|
||||||
num_shards=d.shards, index=0
|
num_shards=d.shards, index=0
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -144,8 +146,8 @@ def load_tokenized_prepared_datasets(
|
|||||||
d_type_split = d_type.split(":")
|
d_type_split = d_type.split(":")
|
||||||
d_base_type = d_type_split[0]
|
d_base_type = d_type_split[0]
|
||||||
d_prompt_style = d_type_split[1] if len(d_type_split) > 1 else None
|
d_prompt_style = d_type_split[1] if len(d_type_split) > 1 else None
|
||||||
if "train" in ds:
|
if split in ds:
|
||||||
ds = ds["train"]
|
ds = ds[split]
|
||||||
if ds_strategy := load(d.type, tokenizer, cfg):
|
if ds_strategy := load(d.type, tokenizer, cfg):
|
||||||
ds_wrapper = TokenizedPromptDataset(ds_strategy, ds)
|
ds_wrapper = TokenizedPromptDataset(ds_strategy, ds)
|
||||||
datasets.append(ds_wrapper)
|
datasets.append(ds_wrapper)
|
||||||
@@ -319,7 +321,6 @@ def load_prepare_datasets(
|
|||||||
f"{cfg.push_dataset_to_hub}/{ds_hash}",
|
f"{cfg.push_dataset_to_hub}/{ds_hash}",
|
||||||
use_auth_token=use_auth_token,
|
use_auth_token=use_auth_token,
|
||||||
)
|
)
|
||||||
dataset = dataset["train"]
|
|
||||||
except Exception: # pylint: disable=broad-except # nosec
|
except Exception: # pylint: disable=broad-except # nosec
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -339,28 +340,37 @@ def load_prepare_datasets(
|
|||||||
f"{cfg.push_dataset_to_hub}/{ds_hash}", private=True
|
f"{cfg.push_dataset_to_hub}/{ds_hash}", private=True
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
dataset = load_tokenized_prepared_datasets(
|
dataset_train = load_tokenized_prepared_datasets(
|
||||||
tokenizer, cfg, default_dataset_prepared_path
|
"train", tokenizer, cfg, default_dataset_prepared_path
|
||||||
)
|
)
|
||||||
|
dataset_test = load_tokenized_prepared_datasets(
|
||||||
|
"test", tokenizer, cfg, default_dataset_prepared_path
|
||||||
|
)
|
||||||
|
dataset = DatasetDict({"train": dataset_train, "test": dataset_test})
|
||||||
if cfg.seed:
|
if cfg.seed:
|
||||||
dataset = dataset.shuffle(seed=cfg.seed)
|
dataset = dataset.shuffle(seed=cfg.seed)
|
||||||
|
|
||||||
constant_len_dataset = ConstantLengthDataset(
|
constant_len_dataset_train = ConstantLengthDataset(
|
||||||
tokenizer,
|
tokenizer,
|
||||||
[dataset],
|
[dataset["train"]],
|
||||||
|
seq_length=max_packed_sequence_len,
|
||||||
|
)
|
||||||
|
constant_len_dataset_test = ConstantLengthDataset(
|
||||||
|
tokenizer,
|
||||||
|
[dataset["test"]],
|
||||||
seq_length=max_packed_sequence_len,
|
seq_length=max_packed_sequence_len,
|
||||||
)
|
)
|
||||||
logging.info(
|
logging.info(
|
||||||
f"packing master dataset to len: {cfg.max_packed_sequence_len}"
|
f"packing master dataset to len: {cfg.max_packed_sequence_len}"
|
||||||
)
|
)
|
||||||
dataset = Dataset.from_list(list(constant_len_dataset))
|
dataset_train = Dataset.from_list(list(constant_len_dataset_train))
|
||||||
|
dataset_test = Dataset.from_list(list(constant_len_dataset_test))
|
||||||
|
|
||||||
# filter out bad data
|
# filter out bad data
|
||||||
dataset = Dataset.from_list(
|
dataset_train = Dataset.from_list(
|
||||||
[
|
[
|
||||||
d
|
d
|
||||||
for d in dataset
|
for d in dataset_train
|
||||||
if len(d["input_ids"]) < cfg.sequence_len
|
if len(d["input_ids"]) < cfg.sequence_len
|
||||||
and len(d["input_ids"]) > 0
|
and len(d["input_ids"]) > 0
|
||||||
and len(d["input_ids"]) == len(d["attention_mask"])
|
and len(d["input_ids"]) == len(d["attention_mask"])
|
||||||
@@ -368,6 +378,19 @@ def load_prepare_datasets(
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# filter out bad data
|
||||||
|
dataset_test = Dataset.from_list(
|
||||||
|
[
|
||||||
|
d
|
||||||
|
for d in dataset_test
|
||||||
|
if len(d["input_ids"]) < cfg.sequence_len
|
||||||
|
and len(d["input_ids"]) > 0
|
||||||
|
and len(d["input_ids"]) == len(d["attention_mask"])
|
||||||
|
and len(d["input_ids"]) == len(d["labels"])
|
||||||
|
]
|
||||||
|
)
|
||||||
|
dataset = DatasetDict({"train": dataset_train, "test": dataset_test})
|
||||||
|
|
||||||
if cfg.local_rank == 0:
|
if cfg.local_rank == 0:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Saving packed prepared dataset to disk... {prepared_ds_path}"
|
f"Saving packed prepared dataset to disk... {prepared_ds_path}"
|
||||||
@@ -382,9 +405,14 @@ def load_prepare_datasets(
|
|||||||
private=True,
|
private=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
# dataset_train = load_tokenized_prepared_datasets(
|
||||||
dataset = load_tokenized_prepared_datasets(
|
dataset = load_tokenized_prepared_datasets(
|
||||||
tokenizer, cfg, default_dataset_prepared_path
|
"train", tokenizer, cfg, default_dataset_prepared_path
|
||||||
)
|
)
|
||||||
|
# dataset_test = load_tokenized_prepared_datasets(
|
||||||
|
# "test", tokenizer, cfg, default_dataset_prepared_path
|
||||||
|
# )
|
||||||
|
# dataset = DatasetDict({"train": dataset_train, "test": dataset_test})
|
||||||
|
|
||||||
if cfg.dataset_shard_num and cfg.dataset_shard_idx is not None:
|
if cfg.dataset_shard_num and cfg.dataset_shard_idx is not None:
|
||||||
logging.info(
|
logging.info(
|
||||||
@@ -399,6 +427,9 @@ def load_prepare_datasets(
|
|||||||
dataset = dataset.train_test_split(test_size=cfg.val_set_size, shuffle=False)
|
dataset = dataset.train_test_split(test_size=cfg.val_set_size, shuffle=False)
|
||||||
train_dataset = dataset["train"]
|
train_dataset = dataset["train"]
|
||||||
eval_dataset = dataset["test"]
|
eval_dataset = dataset["test"]
|
||||||
|
elif "train" in dataset:
|
||||||
|
train_dataset = dataset["train"]
|
||||||
|
eval_dataset = dataset["test"]
|
||||||
else:
|
else:
|
||||||
train_dataset = dataset
|
train_dataset = dataset
|
||||||
eval_dataset = None
|
eval_dataset = None
|
||||||
|
|||||||
@@ -34,15 +34,20 @@ def load_tokenizer(
|
|||||||
tokenizer_type,
|
tokenizer_type,
|
||||||
cfg,
|
cfg,
|
||||||
):
|
):
|
||||||
|
use_fast = True # this is the default
|
||||||
|
if cfg.tokenizer_use_fast is not None:
|
||||||
|
use_fast = cfg.tokenizer_use_fast
|
||||||
if tokenizer_type:
|
if tokenizer_type:
|
||||||
tokenizer = getattr(transformers, tokenizer_type).from_pretrained(
|
tokenizer = getattr(transformers, tokenizer_type).from_pretrained(
|
||||||
tokenizer_config,
|
tokenizer_config,
|
||||||
trust_remote_code=cfg.trust_remote_code or False,
|
trust_remote_code=cfg.trust_remote_code or False,
|
||||||
|
use_fast=use_fast,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
tokenizer = AutoTokenizer.from_pretrained(
|
tokenizer = AutoTokenizer.from_pretrained(
|
||||||
tokenizer_config,
|
tokenizer_config,
|
||||||
trust_remote_code=cfg.trust_remote_code or False,
|
trust_remote_code=cfg.trust_remote_code or False,
|
||||||
|
use_fast=use_fast,
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.debug(f"EOS: {tokenizer.eos_token_id} / {tokenizer.eos_token}")
|
logging.debug(f"EOS: {tokenizer.eos_token_id} / {tokenizer.eos_token}")
|
||||||
|
|||||||
@@ -34,3 +34,5 @@ def check_example_labels(example, tokenizer):
|
|||||||
|
|
||||||
logging.info(" ".join(colored_tokens))
|
logging.info(" ".join(colored_tokens))
|
||||||
logging.info("\n\n\n")
|
logging.info("\n\n\n")
|
||||||
|
|
||||||
|
return " ".join(colored_tokens)
|
||||||
|
|||||||
@@ -124,6 +124,10 @@ def setup_trainer(cfg, train_dataset, eval_dataset, model, tokenizer):
|
|||||||
if cfg.max_grad_norm:
|
if cfg.max_grad_norm:
|
||||||
training_arguments_kwargs["max_grad_norm"] = cfg.max_grad_norm
|
training_arguments_kwargs["max_grad_norm"] = cfg.max_grad_norm
|
||||||
|
|
||||||
|
if cfg.push_to_hub_model_id:
|
||||||
|
training_arguments_kwargs["push_to_hub_model_id"] = cfg.push_to_hub_model_id
|
||||||
|
training_arguments_kwargs["push_to_hub"] = True
|
||||||
|
|
||||||
training_args = transformers.TrainingArguments(
|
training_args = transformers.TrainingArguments(
|
||||||
per_device_train_batch_size=cfg.micro_batch_size,
|
per_device_train_batch_size=cfg.micro_batch_size,
|
||||||
per_device_eval_batch_size=cfg.eval_batch_size
|
per_device_eval_batch_size=cfg.eval_batch_size
|
||||||
@@ -133,9 +137,9 @@ def setup_trainer(cfg, train_dataset, eval_dataset, model, tokenizer):
|
|||||||
eval_accumulation_steps=cfg.gradient_accumulation_steps,
|
eval_accumulation_steps=cfg.gradient_accumulation_steps,
|
||||||
num_train_epochs=cfg.num_epochs,
|
num_train_epochs=cfg.num_epochs,
|
||||||
learning_rate=cfg.learning_rate,
|
learning_rate=cfg.learning_rate,
|
||||||
evaluation_strategy="steps" if cfg.val_set_size > 0 else "no",
|
evaluation_strategy="steps",
|
||||||
save_strategy="steps" if cfg.save_steps else "epoch",
|
save_strategy="steps" if cfg.save_steps else "epoch",
|
||||||
eval_steps=cfg.eval_steps if cfg.val_set_size > 0 else None,
|
eval_steps=cfg.eval_steps,
|
||||||
save_steps=cfg.save_steps,
|
save_steps=cfg.save_steps,
|
||||||
output_dir=cfg.output_dir,
|
output_dir=cfg.output_dir,
|
||||||
save_total_limit=3,
|
save_total_limit=3,
|
||||||
|
|||||||
@@ -7,11 +7,15 @@ from pathlib import Path
|
|||||||
from transformers import AutoTokenizer
|
from transformers import AutoTokenizer
|
||||||
|
|
||||||
from axolotl.prompt_strategies.alpaca_chat import NoSystemPrompter
|
from axolotl.prompt_strategies.alpaca_chat import NoSystemPrompter
|
||||||
|
from axolotl.prompt_strategies.alpaca_w_system import (
|
||||||
|
InstructionWSystemPromptTokenizingStrategy,
|
||||||
|
SystemDataPrompter,
|
||||||
|
)
|
||||||
from axolotl.prompt_tokenizers import (
|
from axolotl.prompt_tokenizers import (
|
||||||
AlpacaPromptTokenizingStrategy,
|
AlpacaPromptTokenizingStrategy,
|
||||||
ShareGPTPromptTokenizingStrategy,
|
ShareGPTPromptTokenizingStrategy,
|
||||||
)
|
)
|
||||||
from axolotl.prompters import AlpacaPrompter, ShareGPTPrompter
|
from axolotl.prompters import AlpacaPrompter, PromptStyle, ShareGPTPrompter
|
||||||
|
|
||||||
logging.basicConfig(level="INFO")
|
logging.basicConfig(level="INFO")
|
||||||
|
|
||||||
@@ -96,5 +100,39 @@ class TestPromptTokenizationStrategies(unittest.TestCase):
|
|||||||
assert example["labels"][world_idx - 1] == -100
|
assert example["labels"][world_idx - 1] == -100
|
||||||
|
|
||||||
|
|
||||||
|
class InstructionWSystemPromptTokenizingStrategyTest(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Test class for prompt tokenization strategies with sys prompt from the dataset
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setUp(self) -> None:
|
||||||
|
# pylint: disable=duplicate-code
|
||||||
|
self.tokenizer = AutoTokenizer.from_pretrained("huggyllama/llama-7b")
|
||||||
|
self.tokenizer.add_special_tokens(
|
||||||
|
{
|
||||||
|
"bos_token": "<s>",
|
||||||
|
"eos_token": "</s>",
|
||||||
|
"unk_token": "<unk>",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_system_alpaca(self):
|
||||||
|
prompter = SystemDataPrompter(PromptStyle.CHAT.value)
|
||||||
|
strat = InstructionWSystemPromptTokenizingStrategy(
|
||||||
|
prompter,
|
||||||
|
self.tokenizer,
|
||||||
|
False,
|
||||||
|
2048,
|
||||||
|
)
|
||||||
|
sample = {
|
||||||
|
"system": "use cot",
|
||||||
|
"instruction": "hello!",
|
||||||
|
"output": "Hi! How can I help?",
|
||||||
|
}
|
||||||
|
example = strat.tokenize_prompt(sample)
|
||||||
|
assert example["input_ids"][0:3] == [1, 671, 20118] # <s>use cot
|
||||||
|
assert example["input_ids"][3] == 11889 # USER
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
@@ -2,7 +2,13 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from axolotl.prompters import AlpacaPrompter, PromptStyle
|
from axolotl.prompt_strategies.alpaca_w_system import SystemDataPrompter
|
||||||
|
from axolotl.prompters import (
|
||||||
|
AlpacaPrompter,
|
||||||
|
MultipleChoiceExplainPrompter,
|
||||||
|
PromptStyle,
|
||||||
|
UnpromptedPrompter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AlpacaPrompterTest(unittest.TestCase):
|
class AlpacaPrompterTest(unittest.TestCase):
|
||||||
@@ -55,3 +61,64 @@ class AlpacaPrompterTest(unittest.TestCase):
|
|||||||
assert "### Response:" not in res
|
assert "### Response:" not in res
|
||||||
assert "USER:" in res
|
assert "USER:" in res
|
||||||
assert "ASSISTANT:" in res
|
assert "ASSISTANT:" in res
|
||||||
|
|
||||||
|
def test_system_prompt(self):
|
||||||
|
prompter = SystemDataPrompter(prompt_style=PromptStyle.CHAT.value)
|
||||||
|
res = next(
|
||||||
|
prompter.build_prompt_w_system(
|
||||||
|
"use cot", "tell me a joke about the following", "alpacas"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
assert "use cot" in res
|
||||||
|
assert res.startswith("use cot")
|
||||||
|
assert "### Instruction:" not in res
|
||||||
|
assert "### Input:" not in res
|
||||||
|
assert "alpacas" in res
|
||||||
|
assert "### Response:" not in res
|
||||||
|
assert "USER:" in res
|
||||||
|
assert "ASSISTANT:" in res
|
||||||
|
|
||||||
|
|
||||||
|
class UnpromptedPrompterTest(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Test class for UnpromptedPrompter with no system prompts
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_prompt_style_w_none(self):
|
||||||
|
prompter = UnpromptedPrompter(prompt_style=None)
|
||||||
|
res = next(prompter.build_prompt("tell me a joke"))
|
||||||
|
assert "### Instruction:" in res
|
||||||
|
assert "tell me a joke" in res
|
||||||
|
assert res.startswith("###")
|
||||||
|
|
||||||
|
def test_prompt_style_w_instruct(self):
|
||||||
|
prompter = UnpromptedPrompter(prompt_style=PromptStyle.INSTRUCT.value)
|
||||||
|
res = next(
|
||||||
|
prompter.build_prompt("tell me a joke about the following", "alpacas")
|
||||||
|
)
|
||||||
|
assert "### Instruction:" in res
|
||||||
|
assert "tell me a joke" in res
|
||||||
|
assert res.startswith("###")
|
||||||
|
|
||||||
|
def test_prompt_style_w_chat(self):
|
||||||
|
prompter = UnpromptedPrompter(prompt_style=PromptStyle.CHAT.value)
|
||||||
|
res = next(
|
||||||
|
prompter.build_prompt("tell me a joke about the following", "alpacas")
|
||||||
|
)
|
||||||
|
assert "USER:" in res
|
||||||
|
assert "tell me a joke" in res
|
||||||
|
assert res.startswith("USER:")
|
||||||
|
|
||||||
|
|
||||||
|
class MultipleChoiceExplainPrompterTest(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Test class for MultipleChoiceExplainPrompter
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_prompt_style_w_chat(self):
|
||||||
|
prompter = MultipleChoiceExplainPrompter(prompt_style=PromptStyle.CHAT.value)
|
||||||
|
res = next(prompter.build_prompt("choose one", "- A\n- B\n- C", "C"))
|
||||||
|
assert "USER:" in res
|
||||||
|
assert "choose one" in res
|
||||||
|
assert "Choose the answer that best answers the question." in res
|
||||||
|
assert "- A\n- B\n- C" in res
|
||||||
|
|||||||
31
tests/test_tokenizers.py
Normal file
31
tests/test_tokenizers.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
"""
|
||||||
|
Test cases for the tokenizer loading
|
||||||
|
"""
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from axolotl.utils.dict import DictDefault
|
||||||
|
from axolotl.utils.models import load_tokenizer
|
||||||
|
|
||||||
|
|
||||||
|
class TestTokenizers(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
test class for the load_tokenizer fn
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_default_use_fast(self):
|
||||||
|
cfg = DictDefault({})
|
||||||
|
tokenizer = load_tokenizer("huggyllama/llama-7b", None, cfg)
|
||||||
|
assert "Fast" in tokenizer.__class__.__name__
|
||||||
|
|
||||||
|
def test_dont_use_fast(self):
|
||||||
|
cfg = DictDefault(
|
||||||
|
{
|
||||||
|
"tokenizer_use_fast": False,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
tokenizer = load_tokenizer("huggyllama/llama-7b", None, cfg)
|
||||||
|
assert "Fast" not in tokenizer.__class__.__name__
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user