KoBERT 설치 후 실행 도중
get_pytorch_kobert_model() 함수를 실행중 나타난 에러입니다.
에러 내용
OSError: Not found: "C:\Users\사용자/kobert/kobert_news_wiki_ko_cased1087f8699e.spiece": Illegal byte sequence Error #42
Illegal byte sequence Error #42 관련 해결 내용은 많았지만, KoBERT 관련 내용은 찾지 못하다가 겨우 찾은 방법...
원 인
KoBERT 설치 파일 경로에 한글이 있어서 발생
해결 방법
1. kobert가 설치되어있는 파일을 찾아갑니다.
예시) C:/Users/사용자/kobert/
2. kobert_news_wiki_ko_cased-1087f8699e.spiece 파일을 한글 경로가 없는 곳으로 복사해줍니다.
예시) 한글 경로가 포함되지 않은 "C 드라이브"로 옯겨줍니다.
3. sentencepiece 라이브러리 설치 경로로 이동
저 같은 경우는 C:\ProgramData\Anaconda3\lib\site-packages\sentencepiece\__init__.py
4. __init__.py 파일을 열어서 171 라인을 수정해줍니다.
[기존]
return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
[수정]
# 예외 처리를 시켜줍니다.
try:
arg = arg.replace("\\","/") # 파일 경로 구분자를 통일시켜줍니다.
return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
except OSError:
# 2번에서 파일을 복사한 디렉터리의 경로를 path에 적어줍니다.
path = "C:/" #예시
arg = path + arg.split("/")[-1]
return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
해 결 !!
실제 SKTBrain의 KoBERT Github에도 동일한 Issue가 올라왔었고
https://github.com/SKTBrain/KoBERT/issues/47
저한테만 뜨는 에러인지 · Issue #47 · SKTBrain/KoBERT
model, vocab = get_pytorch_kobert_model() 엔터하면 OSError: Not found: "C:\Users\etfffff/kobert/kobert_news_wiki_ko_cased-1087f8699e.spiece": Illegal byte sequence Error #42 이라는 에러코드가 뜨는데요
github.com
관리하시는 개발자 분이 직접 확인 코멘트 달아주셨습니다 !!
'Python tech > NLP' 카테고리의 다른 글
[KoBERT] nlp.data.TSVDataset() 적용하기 (0) | 2021.05.18 |
---|---|
[KoBERT 에러] TypeError: dropout(): argument 'input' (position 1) must be Tensor, not str 해결 방법 (0) | 2021.05.18 |
[Python] 단어 빈도 분석 + 워드 클라우드 (0) | 2021.02.08 |
[Python] 감성 분석 결과 + 유의미한 차이인지 확인 (0) | 2021.02.07 |
[Python, keras] 딥러닝을 활용한 감성 예측 + 그래프 생성(plot) (0) | 2021.02.07 |