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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
---
language:
- en
tag:
- doc-chat
- DocChat
- dragon
- retriever
- conversation
- multi-turn
- conversational query
license:
- other
---

# Model Information

We are excited to announce the release of Cerebras DocChat, our first iteration of models designed for document-based conversational question answering. This series includes two models: Cerebras Llama3-DocChat, a large language model (LLM), and Cerebras Dragon-DocChat, a multi-turn retriever model.

This model – Cerebras Dragon-DocChat – was built on top of Dragon+ and finetuned using ChatQA’s conversational Q&A dataset. The finetuning process took *minutes* on 1 Cerebras machine (yes you read that correctly), and yields 8.9% and 3.5% absolute improvements in recall over Dragon+ and ChatQA Dragon-Multiturn (top-1).

**Note that like its predecessors, Cerebras Dragon-DocChat is a dual-encoder embedding model. This model card is for the context encoder. You can find the question encoder's model card here.**

You can find more information about DocChat at the following locations:
* [Blog post](https://www.cerebras.net/blog/train-a-gpt-4-level-conversational-qa-in-a-few-hours)
* [LLM model weights on HuggingFace](https://huggingface.co/cerebras/Llama3-DocChat-1.0-8B)
* Embedding model weights on HuggingFace: [Query Encoder](https://huggingface.co/cerebras/Dragon-DocChat-Query-Encoder), [Context Encoder](https://huggingface.co/cerebras/Dragon-DocChat-Context-Encoder)
* [Data preparation, training, and evaluation code](https://github.com/Cerebras/DocChat)

## Results

DocChat Retriever was evaluated on five multi-turn QA datasets.

<style>
   table {
      border: none;
      border-collapse: collapse;
      border-spacing: 0;
   }

   table td {
      border-style: solid;
      border-width: 1px;
      padding: 2px 5px;
      text-align: center;
      border-color: #7f8c8d;
   }
</style>
<table>
   <tbody>
      <tr>
         <td rowspan="1" colspan="1">
            <div data-align="center">
               <strong data-renderer-mark="true">Benchmark</strong>
            </div>
         </td>
         <td rowspan="1" colspan="1">
            <strong data-renderer-mark="true">Metric</strong>
         </td>
         <td rowspan="1" colspan="1">
            <strong data-renderer-mark="true">Facebook Dragon+</strong>
         </td>
         <td rowspan="1" colspan="1">
            <strong data-renderer-mark="true">Nvidia Dragon-Multiturn</strong>
         </td>
         <td rowspan="1" colspan="1">
            <strong data-renderer-mark="true">Cerebras Dragon-DocChat</strong>
         </td>
      </tr>
      <tr>
         <td rowspan="3" colspan="1">
            Doc2Dial
         </td>
         <td rowspan="1" colspan="1">
            Recall@1
         </td>
         <td rowspan="1" colspan="1">
            43.95
         </td>
         <td rowspan="1" colspan="1">
            50.11
         </td>
         <td rowspan="1" colspan="1">
            51.54
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@5
         </td>
         <td rowspan="1" colspan="1">
            77.61
         </td>
         <td rowspan="1" colspan="1">
            83.85
         </td>
         <td rowspan="1" colspan="1">
            83.12
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@20
         </td>
         <td rowspan="1" colspan="1">
            92.05
         </td>
         <td rowspan="1" colspan="1">
            95.33
         </td>
         <td rowspan="1" colspan="1">
            95.25
         </td>
      </tr>
      <tr>
         <td rowspan="3" colspan="1">
            QuAC
         </td>
         <td rowspan="1" colspan="1">
            Recall@1
         </td>
         <td rowspan="1" colspan="1">
            62.09
         </td>
         <td rowspan="1" colspan="1">
            60.02
         </td>
         <td rowspan="1" colspan="1">
            61.30
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@5
         </td>
         <td rowspan="1" colspan="1">
            86.01
         </td>
         <td rowspan="1" colspan="1">
            86.51
         </td>
         <td rowspan="1" colspan="1">
            87.69
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@20
         </td>
         <td rowspan="1" colspan="1">
            96.48
         </td>
         <td rowspan="1" colspan="1">
            96.60
         </td>
         <td rowspan="1" colspan="1">
            97.25
         </td>
      </tr>
      <tr>
         <td rowspan="3" colspan="1">
            QReCC
         </td>
         <td rowspan="1" colspan="1">
            Recall@1
         </td>
         <td rowspan="1" colspan="1">
            49.00
         </td>
         <td rowspan="1" colspan="1">
            49.43
         </td>
         <td rowspan="1" colspan="1">
            55.41
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@5
         </td>
         <td rowspan="1" colspan="1">
            85.14
         </td>
         <td rowspan="1" colspan="1">
            86.6
         </td>
         <td rowspan="1" colspan="1">
            90.11
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@20
         </td>
         <td rowspan="1" colspan="1">
            97.21
         </td>
         <td rowspan="1" colspan="1">
            98.28
         </td>
         <td rowspan="1" colspan="1">
            98.39
         </td>
      </tr>
      <tr>
         <td rowspan="3" colspan="1">
            INSCIT*
         </td>
         <td rowspan="1" colspan="1">
            Recall@1
         </td>
         <td rowspan="1" colspan="1">
            11.13
         </td>
         <td rowspan="1" colspan="1">
            18.35
         </td>
         <td rowspan="1" colspan="1">
            21.65
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@5
         </td>
         <td rowspan="1" colspan="1">
            29.27
         </td>
         <td rowspan="1" colspan="1">
            48.45
         </td>
         <td rowspan="1" colspan="1">
            50.72
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@20
         </td>
         <td rowspan="1" colspan="1">
            49.07
         </td>
         <td rowspan="1" colspan="1">
            66.19
         </td>
         <td rowspan="1" colspan="1">
            72.78
         </td>
      </tr>
      <tr>
         <td rowspan="3" colspan="1">
            Topiocqa*
         </td>
         <td rowspan="1" colspan="1">
            Recall@1
         </td>
         <td rowspan="1" colspan="1">
            29.19
         </td>
         <td rowspan="1" colspan="1">
            31.34
         </td>
         <td rowspan="1" colspan="1">
            38.19
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@5
         </td>
         <td rowspan="1" colspan="1">
            62.52
         </td>
         <td rowspan="1" colspan="1">
            65.79
         </td>
         <td rowspan="1" colspan="1">
            72.47
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Recall@20
         </td>
         <td rowspan="1" colspan="1">
            83.69
         </td>
         <td rowspan="1" colspan="1">
            84.37
         </td>
         <td rowspan="1" colspan="1">
            87.23
         </td>
      </tr>
      <tr>
         <td rowspan="2" colspan="1">
            Average**
         </td>
         <td rowspan="1" colspan="1">
            Avg top 1
         </td>
         <td rowspan="1" colspan="1">
            49.36
         </td>
         <td rowspan="1" colspan="1">
            54.76
         </td>
         <td rowspan="1" colspan="1">
            58.29
         </td>
      </tr>
      <tr>
         <td rowspan="1" colspan="1">
            Avg top 5
         </td>
         <td rowspan="1" colspan="1">
            76.30
         </td>
         <td rowspan="1" colspan="1">
            81.50
         </td>
         <td rowspan="1" colspan="1">
            84.19
         </td>
      </tr>
   </tbody>
</table>

\*Evaluated on a subset of the wikipedia corpus that was available to us. All models use the same evaluation strategy to ensure apples-to-apples comparisons.

\*\* We follow the same convention as in ChatQA, where we compare top-5 and top-20 of TopiOCQA and INSCIT to top-1 and top-5, respectively, of the other datasets, in order match differences in average context length.

## Prompt Format

In order to maintain consistency, we follow the same format as ChatQA. The chat history should be concatenated into a single query, as follows:


```
user: {user turn 1}
agent: {agent turn 1}
...
user: {current user turn}
```
## Example Usages


```python
# Demonstration of DocChat retriever in a multi-turn setting
# The sample documents are from a spec sheet about the Cerebras system & supercomputers

from transformers import AutoTokenizer, AutoModel
import torch

tokenizer = AutoTokenizer.from_pretrained("cerebras/Dragon-DocChat-Query-Encoder")
query_encoder = AutoModel.from_pretrained("cerebras/Dragon-DocChat-Query-Encoder")
context_encoder = AutoModel.from_pretrained("cerebras/Dragon-DocChat-Context-Encoder")

documents = []
documents.append("""
# Cerebras Wafer-Scale Cluster

The Cerebras Wafer-Scale Cluster (WSC) is a revolutionary technology suite that efficiently handles the enormous computational needs of AI model training. It centers around the CS-3 system, powered by the 3rd generation Wafer-Scale Engine (WSE-3)—the world’s largest AI-optimized processor. The WSC integrates MemoryX for high-capacity, off-chip model weight storage, and SwarmX for effective weight broadcasting and gradient reduction across the cluster. This setup allows the WSC to adeptly train multi-trillion parameter models, achieving near perfect linear-scaled performance and simplifying the complexity seen in traditional distributed computing.

The Cerebras WSE-3 is 46,250 square millimeters of silicon, 4 trillion transistors, 900K cores, 44 GB on-chip memory, and delivers an unparalleled 125 petaFLOPS of AI compute. It surpasses all other processors in AI-optimized cores, memory speed, and on-chip fabric bandwidth.
""")
documents.append("""
## AI Supercomputers

Condor Galaxy (CG), the supercomputer built by G42 and Cerebras, is the simplest and fastest way to build AI models in the cloud. With over 16 ExaFLOPs of AI compute, Condor Galaxy trains the most demanding models in hours rather than days. The terabyte scale MemoryX system natively accommodates 100 billion+ parameter models, making large scale training simple and efficient.

| Cluster  | ExaFLOPs | Systems  | Memory |
| -------- | -------- | -------- | ------ |
| CG1      | 4        | 64 CS-2s | 82 TB  |
| CG2      | 4        | 64 CS-2s | 82 TB  |
| CG3      | 8        | 64 CS-3s | 108 TB |
""")


query = [
    {"role": "user", "content": "How many cores does a WSE-3 have?"},
    {"role": "agent", "content": "WSE-3 has 900k cores."},
    {"role": "user", "content": "What is Condor Galaxy?"}
]

formatted_query = "\n".join([turn["role"] + ": " + turn["content"] for turn in query]).strip()

query_input = tokenizer(formatted_query, return_tensors='pt')
ctx_input = tokenizer(documents, 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, :]

## Compute similarity scores:
similarities = query_emb.matmul(ctx_emb.transpose(0, 1)) # (1, num_ctx)

## Rank the similarity from highest to lowest
ranked_results = torch.argsort(similarities, dim=-1, descending=True) # (1, num_ctx)

for i, doc_idx in enumerate(ranked_results[0].tolist()):
    print(f"Rank {i}th document:")
    print("-" * 80)
    print(documents[doc_idx])
    print()

```

## License

This model was trained from Dragon+, and therefore is subject to [its license](https://github.com/facebookresearch/dpr-scale/blob/main/LICENSE). Furthermore, it is trained on ChatQA's synthetic conversational QA dataset which was generated using GPT-4. As a result this model can be used for non-commercial purposes only, and is subject to [Terms of Use](https://openai.com/policies/terms-of-use) of the data generated by OpenAI.

## Acknowledgements

DocChat was built on top of a large body of ML work, spanning training datasets, recipes, and evaluation. We want to thank each of these resources.

```
@article{lin_dragon_2023,
	title = How to Train Your DRAGON: Diverse Augmentation Towards Generalizable Dense Retrieval,
	url = {https://arxiv.org/abs/2302.07452},
	publisher = {arXiv},
	journal = {arXiv e-print 2302.07452},
	author = {Sheng-Chieh Lin, Akari Asai, Minghan Li, Barlas Oguz, Jimmy Lin, Yashar Mehdad, Wen-tau Yih, Xilun Chen},
	year = {2023},
}
@inproceedings{feng2020doc2dial,
  title={doc2dial: A Goal-Oriented Document-Grounded Dialogue Dataset},
  author={Feng, Song and Wan, Hui and Gunasekara, Chulaka and Patel, Siva and Joshi, Sachindra and Lastras, Luis},
  booktitle={Proceedings of the 2020 Conference on EMNLP},
  year={2020}
}
@inproceedings{choi2018quac,
  title={QuAC: Question Answering in Context},
  author={Choi, Eunsol and He, He and Iyyer, Mohit and Yatskar, Mark and Yih, Wen-tau and Choi, Yejin and Liang, Percy and Zettlemoyer, Luke},
  booktitle={Proceedings of the 2018 Conference on EMNLP},
  year={2018}
}
@inproceedings{anantha2021open,
  title={Open-Domain Question Answering Goes Conversational via Question Rewriting},
  author={Anantha, Raviteja and Vakulenko, Svitlana and Tu, Zhucheng and Longpre, Shayne and Pulman, Stephen and Chappidi, Srinivas},
  booktitle={Proceedings of the 2021 Conference on NAACL},
  year={2021}
}
@article{adlakha2022topiocqa,
  title={TopiOCQA: Open-domain Conversational Question Answering with Topic Switching},
  author={Adlakha, Vaibhav and Dhuliawala, Shehzaad and Suleman, Kaheer and de Vries, Harm and Reddy, Siva},
  journal={Transactions of the Association for Computational Linguistics},
  year={2022}
}
@article{wu2023inscit,
  title={InSCIt: Information-Seeking Conversations with Mixed-Initiative Interactions},
  author={Wu, Zeqiu and Parish, Ryu and Cheng, Hao and Min, Sewon and Ammanabrolu, Prithviraj and Ostendorf, Mari and Hajishirzi, Hannaneh},
  journal={Transactions of the Association for Computational Linguistics},
  year={2023}
}
```