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

SPARKNLP-921: Bug Fix for BPE and RobertaForQA #14022

Conversation

DevinTDHa
Copy link
Member

Description

This PR introduces several fixes to produce expected behavior of RobertaForQuestionAnswering models.

Resolves #14005.

It includes the following changes:

  1. BPE Tokenizer includes a flag whether or not to always prepend a space before words (previous behavior for embeddings)
  2. BPE Tokenizer correctly converts and tokenizes non-latin other special character words
  3. RobertaForQA produces the same logits and indexes as the transformers implementation
    • Note: Spark NLP uses 1-based indexing. So to retrieve the answer strings, you have to use context.slice(start + 1, end + 1)

Motivation and Context

Users should expect the same results as their custom exported models

How Has This Been Tested?

New tests added, existing tests are passing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Code improvements with no or little impact
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING page.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@DevinTDHa DevinTDHa self-assigned this Oct 11, 2023
@maziyarpanahi maziyarpanahi changed the base branch from master to release/514-release-candidate October 26, 2023 11:31
@maziyarpanahi maziyarpanahi merged commit 9baff1d into JohnSnowLabs:release/514-release-candidate Oct 26, 2023
4 checks passed
@DevinTDHa DevinTDHa mentioned this pull request Jan 20, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unequal outputs of RobertaTokenizer from the output of RobertaTokenizer in HuggingFace
2 participants