🚀 Dragon-multiturn
Dragon-multiturnは、会話型QAシナリオに特化したリトリーバーです。対話履歴と現在のクエリを組み合わせた会話型クエリを処理することができます。このモデルはDragonリトリーバーをベースに構築されています。Dragon-multiturnの詳細については、こちらを参照してください。
🚀 クイックスタート
このセクションでは、Dragon-multiturnの基本的な使い方を説明します。
✨ 主な機能
- 会話型QAシナリオに特化した設計
- 対話履歴と現在のクエリを組み合わせた会話型クエリの処理
- デュアルエンコーダ構造(クエリエンコーダとコンテキストエンコーダ)
📚 詳細ドキュメント
モデルの説明
Dragon-multiturnは、会話型QAシナリオに特化したリトリーバーです。これは、対話履歴と現在のクエリを組み合わせた会話型クエリを処理することができます。このモデルはDragonリトリーバーをベースに構築されています。
注意: Dragon-multiturnは、クエリエンコーダとコンテキストエンコーダから構成されるデュアルエンコーダです。このリポジトリは、クエリ埋め込みを取得するためのDragon-multiturnのクエリエンコーダのみを対象としています。コンテキスト埋め込みを取得するには、コンテキストエンコーダも必要です。コンテキストエンコーダはこちらで見つけることができます。クエリエンコーダとコンテキストエンコーダは同じトークナイザーを共有しています。
その他のリソース
ベンチマーク結果
|
平均 |
|
Doc2Dial |
|
QuAC |
|
QReCC |
|
TopiOCQA |
|
INSCIT |
|
|
top-1 |
top-5 |
top-1 |
top-5 |
top-1 |
top-5 |
top-1 |
top-5 |
top-5* |
top-20* |
top-5* |
top-20* |
Dragon |
46.3 |
73.1 |
43.3 |
75.6 |
56.8 |
82.9 |
46.2 |
82.0 |
57.7 |
78.8 |
27.5 |
46.2 |
Dragon-multiturn |
53.0 |
81.2 |
48.6 |
83.5 |
54.8 |
83.2 |
49.6 |
86.7 |
64.5 |
85.2 |
47.4 |
67.1 |
5つのマルチターンQAデータセット(Doc2Dial、QuAC、QReCC、TopiOCQA、INSCIT)における検索結果と、平均のtop-1およびtop-5の再現率スコアが示されています。*TopiOCQAとINSCITの平均コンテキスト長は他のデータセットよりも短いため、それぞれのデータセットにおけるtop-1とtop-5のコンテキスト長に概ね一致するように、top-5とtop-20を報告しています。
💻 使用例
基本的な使用法
import torch
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained('nvidia/dragon-multiturn-query-encoder')
query_encoder = AutoModel.from_pretrained('nvidia/dragon-multiturn-query-encoder')
context_encoder = AutoModel.from_pretrained('nvidia/dragon-multiturn-context-encoder')
query = [
{"role": "user", "content": "I need help planning my Social Security benefits for my survivors."},
{"role": "agent", "content": "Are you currently planning for your future?"},
{"role": "user", "content": "Yes, I am."}
]
contexts = [
"Benefits Planner: Survivors | Planning For Your Survivors \nAs you plan for the future , you'll want to think about what your family would need if you should die now. Social Security can help your family if you have earned enough Social Security credits through your work. You can earn up to four credits each year. In 2019 , for example , you earn one credit for each $1,360 of wages or self - employment income. When you have earned $5,440 , you have earned your four credits for the year. The number of credits needed to provide benefits for your survivors depends on your age when you die. No one needs more than 40 credits 10 years of work to be eligible for any Social Security benefit. But , the younger a person is , the fewer credits they must have for family members to receive survivors benefits. Benefits can be paid to your children and your spouse who is caring for the children even if you don't have the required number of credits. They can get benefits if you have credit for one and one - half years of work 6 credits in the three years just before your death. For Your Widow Or Widower \nThere are about five million widows and widowers receiving monthly Social Security benefits based on their deceased spouse's earnings record.",
"Benefits Planner: Retirement \nOther Things to Consider \nWhat Is The Best Age To Start Your Benefits? The answer is that there is no one \" best age \" for everyone and, ultimately, it is your choice. You should make an informed decision about when to apply for benefits based on your individual and family circumstances. Your monthly benefit amount can differ substantially based on the age when you start receiving benefits. If you decide to start benefits : before your full retirement age , your benefit will be smaller but you will receive it for a longer period of time. at your full retirement age or later , you will receive a larger monthly benefit for a shorter period of time. The amount you receive when you first get benefits sets the base for the amount you will receive for the rest of your life. You may want to consider the following when you make that decision : If you plan to continue working , there are limits on how much you can earn each year between age 62 and full retirement age and still get all your benefits. Depending on the amount of your benefit and your earnings for the year , you may have to give up some of your benefits."
]
formatted_query = '\n'.join([turn['role'] + ": " + turn['content'] for turn in query]).strip()
query_input = tokenizer(formatted_query, return_tensors='pt')
ctx_input = tokenizer(contexts, padding=True, truncation=True, max_length=512, return_tensors='pt')
query_emb = query_encoder(**query_input).last_hidden_state[:, 0, :]
ctx_emb = context_encoder(**ctx_input).last_hidden_state[:, 0, :]
similarities = query_emb.matmul(ctx_emb.transpose(0, 1))
ranked_results = torch.argsort(similarities, dim=-1, descending=True)
マルチターンQA検索ベンチマークの評価
(更新!!) 私たちは、5つのデータセット(Doc2Dial、QuAC、QReCC、TopiOCQA、INSCIT)におけるマルチターンQA検索を評価しています。これらのデータセットはChatRAG Benchで見つけることができます。評価スクリプトはこちらで確認できます。
📄 ライセンス
Dragon-multiturnはDragonをベースに構築されています。ユーザーには、Dragonモデルの元のライセンスを参照することをお勧めします。Dragon-multiturnはまた、利用規約の対象となります。
連絡先
- Zihan Liu (zihanl@nvidia.com)
- Wei Ping (wping@nvidia.com)
引用
@article{liu2024chatqa,
title={ChatQA: Surpassing GPT-4 on Conversational QA and RAG},
author={Liu, Zihan and Ping, Wei and Roy, Rajarshi and Xu, Peng and Lee, Chankyu and Shoeybi, Mohammad and Catanzaro, Bryan},
journal={arXiv preprint arXiv:2401.10225},
year={2024}
}