iTranslated by AI
Investigating GPT-4o's New Japanese Vocabulary: The Case of 'Kaze Fukeba Nanashi'
Yesterday's release of GPT-4o is attracting attention not only for its performance but also for its processing speed. This speed is likely due not only to improvements in the model's processing speed but also significantly to improvements in Japanese language processing.
In fact, according to OpenAI's site, Japanese can now be represented with 1.4x the efficiency (using 1.4x fewer tokens) on average.
This is because GPT-4o includes more Japanese in its vocabulary than GPT-4. In LLMs, vocabulary is the smallest unit of natural language processing; one vocabulary item is converted into one numerical token, which is then fed into the model.
By the way, did you know that GPT-4o treats the string '風吹けば名無し' (Kaze fukeba nanashi) as a single vocabulary item?
As introduced in this tweet, GPT-4o seems to include phrases like this that appear frequently on the internet in its vocabulary.
From a human perspective, '風吹けば名無し' would likely be broken down into '風' (wind), '吹けば' (if it blows), and '名無し' (nameless), but for GPT-4o, it seems to be perceived as a single input or a single token.
In this article, I would like to take a look at GPT-4o's vocabulary, which is slightly different from human intuition.
tiktoken
While the model weights for GPT-4 and GPT-4o are not public, the tokenizer is released comprehensively as a library called tiktoken.
Among these, the tokenizers for GPT-3.5 and GPT-4 were codenamed cl100k_base, while the GPT-4o tokenizer has been given a new codename, o200k_base.
After GPT-4 was released last year, I spent some time looking at the tiktoken repository and realized that the vocabulary list could be easily analyzed. I then stored a text file of the exported vocabulary list in the following repository.
Today, I noticed that the GPT-4o tokenizer has been updated, so I updated the repository accordingly.
I'm not actually doing anything particularly complex for the 'analysis'; you can output the vocabulary list for GPT-4o's tokenizer, o200k_base, by running the following code (I'll leave it as homework for the reader to figure out why this works).
import base64
import requests
# For cl100k_base: https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken
res = requests.get("https://openaipublic.blob.core.windows.net/encodings/o200k_base.tiktoken")
contents = res.content
for token, rank in (line.split() for line in contents.splitlines() if line):
decoded_token = base64.b64decode(token)
try:
print(repr(decoded_token.decode('utf-8')))
except:
print(decoded_token)
What kind of Japanese tokens has GPT-4o newly acquired?
Using this, you can also investigate the Japanese tokens newly added to GPT-4o. For example:
- Cases where the token contains at least one Hiragana or Katakana character
- Cases where the token consists only of Joyo Kanji (commonly used Kanji)
By listing only these, you can obtain something that looks somewhat like Japanese (of course, it is actually difficult with just this because Chinese vocabulary also gets mixed in).
Using the code below, I listed tokens that seem like Japanese added to GPT-4o, specifically those with a length of 4 or more.
import base64
import re
import requests
cl100k_base_tokens_utf8 = []
res = requests.get("https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken")
contents = res.content
for token, rank in (line.split() for line in contents.splitlines() if line):
decoded_token = base64.b64decode(token)
try:
cl100k_base_tokens_utf8.append(decoded_token.decode('utf-8'))
except:
pass
o200k_base_tokens_utf8 = []
res = requests.get("https://openaipublic.blob.core.windows.net/encodings/o200k_base.tiktoken")
contents = res.content
for token, rank in (line.split() for line in contents.splitlines() if line):
decoded_token = base64.b64decode(token)
try:
o200k_base_tokens_utf8.append(decoded_token.decode('utf-8'))
except:
pass
o200k_base_tokens_set = set(o200k_base_tokens_utf8)
cl100k_base_tokens_set = set(cl100k_base_tokens_utf8)
HIRAGANA = set([chr(i) for i in range(12353, 12436)])
KATAKANA = set([chr(i) for i in range(12449, 12532+1)])
from kanji_lists import JOYO
japanese_tokens = []
for token in o200k_base_tokens_set - cl100k_base_tokens_set:
# Add if the token contains at least one Hiragana or Katakana character
if any(char in HIRAGANA or char in KATAKANA for char in token):
japanese_tokens.append(token)
# Add if the token consists only of Joyo Kanji
if all(char in JOYO for char in token):
japanese_tokens.append(token)
# Display only tokens with 4 or more characters, sorted by string length in descending order
japanese_tokens = sorted(japanese_tokens, key=lambda x: len(x), reverse=True)
for token in japanese_tokens:
if len(token) >= 4:
print(token)
The results were as follows:
ありがとうございました
ありがとうございます
VIPがお送りします
精品一区二区三区
風吹けば名無し
スーパーコピー
がお送りします
風吹けば名無し
ご了承ください
@お腹いっぱい
夫妻性生活影片
トラックバック
在天天中彩票
プロフィール
和天天中彩票
しております
レディース
彩票平台招商
的天天中彩票
されています
名無しさん
の名無しさん
一区二区三区
福利彩票天天
中央値との差
ございました
してください
ラックバック
お願いします
お問い合わせ
植物百科通
久久久久久
名無しさん
名無しの
転載は禁止
人民共和国
@恐縮です
ありません
問い合わせ
夫妻性生活
スーパー
ブランド
続きを読む
こんばんは
的天天彩票
送りします
天天好彩票
カテゴリー
人人爽人人
天天中彩票
@おーぷん
ブラック
スポンサー
っています
になります
オンライン
コメント
しています
があります
男人的天堂
平均との差
ランキング
彩彩票平台
ございます
。しかし
有限公司
植物百科
丁香五月
この記事
彩票代理
彩票直属
株式会社
関連記事
スーパー
アクセス
レビュー
ブラック
コピー
でしょう
ーワード
天空彩票
送料無料
天天好彩
。そして
ブランド
スタッフ
はこちら
平台代理
彩票平台
名無し
ディース
しました
ています
よろしく
風吹けば
天天彩票
一区二区
博彩公司
当前位置
一肖中特
体育投注
投注平台
できます
平台直属
中国特色
中文字幕
メーカー
カテゴリ
タイトル
彩票天天
平台招商
フィール
平特一肖
久久久久
おります
生命周期
午夜福利
彩票招商
チェック
是否合法
、名無し
ッピング
福利彩票
その他
早点加盟
あります
サイズ
バッグ
メンズ
彩票主管
文章来源
クリック
五月丁香
ニュース
ケース
いました
仕事内容
いっぱい
高清毛片
ーション
恐縮です
」という
イベント
フォーム
りまして
ッション
青青草原
久久精品
手机看片
について
ちなみに
男人天堂
平台主管
営業時間
こんばん
おすすめ
シリーズ
投注技巧
体育彩票
りました
もちろん
ポイント
サービス
招商主管
ショップ
Looking at this, the Japanese vocabulary acquired by GPT-4o seems to be classified into roughly the following three categories.
1. Greetings, Politeness, and Requests
Example
ありがとうございました (Thank you very much - past)
ありがとうございます (Thank you very much - present)
ご了承ください (Please understand/be aware)
ございました (Thank you - past)
してください (Please do)
お願いします (Please/Best regards)
お問い合わせ (Inquiry)
こんばんは (Good evening)
よろしく (Best regards)
恐縮です (I am grateful/humbled)
2. Internet Slang
Example
VIPがお送りします (Brought to you by VIP [2ch/5ch])
風吹けば名無し (Kaze fukeba nanashi [NanJ nickname])
@お腹いっぱい (@Onaka ippai [Eating/Drinking board])
トラックバック (Trackback)
名無しさん (Mr. Nameless)
転載は禁止 (Reproduction prohibited)
@おーぷん (@Open [Open2ch])
3. Loanwords (Especially shopping-related)
Example
レディース (Ladies)
ランキング (Ranking)
スーパー (Super/Supermarket)
アクセス (Access)
ブランド (Brand)
スタッフ (Staff)
メーカー (Manufacturer)
カテゴリ (Category)
タイトル (Title)
ポイント (Point)
サービス (Service)
ショップ (Shop)
Thoughts
From here on, it's strictly my personal impression, but I feel that adult-related terms don't appear as tokens as much as I expected.
As those involved with Japanese LLMs might know, cleaning adult-related corpora is said to be quite difficult. Therefore, if you were to train a tokenizer naively, it wouldn't be surprising if many related tokens appeared.
However, considering that they are hardly seen in this list, it might be that they were skillfully removed from the training corpus, the token list, or handled smartly through some other means. On the other hand, since so-called four-letter words are normally included in the English token list, it might just be because the frequency of Japanese is still low even in GPT-4o.
Furthermore, OpenAI is planning to release GPT-4 Customized for Japanese, and this model might contain an even richer Japanese vocabulary. It's unclear if the tokenizer for this model will be made public, but just thinking about what kind of Japanese it might include is exciting.
I would like to continue keeping an eye on Japanese vocabulary as GPT develops further.
Discussion
「思ったよりもアダルト関係の用語がトークンとしてあまり出ていないな」あたりにめっちゃ笑っちゃいましたw
なぜならこの文章の中のリストだけを見ると、混ぜている中国語の語彙はほとんどがアダルト関係用語になってしまうからです。一見ギャンブル関係の用語なんだけど、実はそれのほとんどが中国語圏で流通している海賊版アダルトビデオについてるギャンブルサービス宣伝用語になります。なんならアダルトBBSの名前そのまま入ってますwww
本当に、GPTに何を勉強させてるのですかOpenAI w
ええ...そうなんですね。
そうすると、なおさら日本語のアダルト関係用語が少ない理由が気になりますね。🤔
香港在住の研究者、ヘンリー・ルオが投稿した興味深いブログ記事がある。ルオはさまざまな言語の最も長いGPT-4oトークンを照会し、それらが異なるテーマを持っているように見えることを発見した。ロシア語のトークンには政府や公的機関に関する言葉が反映されている一方で、日本語のトークンには「ありがとう」のさまざまな言い方がたくさん含まれている。