New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KoBERT를 이용한 유사도 분석 #24
Comments
네.. https://github.com/SKTBrain/KoBERT/blob/master/scripts/NSMC/naver_review_classifications_pytorch_kobert.ipynb 에서 아래 코드 부분을 참고하시면 될거 같습니다. _, pooler = self.bert(input_ids = token_ids, token_type_ids = segment_ids.long(), attention_mask = attention_mask.float().to(token_ids.device)) pooler를 문장 벡터라 볼 수 있습니다. 이렇게 도출된 벡터간의 유사도를 보려면... 코사인 유사도 정도 사용하면 될듯 합니다. |
답변 감사합니다. 말씀해주신 pooler를 만들기 위해서는 token_ids, token_type_ids, attention_mask가 필요합니다. README에서 How to Use의 Using with PyTorch 부분을 참고했을 때에도 sequence_output, pooled_output을 얻기 위해 input_ids, input_mask, token_type_ids세가지를 만들어야 하는데, 예제에서는 임의로 만든 것으로 보입니다.
How to Use의 예제 결과처럼 "안녕"과 같은 특정 문장의 벡터를 보려면 input_ids, input_mask, token_type_ids 세 가지 인자를 어떻게 만들어야 하나요? |
노트북 BERTDataset에서 nlp.data.BERTSentenceTransform 를 사용하시면 됩니다. 전반적으로 하시고자 하는 작업은 노트북의 코드를 잘 분석해보시면 쉽게 가능하실거라 생각되네요. |
그렇군요. 감사합니다! |
안녕하세요. |
안녕하세요.
KoBERT에 이미 구축된 임베딩을 이용해 문장 간 유사도 분석을 하고 싶습니다.
인터넷을 사용할 수 없는 상황이라 다음과 같이 model, vocab을 로드해서 사용하고 있습니다.
분류 예제를 보아도 특정 문장을 벡터화 할 수 있는 부분을 찾기가 어려워서 글을 남깁니다.
문장을 벡터화하고 유사도를 비교할 방법이 있을까요?
The text was updated successfully, but these errors were encountered: