Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

[NeuralChat] Use unk token instead of eos token #1198

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,10 @@ def preprocess_v1(
# Mask targets
sep = conv.sep + conv.roles[1] + ": "
for conversation, target in zip(conversations, targets):
# total_len = int(target.ne(tokenizer.pad_token_id).sum())
total_len = int(target.ne(tokenizer.pad_token_id).sum())

rounds = conversation.split(conv.sep2)

total_len = int(target.ne(tokenizer.pad_token_id).sum()) + \
len([rou for rou in rounds if rou != ""])

cur_len = 1
target[:cur_len] = IGNORE_INDEX
for i, rou in enumerate(rounds):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def make_inputs_require_grad(module, input, output):
use_fast=use_fast
)

tokenizer.pad_token = tokenizer.eos_token
tokenizer.pad_token = tokenizer.unk_token

# set vision module
model.get_model().initialize_vision_modules(
Expand Down
Loading