Views
No views yet
$ pip install transformers fugashi[unidic-lite]True, it is determined that there is a utterance response relationship, and if the output is False, it is determined that there is no relationship.1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3model_path = "ganbon/novel-bert-base-relationship"
4model = AutoModelForSequenceClassification.from_pretrained(model_path, trust_remote_code=True)
5tokenizer = AutoTokenizer.from_pretrained(model_path)
6previous_sentence_list = [["「おはよう」",
7 "「おはよう。元気ですか?」",
8 "太郎が花子を気にかける。"
9 "昨日体調が悪そうだったからだ。"
10 ],
11 [
12 "「早く学校に行こうか」"
13 "「そうだね!」"
14 "そういいながら、学校に行った。",
15 "学校ではすでに次郎がいた。"
16 ]]
17next_sentence_list = ["「はい、元気です。お気遣いありがとう。」","「おはよう、次郎」"]
18for previous, next_sentence in zip(previous_sentence_list, next_sentence_list):
19 previous_sentences = "[SEP]".join(previous)
20 outputs = model(**tokenizer(previous_sentences, next_sentence, return_tensors='pt'))
21 if torch.argmax(outputs["logits"]).item() == 0:
22 print(True)
23 else:
24 print(False)@article{iwamoto-2024-novel_relation-ja,
title={小説を用いた対話コーパス構築のための言語モデルによる台詞間の発話応答関係の判定手法},
author={岩本 和真 and 安藤 一秋},
journal={人工知能学会全国大会論文集},
volume={JSAI2024},
pages={2G4GS605-2G4GS605},
year={2024},
}
@inproceedings{iwamoto-2024-novel_relation,
author = "Iwamoto, Kazuma and Ando, Kazuaki",
title = "A Method for Determining Utterance-Response Relationships Between Japanese Novel Lines for Constructing a Daily Dialogue Corpus",
booktitle = "2024 16th IIAI International Congress on Advanced Applied Informatics (IIAI-AAI)",
year = 2024,
}