더북(TheBook)

코드 2-3에서 구현한 SimpleTokenizerV1과 비교해 보면 새로운 SimpleTokenizerV2는 알지 못하는 단어를 <|unk|> 토큰으로 바꿉니다.

이 새로운 토크나이저를 실제로 사용해 보죠. 서로 관련이 없는 2개의 독립된 문장을 연결한 간단한 텍스트 샘플에 사용해 보겠습니다.

text1 = "Hello, do you like tea?"
text2 = "In the sunlit terraces of the palace."
text = " <|endoftext|> ".join((text1, text2))
print(text)

출력은 다음과 같습니다.

Hello, do you like tea? <|endoftext|> In the sunlit terraces of the palace.
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.