Skip to content

Instantly share code, notes, and snippets.

@tamuhey
Last active January 2, 2020 16:38
Show Gist options
  • Select an option

  • Save tamuhey/929c9b91bda59b288e1cafe7599b763d to your computer and use it in GitHub Desktop.

Select an option

Save tamuhey/929c9b91bda59b288e1cafe7599b763d to your computer and use it in GitHub Desktop.
tokenization alignment

2つのtokenizationのアラインメントを求めたい.

https://github.com/explosion/spacy-transformers/issues/87

stack overflowで質問した.

https://stackoverflow.com/questions/59497734/how-can-i-get-an-alignment-for-two-different-tokenizations

diffと似ていそう

つくった (Rust, Python bindingあり)
https://github.com/tamuhey/tokenizations

spacy-transformersに入れてみた

  • sum(num of wordpiece per sentence) == num of doc wordpieces とならない

制御文字が先頭に来る場合,満たされないことがあるので,正しい挙動のように思う

  • 間に制御文字が入る場合,alignmentが不連続になる

これもまあ正しい挙動のように思う.連続値が欲しいなら,補間すればよい

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment