fgg blog

Tokenization: BPE, Unigram and more

## There is more than one way to tokenize a sentence

  • word-level chunks/tokens

    • A big vocabulary is needed
    • We combine words: what exactly constitutes a word (“bachelor of science”, or isolated words)
    • Abbreviated words: “LOL”, “IMO”, are these collections of words or new words?
    • Languages that don’t segment by spaces
  • character-level chunks/tokens

    • Lack of meaning: Unlike words, characters don’t have any inherent meaning, model may lose the semantic-specific feature of words.
    • Increased input computation
    • Limits netword+k choices: It’s difficult to use architectures which process input sequentially since the input sequences will be much longer.
  • Subword-level chunks/tokens

test rendering of equations of latex in Hugo

式子能正常渲染,但需要在两个地方的下标处添加额外转义字符 \, 也就是:\mathbb{E}\_{xxx}p\_{model},其他地方却不需要 \hat{p}_{data}

$$ \mathbb{E}_{x \sim \hat{p}_{data}} {\text{log}\ p_{model} {(x^i; \theta})} $$

是因为 \mathbb{} 导致的吗?看起来不是: $$ E_{x \sim \hat{p}_{data}} {\text{log}\ p_{model} {(x^i; \theta})} $$

是因为 \text{} 导致的吗?看起来不是 (\text{log} -> \log): $$ \mathbb{E}_{x \sim \hat{p}_{data}}{\log p_{model} {(x^i; \theta})} $$

如果 \mathbb{}_ 渲染不出来,那它渲染失败是怎么样的 (下式\mathbb{}_中的_不见了):

$$ \mathbb{E}{x \sim \hat{p}{data}}{\text{log}\ p_{model} {(x^i; \theta})} $$

为什么 p_{model} 也渲染不出来, 而非要添加转意字符 p\_{model} 呢?

$$ \mathbb{E}_{x \sim \hat{p}{data}}{\text{log}\ p{model} {(x^i; \theta})} $$

$$ E_{x \sim \hat{p}{data}}{\text{log}\ p{model} {(x^i; \theta})} $$

利器4: Vim 编辑器 – 只因为在键盘之中,方向键太遥远

# Vim 初体验

“多年以后,面对显示屏,“逃离了巨硬·仍旧愤怒·懵懂菜鸟"将会回想起初次尝试 Vim 编辑器 而被困在里面叫天不应叫地不灵的那个遥远的下午”。

那时候的我(2017),是个二十多岁的青年,刚刚认识终端和 Linux 大概是怎么一回事, 感觉恰似上天给我关了那扇“窗”,自己推开了 Linux 世界的大门。 世界新生伊始,许多事物还不知其名何处,对许多“拿来主义”的命令仍旧半信半疑, 简直就是一场大冒险 (没有性命之攸的那种)。

当我发现在文本编辑器里的光标可以用 h,j,k,l 来进行左下上右移动时,“不懂,但我大受震撼”。

(其实就是见识少,不是所有键盘都有独立的方向键,更不是操作系统就只一个 windows ,不过我是二十好几的人了才知道这个事情,用于连的话讲就是:“啊,这是一场侮辱”。)

虽然第一次尝试 Vim 就被抛弃到了荒岛,好在我对这样一个新奇的世界,早有心理准备。 事实证明,要适应新环境,最好的武器不过是“一点好奇心和多点耐心”。从那以后, 感觉就好像“居住在兔子皮毛深处的微生物”竭力向毛尖爬去,“以便将魔术师看个清楚”。

终端里能用的优秀工具多得让我觉得简直“就像是在海边拣贝壳的孩子”,而 Vim 编辑器无疑是我最喜爱的那一枚。 而在海边放贝壳的无疑是那些乐于分享的同道中人,我相信真正的进步来自于分享。

后来当我大概明白 vimrc 文件是怎么一回事之后,我第一件事就是给它加上了这一句:

set mouse=

其实当时是怀着对旧日那种凡事必得“鼠标点击拖拽”宣战的忐忑心态。

后来怎么样了?

利器1: Oh, My Tmux – 键盘驱动(为主)的工作流

Tmux 是一个终端多路复用器1:…

Tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

那到底什么是“终端”terminal2 我回答不了这个问题,但我发现了一个很好的解释 – terminal

突然想起《统计学》关于“卡方检验”那一章的经典导语:

不要问它的含义,宁可问如何使用它。– 维特根斯坦

本着“拿来主义”精神,那就来粗略看看 Tmux 能如何使用吧:

IMG_MyTmux – (gif 失效)

  1. 启动 Termainal (CTRL+Enter, 这是个人定义的快捷键)

  2. 启动 Tmux 进入我的工作环境 (须知:我这里展示的不是初始化的 Tmux 启动)

  3. 检查一下昨天写的博客写到哪里了 (貌似差不多了,写其他内容)

  4. 切换到下一场“会话”(session) – vimwiki (这里是我个人项目根目录)