Stability AI/Dense

StableLM 2 12B

chatTool Use
12B
Parameters
4K
Context length
7
Benchmarks
4
Quantizations
50K
HF downloads
Architecture
Dense
Released
2024-03-22
Layers
40
KV Heads
8
Head Dim
160
Family
stablelm

StableLM 2 12B Chat

Model Description

Stable LM 2 12B Chat is a 12 billion parameter instruction tuned language model trained on a mix of publicly available datasets and synthetic datasets, utilizing Direct Preference Optimization (DPO).

Usage

NOTE: This model requires transformers>=4.40.0

StableLM 2 12B Chat uses the following instruction ChatML format. This format is also available through the tokenizer's apply_chat_template method:

from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained('stabilityai/stablelm-2-12b-chat')
model = AutoModelForCausalLM.from_pretrained(
    'stabilityai/stablelm-2-12b-chat',
    device_map="auto",
)

prompt = [{'role': 'user', 'content': 'Implement snake game using pygame'}]
inputs = tokenizer.apply_chat_template(
    prompt,
    add_generation_prompt=True,
    return_tensors='pt'
)

tokens = model.generate(
    inputs.to(model.device),
    max_new_tokens=100,
    temperature=0.7,
    do_sample=True,
)
output = tokenizer.decode(tokens[:, inputs.shape[-1]:][0], skip_special_tokens=False)

print(output)

StableLM 2 12B Chat also supports function calling. The following is an example of how to use it:

system_prompt = """\
You are a helpful assistant with access to the following functions. You must use them if required -\n
[
  {
    "type": "function",
    "function": {
      "name": "TextToImage",
      "description": "This function is able to create, draw, or illustrate an image from a text prompt.",
      "parameters": {
        "type": "object",
        "properties": {
          "prompt": {
            "type": "string",
            "description": "The description of image that the user wants to create."
          }
        },
        "required": [
          "prompt"
        ]
      }
    }
  }
]
"""
messages = [
    {'role': 'system', 'content': system_prompt},
    {'role': "user", 'content': "Please, generate a picture of the Eiffel Tower at night!"}
]

inputs = tokenizer.apply_chat_template(
    messages,
    add_generation_prompt=True,
    return_tensors='pt'
)

tokens = model.generate(
    inputs.to(model.device),
    max_new_tokens=1024,
    temperature=0.5,
    do_sample=True
)
output = tokenizer.decode(tokens[:, inputs.shape[-1]:][0], skip_special_tokens=True)

print(output)
"""
[
  {
    "name": "TextToImage",
    "arguments": {
      "prompt": "Eiffel Tower at night."
    }
  }
]
"""

Model Details

Training Dataset

The dataset is comprised of a mixture of open datasets large-scale datasets available on the HuggingFace Hub as well as an internal safety dataset:

  1. SFT Datasets
  • HuggingFaceH4/ultrachat_200k
  • meta-math/MetaMathQA
  • WizardLM/WizardLM_evol_instruct_V2_196k
  • Open-Orca/SlimOrca
  • openchat/openchat_sharegpt4_dataset
  • LDJnr/Capybara
  • hkust-nlp/deita-10k-v0
  • teknium/OpenHermes-2.5
  • glaiveai/glaive-function-calling-v2
  1. Safety Datasets:
  • Anthropic/hh-rlhf
  • Internal Safety Dataset
  1. Preference Datasets:
  • argilla/dpo-mix-7k

Performance

MT-Bench

ModelParametersMT Bench (Inflection-corrected)
mistralai/Mixtral-8x7B-Instruct-v0.113B/47B8.48 ± 0.06
stabilityai/stablelm-2-12b-chat12B8.15 ± 0.08
Qwen/Qwen1.5-14B-Chat14B7.95 ± 0.10
HuggingFaceH4/zephyr-7b-gemma-v0.18.5B7.82 ± 0.03
mistralai/Mistral-7B-Instruct-v0.27B7.48 ± 0.02
meta-llama/Llama-2-70b-chat-hf70B7.29 ± 0.05

OpenLLM Leaderboard

ModelParametersAverageARC Challenge (25-shot)HellaSwag (10-shot)MMLU (5-shot)TruthfulQA (0-shot)Winogrande (5-shot)GSM8K (5-shot)
mistralai/Mixtral-8x7B-Instruct-v0.113B/47B72.7170.1487.5571.4064.9881.0661.11
stabilityai/stablelm-2-12b-chat12B68.4565.0286.0661.1462.0078.7757.70
Qwen/Qwen1.5-14B14B66.7056.5781.0869.3652.0673.4867.63
mistralai/Mistral-7B-Instruct-v0.27B65.7163.1484.8860.7860.2677.1940.03
HuggingFaceH4/zephyr-7b-gemma-v0.18.5B62.4158.4583.4860.6852.0774.1945.56
Qwen/Qwen1.5-14B-Chat14B62.3758.7982.3368.5260.3873.3230.86
google/gemma-7b8.5B63.7561.0982.2064.5644.7979.0150.87
stabilityai/stablelm-2-12b12B63.5358.4584.3362.0948.1678.1056.03
mistralai/Mistral-7B-v0.17B60.9759.9883.3164.1642.1578.3737.83
meta-llama/Llama-2-13b-hf13B55.6959.3982.1355.7737.3876.6422.82
meta-llama/Llama-2-13b-chat-hf13B54.9259.0481.9454.6441.1274.5115.24

Use and Limitations

Intended Use

The model is intended to be used in chat-like applications. Developers must evaluate the model for safety performance in their specific use case. Read more about safety and limitations below.

Limitations and Bias

We strongly recommend pairing this model with an input and output classifier to prevent harmful responses. Using this model will require guardrails around your inputs and outputs to ensure that any outputs returned are not hallucinations. Additionally, as each use case is unique, we recommend running your own suite of tests to ensure proper performance of this model. Finally, do not use the models if they are unsuitable for your application, or for any applications that may cause deliberate or unintentional harm to others.

How to Cite

@article{bellagente2024stable,
  title={Stable LM 2 1.6 B Technical Report},
  author={Bellagente, Marco and Tow, Jonathan and Mahan, Dakota and Phung, Duy and Zhuravinskyi, Maksym and Adithyan, Reshinth and Baicoianu, James and Brooks, Ben and Cooper, Nathan and Datta, Ashish and others},
  journal={arXiv preprint arXiv:2402.17834},
  year={2024}
}

Quantizations & VRAM

Q4_K_M4.5 bpw
7.2 GB
VRAM required
94%
Quality
Q6_K6.5 bpw
10.2 GB
VRAM required
97%
Quality
Q8_08 bpw
12.5 GB
VRAM required
100%
Quality
FP1616 bpw
24.5 GB
VRAM required
100%
Quality

Benchmarks (7)

IFEval54.0
HumanEval35.0
BBH25.3
MMLU-PRO19.3
MUSR7.7
MATH5.4
GPQA2.2

GPUs that can run this model

At Q4_K_M quantization. Sorted by minimum VRAM.

Find the best GPU for StableLM 2 12B

Build Hardware for StableLM 2 12B