zihanliu commited on
Commit
b80bf5a
1 Parent(s): 91f014e

Upload 6 files

Browse files
Files changed (6) hide show
  1. README.md +141 -0
  2. config.json +26 -0
  3. pytorch_model.bin +3 -0
  4. special_tokens_map.json +1 -0
  5. tokenizer_config.json +3 -0
  6. vocab.txt +0 -0
README.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tag:
5
+ - dragon
6
+ - retriever
7
+ - conversation
8
+ - multi-turn
9
+ - conversational query
10
+ license:
11
+ - other
12
+ ---
13
+
14
+ ## Model Description
15
+ We introduce Dragon-multiturn, a retriever specifically designed for the conversational QA scenario. It can handle conversational query which combine dialogue history with the current query. It is built on top of the [Dragon](https://huggingface.co/facebook/dragon-plus-query-encoder) retriever. The details of Dragon-multiturn can be found in [here](https://arxiv.org/abs/2401.10225).
16
+
17
+ ## Benchmark Results
18
+ <style type="text/css">
19
+ .tg {border:none;border-collapse:collapse;border-spacing:0;}
20
+ .tg td{border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;overflow:hidden;
21
+ padding:10px 5px;word-break:normal;}
22
+ .tg th{border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;font-weight:normal;
23
+ overflow:hidden;padding:10px 5px;word-break:normal;}
24
+ .tg .tg-c3ow{border-color:inherit;text-align:center;vertical-align:center}
25
+ .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:center}
26
+ </style>
27
+ <table class="tg">
28
+ <thead>
29
+ <tr>
30
+ <th class="tg-0pky" rowspan="2"></th>
31
+ <th class="tg-c3ow" colspan="2">Average</th>
32
+ <th class="tg-c3ow" colspan="2">Doc2Dial</th>
33
+ <th class="tg-c3ow" colspan="2">QuAC</th>
34
+ <th class="tg-c3ow" colspan="2">QReCC</th>
35
+ <th class="tg-c3ow" colspan="2">TopiOCQA</th>
36
+ <th class="tg-c3ow" colspan="2">INSCIT</th>
37
+ </tr>
38
+ <tr>
39
+ <th class="tg-c3ow">top-1</th>
40
+ <th class="tg-c3ow">top-5</th>
41
+ <th class="tg-c3ow">top-1</th>
42
+ <th class="tg-c3ow">top-5</th>
43
+ <th class="tg-c3ow">top-1</th>
44
+ <th class="tg-c3ow">top-5</th>
45
+ <th class="tg-c3ow">top-1</th>
46
+ <th class="tg-c3ow">top-5</th>
47
+ <th class="tg-c3ow">top-5*</th>
48
+ <th class="tg-c3ow">top-20*</th>
49
+ <th class="tg-c3ow">top-5*</th>
50
+ <th class="tg-c3ow">top-20*</th>
51
+ </tr>
52
+ </thead>
53
+ <tbody>
54
+ <tr>
55
+ <td class="tg-0pky">Dragon</td>
56
+ <td class="tg-c3ow">46.3</td>
57
+ <td class="tg-c3ow">73.1</td>
58
+ <td class="tg-c3ow">43.3</td>
59
+ <td class="tg-c3ow">75.6</td>
60
+ <td class="tg-c3ow">56.8</td>
61
+ <td class="tg-c3ow">82.9</td>
62
+ <td class="tg-c3ow">46.2</td>
63
+ <td class="tg-c3ow">82.0</td>
64
+ <td class="tg-c3ow">57.7</td>
65
+ <td class="tg-c3ow">78.8</td>
66
+ <td class="tg-c3ow">27.5</td>
67
+ <td class="tg-c3ow">46.2</td>
68
+ </tr>
69
+ <tr>
70
+ <td class="tg-0pky">Dragon-multiturn</td>
71
+ <td class="tg-c3ow">53.0</td>
72
+ <td class="tg-c3ow">81.2</td>
73
+ <td class="tg-c3ow">48.6</td>
74
+ <td class="tg-c3ow">83.5</td>
75
+ <td class="tg-c3ow">54.8</td>
76
+ <td class="tg-c3ow">83.2</td>
77
+ <td class="tg-c3ow">49.6</td>
78
+ <td class="tg-c3ow">86.7</td>
79
+ <td class="tg-c3ow">64.5</td>
80
+ <td class="tg-c3ow">85.2</td>
81
+ <td class="tg-c3ow">47.4</td>
82
+ <td class="tg-c3ow">67.1</td>
83
+ </tr>
84
+ </tbody>
85
+ </table>
86
+ Retrieval results across five multi-turn QA datasets (Doc2Dial, QuAC, QReCC, TopiOCQA, INSCIT) with the average top-1 and top-5 recall scores. *Since the average context length in TopiOCQA and INSCIT is smaller than in other datasets, we report top-5 and top-20 to roughly match the context lengths of top-1 and top-5, respectively, in those datasets.
87
+
88
+
89
+ ## How to use
90
+ ```python
91
+ import torch
92
+ from transformers import AutoTokenizer, AutoModel
93
+
94
+ tokenizer = AutoTokenizer.from_pretrained('nvidia/dragon-multiturn-query-encoder')
95
+ query_encoder = AutoModel.from_pretrained('nvidia/dragon-multiturn-query-encoder')
96
+ context_encoder = AutoModel.from_pretrained('nvidia/dragon-multiturn-context-encoder')
97
+
98
+ query = [
99
+ {"role": "user", "content": "I need help planning my Social Security benefits for my survivors."},
100
+ {"role": "agent", "content": "Are you currently planning for your future?"},
101
+ {"role": "user", "content": "Yes, I am."}
102
+ ]
103
+ contexts = [
104
+ "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.",
105
+ "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."
106
+ ]
107
+
108
+ ## convert query into a format as follows:
109
+ ## user: {user}\nagent: {agent}\nuser: {user}
110
+ formatted_query = ""
111
+ for turn in query:
112
+ formatted_query += turn['role'] + ": " + turn['content'] + "\n"
113
+ formatted_query = formatted_query.strip()
114
+
115
+ ## get query and context embeddings
116
+ query_input = tokenizer(formatted_query, return_tensors='pt')
117
+ ctx_input = tokenizer(contexts, padding=True, return_tensors='pt')
118
+ query_emb = query_encoder(**query_input).last_hidden_state[:, 0, :]
119
+ ctx_emb = context_encoder(**ctx_input).last_hidden_state[:, 0, :]
120
+
121
+ # Compute similarity scores using dot product
122
+ score1 = query_emb @ ctx_emb[0]
123
+ score2 = query_emb @ ctx_emb[1]
124
+ ```
125
+
126
+ ## License
127
+ Dragon-multiturn is built on top of [Dragon](https://arxiv.org/abs/2302.07452). We refer users to the original license of the Dragon model.
128
+
129
+
130
+ ## Correspondence to
131
+ Zihan Liu (zihanl@nvidia.com), Wei Ping (wping@nvidia.com)
132
+
133
+
134
+ ## Citation
135
+ <pre>
136
+ @article{liu2024chatqa,
137
+ title={ChatQA: Building GPT-4 Level Conversational QA Models},
138
+ author={Liu, Zihan and Ping, Wei and Roy, Rajarshi and Xu, Peng and Lee, Chankyu and Shoeybi, Mohammad and Catanzaro, Bryan},
139
+ journal={arXiv preprint arXiv:2401.10225},
140
+ year={2024}}
141
+ </pre>
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/dragon-plus-context-encoder",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.26.1",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30522
26
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfae6270ccce58f9f1716fdb14a2656bf42eb96397d5de5336b7bebd710a6347
3
+ size 438003629
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
tokenizer_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "do_lower_case": true
3
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff