Skip to content

Commit

Permalink
Fix context printing (#1068)
Browse files Browse the repository at this point in the history
* Fix comparison in train for hf_t5

* Add back context printing in dataloader.py
  • Loading branch information
irenedea committed Mar 27, 2024
1 parent e42ea70 commit f044d6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions llmfoundry/data/finetuning/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,15 @@ def _build_collate_fn(
1)],
skip_special_tokens=False,
clean_up_tokenization_spaces=True))
context = torch.logical_and(
batch['attention_mask'][j] == 1,
batch['labels'][j] == _HF_IGNORE_INDEX)
print(
'\033[92m{}\033[00m\n'.format('CONTEXT: '),
tokenizer.decode(batch['input_ids'][
j, torch.logical_and(is_subseq, context)],
skip_special_tokens=False,
clean_up_tokenization_spaces=True))
print(
'\033[91m{}\033[00m\n'.format('TARGET: '),
tokenizer.decode(batch['input_ids'][
Expand All @@ -569,6 +578,14 @@ def _build_collate_fn(
batch['attention_mask'][j] == 1],
skip_special_tokens=False,
clean_up_tokenization_spaces=True))
context = torch.logical_and(
batch['attention_mask'][j] == 1,
batch['labels'][j] == _HF_IGNORE_INDEX)
print(
'\033[92m{}\033[00m\n'.format('CONTEXT: '),
tokenizer.decode(batch['input_ids'][j, context],
skip_special_tokens=False,
clean_up_tokenization_spaces=True))
print(
'\033[91m{}\033[00m\n'.format('TARGET: '),
tokenizer.decode(batch['input_ids'][
Expand Down
2 changes: 1 addition & 1 deletion scripts/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def validate_config(cfg: DictConfig):
loaders.append(eval_loader)
for loader in loaders:
if loader.name == 'text':
if cfg.model.name in ['hf_t5']:
if cfg.model.name == 'hf_t5':
raise ValueError(
f'Model type "{cfg.model.name}" is not supported when using the "text " ' +\
f'dataloader. Only finetuning is supported.')
Expand Down

0 comments on commit f044d6c

Please sign in to comment.