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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
## Use At your own Risk!
|
| 3 |
+
|
| 4 |
+
4bit gptq (gptq) version of dbrx-base-converted-v2
|
| 5 |
+
|
| 6 |
+
Version: 2 (much better than quantization/calibration than previous)
|
| 7 |
+
|
| 8 |
+
Run:
|
| 9 |
+
1. Use PR https://github.com/AutoGPTQ/AutoGPTQ/pull/625
|
| 10 |
+
2. Need ~68GB of VRAM (1xA100 80G will do)
|
| 11 |
+
3. Use combine_tensors.sh script to combine the two split files into one. HF has max 50GB file size limit.
|
| 12 |
+
|
| 13 |
+
```json
|
| 14 |
+
{
|
| 15 |
+
"bits": 4,
|
| 16 |
+
"group_size": 128,
|
| 17 |
+
"damp_percent": 0.005,
|
| 18 |
+
"desc_act": false,
|
| 19 |
+
"static_groups": false,
|
| 20 |
+
"sym": true,
|
| 21 |
+
"true_sequential": true,
|
| 22 |
+
"model_name_or_path": null,
|
| 23 |
+
"model_file_base_name": null,
|
| 24 |
+
"quant_method": "gptq",
|
| 25 |
+
"checkpoint_format": "gptq"
|
| 26 |
+
}
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
TODO:
|
| 30 |
+
* Add sharding of quantized model so there is no need to manually combine safetensor files
|
| 31 |
+
---
|
| 32 |
+
inference: false
|
| 33 |
+
license: other
|
| 34 |
+
license_name: databricks-open-model-license
|
| 35 |
+
license_link: https://www.databricks.com/legal/open-model-license
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
# DBRX Base
|
| 39 |
+
|
| 40 |
+
* DBRX Base is a mixture-of-experts (MoE) large language model trained from scratch by Databricks.
|
| 41 |
+
* We are releasing both DBRX Base, a pretrained base model, and DBRX Instruct, a fine-tuned version for few-turn interactions, under [an open license](https://www.databricks.com/legal/open-model-license).
|
| 42 |
+
* This is the repository for DBRX Base. DBRX Instruct can be found [here](https://huggingface.co/databricks/dbrx-instruct).
|
| 43 |
+
* For full details on the DBRX models, please read our [technical blog post](https://www.databricks.com/blog/introducing-dbrx-new-state-art-open-llm).
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
## Model Overview
|
| 47 |
+
DBRX is a [transformer-based](https://www.isattentionallyouneed.com/) decoder-only large language model (LLM) that was trained using next-token prediction.
|
| 48 |
+
It uses a *fine-grained* mixture-of-experts (MoE) architecture with 132B total parameters of which 36B parameters are active on any input.
|
| 49 |
+
It was pre-trained on 12T tokens of text and code data.
|
| 50 |
+
Compared to other open MoE models like Mixtral-8x7B and Grok-1, DBRX is fine-grained, meaning it uses a larger number of smaller experts. DBRX has 16 experts and chooses 4, while Mixtral-8x7B and Grok-1 have 8 experts and choose 2.
|
| 51 |
+
This provides 65x more possible combinations of experts and we found that this improves model quality.
|
| 52 |
+
DBRX uses rotary position encodings (RoPE), gated linear units (GLU), and grouped query attention (GQA).
|
| 53 |
+
It uses the GPT-4 tokenizer as provided in the [tiktoken](https://github.com/openai/tiktoken) repository.
|
| 54 |
+
We made these choices based on exhaustive evaluation and scaling experiments.
|
| 55 |
+
|
| 56 |
+
DBRX was pretrained on 12T tokens of carefully curated data and a maximum context length of 32K tokens.
|
| 57 |
+
We estimate that this data is at least 2x better token-for-token than the data we used to pretrain the MPT family of models.
|
| 58 |
+
This new dataset was developed using the full suite of Databricks tools, including Apache Spark™ and Databricks notebooks for data processing, and Unity Catalog for data management and governance.
|
| 59 |
+
We used curriculum learning for pretraining, changing the data mix during training in ways we found to substantially improve model quality.
|
| 60 |
+
|
| 61 |
+
* **Inputs:** DBRX only accepts text-based inputs and accepts a context length of up to 32768 tokens.
|
| 62 |
+
* **Outputs:** DBRX only produces text-based outputs.
|
| 63 |
+
* **Model Architecture:** More detailed information about DBRX Instruct and DBRX Base can be found in our [technical blog post](https://www.databricks.com/blog/introducing-dbrx-new-state-art-open-llm).
|
| 64 |
+
* **License:** [Databricks Open Model License](https://www.databricks.com/legal/open-model-license)
|
| 65 |
+
* **Acceptable Use Policy:** [Databricks Open Model Acceptable Use Policy](https://www.databricks.com/legal/acceptable-use-policy-open-model)
|
| 66 |
+
* **Version:** 1.0
|
| 67 |
+
* **Owner:** Databricks, Inc.
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
## Usage
|
| 71 |
+
These are several general ways to use the DBRX models:
|
| 72 |
+
* DBRX Base and DBRX Instruct are available for download on HuggingFace (see our Quickstart guide below). This is the HF repository for DBRX Base; DBRX Instruct can be found [here](https://huggingface.co/databricks/dbrx-instruct).
|
| 73 |
+
* The DBRX model repository can be found on GitHub [here](https://github.com/databricks/dbrx).
|
| 74 |
+
* DBRX Base and DBRX Instruct are available with [Databricks Foundation Model APIs](https://docs.databricks.com/en/machine-learning/foundation-models/index.html) via both *Pay-per-token* and *Provisioned Throughput* endpoints. These are enterprise-ready deployments.
|
| 75 |
+
* For more information on how to fine-tune using LLM-Foundry, please take a look at our LLM pretraining and fine-tuning [documentation](https://github.com/mosaicml/llm-foundry/blob/main/scripts/train/README.md).
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
## Quickstart Guide
|
| 79 |
+
**NOTE: This is DBRX Base, and has not been instruction finetuned. It has not been trained for interactive chat and is only a completion model.**
|
| 80 |
+
If you are looking for the finetuned model, please use [DBRX Instruct](https://huggingface.co/databricks/dbrx-instruct).
|
| 81 |
+
|
| 82 |
+
Getting started with DBRX models is easy with the `transformers` library. The model requires ~264GB of RAM and the following packages:
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
pip install "transformers>=4.39.2" "tiktoken>=0.6.0"
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
If you'd like to speed up download time, you can use the `hf_transfer` package as described by Huggingface [here](https://huggingface.co/docs/huggingface_hub/en/guides/download#faster-downloads).
|
| 89 |
+
```bash
|
| 90 |
+
pip install hf_transfer
|
| 91 |
+
export HF_HUB_ENABLE_HF_TRANSFER=1
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
You will need to request access to this repository to download the model. Once this is granted,
|
| 95 |
+
[obtain an access token](https://huggingface.co/docs/hub/en/security-tokens) with `read` permission, and supply the token below.
|
| 96 |
+
|
| 97 |
+
### Run the model on a CPU:
|
| 98 |
+
```python
|
| 99 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 100 |
+
import torch
|
| 101 |
+
|
| 102 |
+
tokenizer = AutoTokenizer.from_pretrained("databricks/dbrx-base", trust_remote_code=True, token="hf_YOUR_TOKEN")
|
| 103 |
+
model = AutoModelForCausalLM.from_pretrained("databricks/dbrx-base", device_map="cpu", torch_dtype=torch.bfloat16, trust_remote_code=True, token="hf_YOUR_TOKEN")
|
| 104 |
+
|
| 105 |
+
input_text = "Databricks was founded in "
|
| 106 |
+
input_ids = tokenizer(input_text, return_tensors="pt")
|
| 107 |
+
|
| 108 |
+
outputs = model.generate(**input_ids, max_new_tokens=100)
|
| 109 |
+
print(tokenizer.decode(outputs[0]))
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
### Run the model on multiple GPUs:
|
| 113 |
+
```python
|
| 114 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 115 |
+
import torch
|
| 116 |
+
|
| 117 |
+
tokenizer = AutoTokenizer.from_pretrained("databricks/dbrx-base", trust_remote_code=True, token="hf_YOUR_TOKEN")
|
| 118 |
+
model = AutoModelForCausalLM.from_pretrained("databricks/dbrx-base", device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True, token="hf_YOUR_TOKEN")
|
| 119 |
+
|
| 120 |
+
input_text = "Databricks was founded in "
|
| 121 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
| 122 |
+
|
| 123 |
+
outputs = model.generate(**input_ids, max_new_tokens=100)
|
| 124 |
+
print(tokenizer.decode(outputs[0]))
|
| 125 |
+
```
|
| 126 |
+
If your GPU system supports [FlashAttention2](https://huggingface.co/docs/transformers/perf_infer_gpu_one#flashattention-2), you can add `attn_implementation=”flash_attention_2”` as a keyword to `AutoModelForCausalLM.from_pretrained()` to achieve faster inference.
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
## Limitations and Ethical Considerations
|
| 130 |
+
### Training Dataset Limitations
|
| 131 |
+
The DBRX models were trained on 12T tokens of text, with a knowledge cutoff date of December 2023.
|
| 132 |
+
|
| 133 |
+
The training mix used for DBRX contains both natural-language and code examples. The vast majority of our training data is in the English language. We did not test DBRX for non-English proficiency. Therefore, DBRX should be considered a generalist model for text-based use in the English language.
|
| 134 |
+
|
| 135 |
+
DBRX does not have multimodal capabilities.
|
| 136 |
+
|
| 137 |
+
### Associated Risks and Recommendations
|
| 138 |
+
All foundation models are novel technologies that carry various risks, and may output information that is inaccurate, incomplete, biased, or offensive.
|
| 139 |
+
Users should exercise judgment and evaluate such output for accuracy and appropriateness for their desired use case before using or sharing it.
|
| 140 |
+
Databricks recommends [using retrieval augmented generation (RAG)](https://www.databricks.com/glossary/retrieval-augmented-generation-rag) in scenarios where accuracy and fidelity are important.
|
| 141 |
+
We also recommend that anyone using or fine-tuning either DBRX Base or DBRX Instruct perform additional testing around safety in the context of their particular application and domain.
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
## Intended Uses
|
| 145 |
+
### Intended Use Cases
|
| 146 |
+
The DBRX models are open, general-purpose LLMs intended and licensed for both commercial and research applications.
|
| 147 |
+
They can be further fine-tuned for various domain-specific natural language and coding tasks.
|
| 148 |
+
DBRX Base can be used as an off-the-shelf model for text completion for general English-language and coding tasks.
|
| 149 |
+
|
| 150 |
+
Please review the Associated Risks section above, as well as the [Databricks Open Model License](https://www.databricks.com/legal/open-model-license) and [Databricks Open Model Acceptable Use Policy](https://www.databricks.com/legal/acceptable-use-policy-open-model) for further information about permissible uses of DBRX Base and its derivatives.
|
| 151 |
+
|
| 152 |
+
### Out-of-Scope Use Cases
|
| 153 |
+
DBRX models are not intended to be used out-of-the-box in non-English languages and do not support native code execution, or other forms of function-calling.
|
| 154 |
+
DBRX models should not be used in any manner that violates applicable laws or regulations or in any other way that is prohibited by the [Databricks Open Model License](https://www.databricks.com/legal/open-model-license) and [Databricks Open Model Acceptable Use Policy](https://www.databricks.com/legal/acceptable-use-policy-open-model).
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
## Training Stack
|
| 158 |
+
MoE models are complicated to train, and the training of DBRX Base and DBRX Instruct was heavily supported by Databricks’ infrastructure for data processing and large-scale LLM training (e.g., [Composer](https://github.com/mosaicml/composer), [Streaming](https://github.com/mosaicml/streaming), [Megablocks](https://github.com/stanford-futuredata/megablocks), and [LLM Foundry](https://github.com/mosaicml/llm-foundry)).
|
| 159 |
+
|
| 160 |
+
Composer is our core library for large-scale training.
|
| 161 |
+
It provides an optimized training loop, easy [checkpointing](https://docs.mosaicml.com/projects/composer/en/latest/trainer/checkpointing.html) and [logging](https://docs.mosaicml.com/projects/composer/en/latest/trainer/logging.html#wood-logging),
|
| 162 |
+
[FSDP](https://pytorch.org/docs/stable/fsdp.html)-based [model sharding](https://docs.mosaicml.com/projects/composer/en/latest/notes/distributed_training.html#fullyshardeddataparallel-fsdp),
|
| 163 |
+
convenient [abstractions](https://docs.mosaicml.com/projects/composer/en/latest/trainer/time.html), extreme customizability via [callbacks](https://docs.mosaicml.com/projects/composer/en/latest/trainer/callbacks.html), and more.
|
| 164 |
+
|
| 165 |
+
Streaming enables fast, low cost, and scalable training on large datasets from cloud storage. It handles a variety of challenges around deterministic resumption as node counts change, avoiding redundant downloads across devices, high-quality shuffling at scale, sample-level random access, and speed.
|
| 166 |
+
|
| 167 |
+
Megablocks is a lightweight library for MoE training. Crucially, it supports “dropless MoE,” which avoids inefficient padding and is intended to provide deterministic outputs for a given sequence no matter what other sequences are in the batch.
|
| 168 |
+
|
| 169 |
+
LLM Foundry ties all of these libraries together to create a simple LLM pretraining, fine-tuning, and inference experience.
|
| 170 |
+
|
| 171 |
+
DBRX was trained using proprietary optimized versions of the above open source libraries, along with our [LLM training platform](https://www.databricks.com/product/machine-learning/mosaic-ai-training).
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
## Evaluation
|
| 175 |
+
We find that DBRX outperforms established open-source and open-weight base models on the [Databricks Model Gauntlet](https://www.databricks.com/blog/llm-evaluation-for-icl), the [Hugging Face Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard), and HumanEval.
|
| 176 |
+
The Databricks Model Gauntlet measures performance on more than 30 tasks across six categories: world knowledge, common sense reasoning, language understanding, reading comprehension, symbolic problem solving, and programming.
|
| 177 |
+
The Hugging Face Open LLM Leaderboard measures the average of ARC-Challenge, HellaSwag, MMLU, TruthfulQA, Winogrande and GSM8k.
|
| 178 |
+
HumanEval measures coding ability.
|
| 179 |
+
|
| 180 |
+
Full evaluation details can be found in our [technical blog post](https://www.databricks.com/blog/introducing-dbrx-new-state-art-open-llm).
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
## Acknowledgements
|
| 184 |
+
The DBRX models were made possible thanks in large part to the open-source community, especially:
|
| 185 |
+
* The [MegaBlocks](https://arxiv.org/abs/2211.15841) library, which established a foundation for our MoE implementation.
|
| 186 |
+
* [PyTorch FSDP](https://arxiv.org/abs/2304.11277), which we built on for distributed training.
|