Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RoBERTa segment ids #98

Merged
merged 3 commits into from
Oct 1, 2023
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
2 changes: 1 addition & 1 deletion main/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion main/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust_tokenizers"
version = "8.1.0"
version = "8.1.1"
authors = ["Guillaume Becquin <guillaume.becquin@gmail.com>"]
edition = "2018"
description = "High performance tokenizers for Rust"
Expand Down
3 changes: 2 additions & 1 deletion main/src/tokenizer/roberta_tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ impl Tokenizer<RobertaVocab> for RobertaTokenizer {
special_tokens_mask.extend(vec![0; length]);
special_tokens_mask.push(1);
token_segment_ids.push(0);
token_segment_ids.extend(vec![1; length + 1]);
// RobERTa does not use segment id, the entire sequence is set to zeros.
token_segment_ids.extend(vec![0; length + 1]);
output.push(self.vocab.token_to_id(self.vocab.get_sep_value()));
output.extend(tokens_ids_with_offsets_2_value.ids);
output.push(self.vocab.token_to_id(self.vocab.get_sep_value()));
Expand Down
2 changes: 1 addition & 1 deletion python-bindings/tests/test_tokenization_sst2.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_tokenization_distilbert(self):

def test_tokenization_ctrl(self):
# Given
self.base_tokenizer = CTRLTokenizer.from_pretrained('ctrl',
self.base_tokenizer = CTRLTokenizer.from_pretrained('Salesforce/ctrl',
do_lower_case=True,
cache_dir=self.test_dir)
self.rust_tokenizer = PyCtrlTokenizer(
Expand Down
Loading