Files
wehub-resource-sync e06fe8e8c6
Secret Leaks / trufflehog (push) Failing after 1s
Build documentation / build (push) Failing after 1s
Build documentation / build_other_lang (push) Failing after 0s
CodeQL Security Analysis / CodeQL Analysis (push) Failing after 0s
PR CI / pr-ci (push) Failing after 1s
Slow tests on important models (on Push - A10) / Get all modified files (push) Failing after 1s
Slow tests on important models (on Push - A10) / Model CI (push) Has been skipped
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Has been cancelled
New model PR merged notification / Notify new model (push) Has been cancelled
Update Transformers metadata / build_and_package (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:57:37 +08:00

2.9 KiB

일본어 BERT (BertJapanese) bertjapanese

개요 overview

일본어 문장에 학습된 BERT 모델 입니다.

각각 서로 다른 토큰화 방법을 사용하는 두 모델:

  • MeCab와 WordPiece를 사용하여 토큰화합니다. 이를 위해 추가 의존성 fugashi이 필요합니다. (이는 MeCab의 래퍼입니다.)
  • 문자 단위로 토큰화합니다.

MecabTokenizer를 사용하려면, 의존성을 설치하기 위해 pip install transformers["ja"] (또는 소스에서 설치하는 경우 pip install -e .["ja"]) 명령을 실행해야 합니다.

자세한 내용은 cl-tohoku 리포지토리에서 확인하세요.

MeCab과 WordPiece 토큰화를 사용하는 모델 예시:

>>> import torch
>>> from transformers import AutoModel, AutoTokenizer

>>> bertjapanese = AutoModel.from_pretrained("cl-tohoku/bert-base-japanese")
>>> tokenizer = AutoTokenizer.from_pretrained("cl-tohoku/bert-base-japanese")

>>> ## Input Japanese Text
>>> line = "吾輩は猫である。"

>>> inputs = tokenizer(line, return_tensors="pt")

>>> print(tokenizer.decode(inputs["input_ids"][0]))
[CLS] 吾輩    ある  [SEP]

>>> outputs = bertjapanese(**inputs)

문자 토큰화를 사용하는 모델 예시:

>>> bertjapanese = AutoModel.from_pretrained("cl-tohoku/bert-base-japanese-char")
>>> tokenizer = AutoTokenizer.from_pretrained("cl-tohoku/bert-base-japanese-char")

>>> ## Input Japanese Text
>>> line = "吾輩は猫である。"

>>> inputs = tokenizer(line, return_tensors="pt")

>>> print(tokenizer.decode(inputs["input_ids"][0]))
[CLS]         [SEP]

>>> outputs = bertjapanese(**inputs)

이는 토큰화 방법을 제외하고는 BERT와 동일합니다. API 참조 정보는 BERT 문서를 참조하세요. 이 모델은 cl-tohoku께서 기여하였습니다.

BertJapaneseTokenizer

autodoc BertJapaneseTokenizer