Comments (4)
This is somehow expected.
Short answer is that U+2047 https://www.compart.com/en/unicode/U+2047 is a sort of reserved token meaning unknown.
First, we no longer know the original surface string when converting the input into id sequences.
So EncodeIds([0]) will not return "^^".
The workaround for this situation is either
- Decode 0 to "<unk>"
- Decode 0 to empty string ""
- Decode 0 to other reserved string.
We don't want to show internal representation like <unk>, as they are tricky for users. Returning empty string will make the debugging harder for developer. So we now use a special token ?? which can be interpretable both for user and developer.
Any comments for this behavior are appreciated.
It would be nicer to allow user change the behavior like --unk-surface=<unk>
Thank you.
from sentencepiece.
Thanks for clarifying.
I think that allowing the user to set this option would be great, but for now I can just replace it I guess.
One more thing that is interesting for me is why is there a trailing space in the decoded result, and a double space between the first word and the ?? special token?
>>> p.DecodeIds(p.EncodeAsIds('test ^^'))
'test \u2047 '
from sentencepiece.
I forgot to mention that the unk id (0) is decoded " ?? ", containing heading/tailing spaces.
This is because we are not sure the unknown token is either a part of word or independent token. However, it would be safer to handle it as an independent token.
from sentencepiece.
Added --unk_surface= flag to spm_train.
Note that this is not a flag of spm_encode, meaning that the unk_surface
is embedded in the model file.
from sentencepiece.
Related Issues (20)
- Evaluate Profile-Guided Optimization (PGO)
- Official support for Android compilation in Release/Assets HOT 1
- Merging tokenizers issue HOT 4
- RuntimeError HOT 1
- coredump when build with CXXFLAG `-Wp,-D_GLIBCXX_ASSERTIONS` HOT 4
- High frequency token segmented into letter sequence when input is a tsv file HOT 3
- Error while installing the library "sentence-transformers" which has dependency on "sentencepiece" HOT 11
- Getting requirements to build wheel did not run successfully. HOT 5
- Not found google.protobuf packages HOT 1
- error while installing sentencepiece python 3.12.2 HOT 2
- Many tests fail HOT 2
- entry points return non-zero exit code (at least for `--help`) HOT 2
- HELP NEEDED Mask Token in SentencePiece tokenizer HELP NEEDED HOT 1
- Sequence of byte '<0x09>' as token HOT 1
- TSV for NFC normalization HOT 1
- Allow whitespace-only pieces
- coredump when build with CXXFLAGS `-Wp,-D_GLIBCXX_ASSERTIONS`
- Only Pretokenization HOT 3
- pip subprocess to install build dependencies did not run successfully. │ exit code: 1 HOT 1
- Windows pip Dependancy Installation Error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sentencepiece.