ghmagazine / llm-book

「大規模言語モデル入門」(技術評論社, 2023)のGitHubリポジトリ
https://gihyo.jp/book/2023/978-4-297-13633-8
Apache License 2.0
272 stars 41 forks source link

Windows環境で llm-book/livedoor-news-corpus を load_dataset()するとUnicodeDecodeError #25

Closed piyoketa closed 9 months ago

piyoketa commented 10 months ago

発生した問題

from datasets import load_dataset
dataset = load_dataset("llm-book/livedoor-news-corpus")

を実行すると以下のエラーが発生します

File ~\.cache\huggingface\modules\datasets_modules\datasets\llm-book--livedoor-news-corpus\xxxx\livedoor-news-corpus.py:91 in (.0)
     89         continue
     90     with open(file_name, "r") as f:
---> 91         d = [line.strip() for line in f]
     92         data.append(
     93             {
     94                 "url": d[0],
   (...)
     99             }
    100         )
    102 if self.config.shuffle == True:

UnicodeDecodeError: 'cp932' codec can't decode byte 0x83 in position 96: illegal multibyte sequence

解決法

livedoor-news-corpus.pyの90行目を下記に修正したところ、解決しました

with open(file_name, "r", encoding="utf-8") as f:

Kosuke-Yamada commented 9 months ago

問題の共有と解決法の提案ありがとうございます。 反映いたしました。