Skip to content

Instantly share code, notes, and snippets.

@uchidama
Last active February 20, 2024 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uchidama/6f625bf8916a66c2d1df8490b043e29f to your computer and use it in GitHub Desktop.
Save uchidama/6f625bf8916a66c2d1df8490b043e29f to your computer and use it in GitHub Desktop.
wikipedia日本語データセットの読み込み
# 参考URL:
# GoogleColobで小規模言語モデル(0.15B)の事前学習モデルを作ってみる
# https://ayousanz.hatenadiary.jp/entry/2024/01/23/225623
#
'''
データセット関連の情報
https://huggingface.co/datasets/graelo/wikipedia <- 日本語データセット読める
https://huggingface.co/datasets/wikipedia <- 日本語データセット読めない
https://dumps.wikimedia.org/jawiki/
'''
'''
実行コマンド。実行時間のログをテキストに書いておく
# python3 wikipedia_jp_load.py | tee wikipedia_jp_load.txt
仮想環境の作成
# python3.11 -m venv myenv
仮想環境をアクティベート
# source myenv/bin/activate
使用後は仮想環境をデアクティベート
# deactivate
'''
# datetime モジュールをインポート
from datetime import datetime
from datasets import load_dataset
def get_current_datetime_formatted():
# 現在の日時を取得
current_datetime = datetime.now()
# 日時を「年-月-日 時:分:秒」の形式に整形
formatted_datetime = current_datetime.strftime('%Y-%m-%d %H:%M:%S')
# 整形した日時を表示
return formatted_datetime
print("start:" + get_current_datetime_formatted())
# es はスペイン語 230601.es, 230601.ja両方とも実行問題なかった
# https://huggingface.co/datasets/graelo/wikipedia
#wikipedia_es = load_dataset("graelo/wikipedia", "20230601.es", cache_dir="/Volumes/DataSets/DataSets")
#wikipedia_ja = load_dataset("graelo/wikipedia", "20230601.ja", cache_dir="/Volumes/DataSets/DataSets")
'''
実行ログ
start:2024-02-20 02:08:38
Downloading data: 100%|██████████████████████████████████████████████████████████████████████| 492/492 [00:00<00:00, 2.42MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 249M/249M [00:11<00:00, 20.7MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 248M/248M [00:11<00:00, 21.5MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 250M/250M [00:11<00:00, 21.5MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 251M/251M [00:11<00:00, 21.6MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 246M/246M [00:11<00:00, 21.6MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 246M/246M [00:12<00:00, 19.9MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 248M/248M [00:11<00:00, 21.4MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 249M/249M [00:13<00:00, 18.8MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 246M/246M [00:11<00:00, 21.0MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 250M/250M [00:16<00:00, 15.1MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 247M/247M [00:11<00:00, 21.1MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 247M/247M [00:11<00:00, 21.5MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 245M/245M [00:11<00:00, 21.9MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 248M/248M [00:11<00:00, 21.6MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 249M/249M [00:12<00:00, 20.1MB/s]
Downloading data: 100%|████████████████████████████████████████████████████████████████████| 247M/247M [00:11<00:00, 21.2MB/s]
Generating train split: 100%|█████████████████████████████████████████████| 1383531/1383531 [01:15<00:00, 18251.16 examples/s]
end:2024-02-20 02:14:12
'''
# データセットの保存先を外付けハードディスクにしているのでchache_dirを指定
wiki = load_dataset("graelo/wikipedia", "20230901.ja", cache_dir="/Volumes/DataSets/DataSets")
# なんでかわからないけど、こっちのwikipediaデータセットは日本語のデータがどうにも読めない
# graelo/wikipedia は日本語のデータが読めるので、こっちを使う
#load_dataset('wikipedia', '20220301.ja', beam_runner='DirectRunner', cache_dir="/Volumes/DataSets/DataSets")
print("end:" + get_current_datetime_formatted())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment