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

How to identify the subunits in an encoded text #72

Closed
CodingJonas opened this issue Feb 5, 2019 · 4 comments
Closed

How to identify the subunits in an encoded text #72

CodingJonas opened this issue Feb 5, 2019 · 4 comments

Comments

@CodingJonas
Copy link

CodingJonas commented Feb 5, 2019

I understand that by removing the @@ symbols I get back to the input text, but how can I identify the smallest subunits in the processed text?

If for example I have di@@ rect, How can I figure out the smallest subunits, as I understand it, it could be {di, rect}, {d, i, rect}, {d, i, re, ct} and so on, since I don'nt know which part of di and which part of rect belongs to the subunit, and which part is unknown to the tokenizer.
How do I know what part of a word which contains is part of the binary pair, and which part is the rest of the word?

I'm sorry, if I just got the overall concept wrong, but I can't figure this out.

@CodingJonas CodingJonas changed the title How to identify the subunits in a encoded text How to identify the subunits in an encoded text Feb 5, 2019
@rsennrich
Copy link
Owner

BPE always starts with a character-level segmentation so you start with {d i r e c t} and apply pairwise merge operations until you've reached the maximum number of merge operations (at training time), or until there is no more valid merge operation in your learned list (at test time).

So I'm not sure why you're asking about the smallest subunits (this is always characters). Instead, maybe you should be interested in the largest subword units that are still in-vocabulary. If your segmentation produces "di@@ rect", then "di@@" and "rect" are both in-vocabulary subword units, but "direct" is out-of-vocabulary.

@CodingJonas
Copy link
Author

Thank you for your response, you are right, it is more relevant to think about the largest subwords.

I understand your explanation. I hope I don't bother you too much with another question. Just so I get my understanding right, if the final segmentation would be di@@ rec@@ t, how would I know if rec would be the largest subunit, or could it also be re (belonging to the first binary pair di-re) and c (belonging to the second binary pair c-t), but rec is not a learned subword?

@rsennrich
Copy link
Owner

I'm not sure I get your question.

The final segmentation is produced by a greedy algorithm that iteratively applies the most frequent pairwise merge operation that has been learned on the training set. If you reach the intermediate segmentation (di - re - c - t), and di - re and c - t are the most frequent subword pairs and merged by the algorithm next (instead of re - c), the final segmentation would be dire@@ ct.

@CodingJonas
Copy link
Author

Thank you, your explanations helped me understanding how you program works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants