File size: 1,120 Bytes
751936e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d10ecd7
751936e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d10ecd7
 
751936e
 
 
 
9495a4f
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

## 词典构建

bert词典
gpt词典
gpt-neox词典

## encode


## decode

bert词典有个特殊字符 #

gpt-neox词典呢?
  - _开头表示空格或句首


## 关于分词粒度


## ss



bert-chinese  vocab_size: 21128
bert-en
clue
glm
chatglm
bloom


## bert

```
[PAD]
...
[unused99]
[UNK]
[CLS]
[SEP]
[MASK]
<S>
<T>
!
...

big
##ut
ftp
carol
##vi
```


## 

https://github.com/pytorch/fairseq/blob/master/tests/test_noising.py#L37

```
"he@@", "llo", "n@@", "ew", "y@@", "or@@", "k"
```

跟BERT类似,只不过BERT是词后缀,这里是词前缀。


## GPT2

词典见:https://huggingface.co/gpt2/raw/main/vocab.json


```
['What', "'s", 'Ġup', 'Ġwith', 'Ġthe', 'Ġtoken', 'izer', '?']
```
跟BERT不同,BERT用特殊符号表示 “连接”,GPT2用特殊符号表示 “空格”。

详见 gpt2/README.md

- 功能符号: `<|endoftext|>` 表示换行。tab? 空格?
- 很多数字独立编码,几乎上千个。

- 类似的还有:moss

## 空格、tab、换行 



## reversible and lossless

It's reversible and lossless, so you can convert tokens back into the original text