rasa icon indicating copy to clipboard operation
rasa copied to clipboard

Fix mixed language tokenization in JiebaTokenizer

Open lyirs opened this issue 2 months ago • 1 comments

Proposed changes:

  • Modify JiebaTokenizer.tokenize to correctly process mixed Chinese and English texts. This adjustment is aimed at resolving the issue where additional white space tokens were generated between Chinese and English tokens, which previously led to dimension mismatch errors during model training.

Detailed explanation:

  • Updated the tokenize method to skip whitespace tokens and accurately find each token's position using the text itself rather than relying solely on Jieba's output. This change helps prevent the dimension mismatch error and is a response to the issues reported in Jira as OSS-275 and OSS-539.

Benefits:

  • Prevents training errors when training data contains mixed Chinese and English languages.
  • Improves the robustness of tokenization in mixed language scenarios.

Related Jira Issues:

Status (please check what you already did):

  • [x] added some tests for the functionality
  • [ ] updated the documentation
  • [ ] updated the changelog (please check changelog for instructions)
  • [ ] reformat files using black (please check Readme for instructions)

Additional notes:

  • Further testing in different operational environments is recommended to ensure compatibility and efficiency.

lyirs avatar Apr 28 '24 09:04 lyirs

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 28 '24 09:04 CLAassistant