我有理解bpemb的encode_ids_with_eos()
或类似的问题。当我运行下面的代码时,我会得到类似于任何单词的分段(更确切地说,是基于音节的,或者是在一个看似任意的fashin中由两个字母组成的)。但这有什么用呢?在分配ids时,它是如何有用的?
print(bpemb_en.encode_ids_with_eos([" , ", ". "]))
print(bpemb_en.encode_ids([" , ", ". "] ))
print(bpemb_en.encode_with_eos([" , ", ". "] ))
print(bpemb_en.encode_with_eos(["Canvas and grouped People", ". "] ))
print(bpemb_en.encode_with_eos(["Canvas and grouped people", ". ", "I went to China to eat a roll of meat", "I am just an ordinary person"] ))
print(bpemb_en.encode_ids_with_bos_eos(["Olla , ", ". ", "_"]))
print(bpemb_en.encode_with_bos_eos(["Olla , ", ". ", "_"]))
print(bpemb_en.encode_with_bos_eos(["<PAD>", "Olla , ", ". ", "_"]))
OUTPUT:
[[912, 934, 2], [896, 2]]
[[912, 934], [896]]
[['▁', ',', '</s>'], ['▁.', '</s>']]
[['▁can', 'v', 'as', '▁and', '▁group', 'ed', '▁people', '</s>'], ['▁.', '</s>']]
[['▁can', 'v', 'as', '▁and', '▁group', 'ed', '▁people', '</s>'], ['▁.', '</s>'], ['▁i', '▁w', 'ent', '▁to', '▁ch', 'ina', '▁to', '▁e', 'at', '▁a', '▁ro', 'l', 'l', '▁of', '▁me', 'at', '</s>'], ['▁i', '▁am', '▁j', 'ust', '▁an', '▁or', 'd', 'in', 'ary', '▁pers', 'on', '</s>']]
[[1, 13, 922, 922, 914, 912, 934, 2], [1, 896, 2], [1, 912, 976, 2]]
[['<s>', '▁o', 'l', 'l', 'a', '▁', ',', '</s>'], ['<s>', '▁.', '</s>'], ['<s>', '▁', '_', '</s>']]
[['<s>', '▁', '<', 'p', 'ad', '>', '</s>'], ['<s>', '▁o', 'l', 'l', 'a', '▁', ',', '</s>'], ['<s>', '▁.', '</s>'], ['<s>', '▁', '_', '</s>']]
发布于 2022-09-04 03:16:37
句子在看似任意的标记中分组的方式是基于实例化/初始化时bpemb的词汇表大小。它们表示最频繁的字节除法。
有关解释性教程,请参见https://www.youtube.com/watch?v=HEikzVL-lZU。
https://datascience.stackexchange.com/questions/114086
复制相似问题