How to Use the Hugging Face Stable LM 2 1.6B Model

Model Description
The Stable LM 2 1.6B is a 1.6 billion parameter decoder-only language model pre-trained on 2 trillion tokens of diverse multilingual and code datasets for two epochs.

Usage
To generate text using the Stable LM 2 1.6B model, use the following Python code snippet:

from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(“stabilityai/stablelm-2-1_6b”, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
“stabilityai/stablelm-2-1_6b”,
trust_remote_code=True,
torch_dtype=”auto”,
)
model.cuda()
inputs = tokenizer(“The weather is always wonderful”, return_tensors=”pt”).to(model.device)
tokens = model.generate(
**inputs,
max_new_tokens=64,
temperature=0.70,
top_p=0.95,
do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))

Run with Flash Attention 2 ⚡️
To use Flash Attention 2 with the model, use the following code snippet:

from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(“stabilityai/stablelm-2-1_6b”, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
“stabilityai/stablelm-2-1_6b”,
trust_remote_code=True,
torch_dtype=”auto”,
attn_implementation=”flash_attention_2″,
)
model.cuda()
inputs = tokenizer(“The weather is always wonderful”, return_tensors=”pt”).to(model.device)
tokens = model.generate(
**inputs,
max_new_tokens=64,
temperature=0.70,
top_p=0.95,
do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))

Model Details
– Developed by: Stability AI
– Model type: Stable LM 2 1.6B models are auto-regressive language models based on the transformer decoder architecture.
– Language(s): English
– Library: GPT-NeoX
– License: Stability AI Non-Commercial Research Community License. For commercial use, please contact Stability AI.
– Contact: For questions and comments about the model, please email lm@stability.ai

Model Architecture
The model is a decoder-only transformer with the following specifications:
– Parameters: 1,644,417,024
– Hidden Size: 2048
– Layers: 24
– Heads: 32
– Sequence Length: 4096

Training
Training Dataset
The dataset used for training includes a filtered mixture of open-source large-scale datasets available on the HuggingFace Hub.

Training Procedure
The model is pre-trained on the datasets in bfloat16 precision, optimized with AdamW, and trained using the NeoX tokenizer with a vocabulary size of 100,352.

Training Infrastructure
– Hardware: Stable LM 2 1.6B was trained on the Stability AI cluster across 512 NVIDIA A100 40GB GPUs (AWS P4d instances).
– Software: The model is trained under 2D parallelism (Data and Tensor Parallel) with ZeRO-1, flash-attention, SwiGLU, and Rotary Embedding kernels.

Use and Limitations
Intended Use
The model is intended to be used as a foundational base model for application-specific fine-tuning.

Limitations and Bias
As a base model, the model may exhibit unreliable, unsafe, or other undesirable behaviors that must be corrected through evaluation and fine-tuning prior to deployment.

How to Cite
@misc{StableLM-2-1.6B,
url={https://huggingface.co/stabilityai/stablelm-2-1.6b},
title={Stable LM 2 1.6B},
author={Stability AI Language Team}

Source link
# HuggingFace Tutorial: How to Use StableLM 2 1.6B Model

## Model Description
The `Stable LM 2 1.6B` is a language model pre-trained on 2 trillion tokens of diverse multilingual and code datasets for two epochs.

## Usage
To get started generating text with `Stable LM 2 1.6B`, use the following Python code snippet:

“`python
from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(“stabilityai/stablelm-2-1_6b”, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
“stabilityai/stablelm-2-1_6b”,
trust_remote_code=True,
torch_dtype=”auto”,
)
model.cuda()
inputs = tokenizer(“The weather is always wonderful”, return_tensors=”pt”).to(model.device)
tokens = model.generate(
**inputs,
max_new_tokens=64,
temperature=0.70,
top_p=0.95,
do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))
“`

## Run with Flash Attention 2 ⚡️
You can run the model with Flash Attention 2 using the following Python code snippet:

“`python
from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(“stabilityai/stablelm-2-1_6b”, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
“stabilityai/stablelm-2-1_6b”,
trust_remote_code=True,
torch_dtype=”auto”,
attn_implementation=”flash_attention_2″,
)
model.cuda()
inputs = tokenizer(“The weather is always wonderful”, return_tensors=”pt”).to(model.device)
tokens = model.generate(
**inputs,
max_new_tokens=64,
temperature=0.70,
top_p=0.95,
do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))
“`

## Model Details
– **Developed by**: [Stability AI](https://stability.ai/)
– **Model type**: `Stable LM 2 1.6B` models are auto-regressive language models based on the transformer decoder architecture.
– **Language(s)**: English
– **Library**: [GPT-NeoX](https://github.com/EleutherAI/gpt-neox)
– **License**: [Stability AI Non-Commercial Research Community License](https://huggingface.co/stabilityai/stablelm-2-1_6b/blob/main/LICENSE)
– **Contact**: For questions and comments about the model, please email `lm@stability.ai`

## Model Architecture
The model is a decoder-only transformer with the following specifications:
– Parameters: 1,644,417,024
– Hidden Size: 2048
– Layers: 24
– Heads: 32
– Sequence Length: 4096

## Training
### Training Dataset
The dataset used for training includes a filtered mixture of large-scale datasets available on the [HuggingFace Hub](https://huggingface.co/datasets).

### Training Procedure
The model is pre-trained on the datasets in `bfloat16` precision, optimized with AdamW, and trained using the NeoX tokenizer with a vocabulary size of 100,352.

### Training Infrastructure
– **Hardware**: `Stable LM 2 1.6B` was trained on the Stability AI cluster across 512 NVIDIA A100 40GB GPUs (AWS P4d instances).
– **Software**: The training utilized a fork of `gpt-neox`, 2D parallelism (Data and Tensor Parallel) with ZeRO-1, and flash-attention as well as SwiGLU and Rotary Embedding kernels from FlashAttention-2.

## Use and Limitations
### Intended Use
The model is intended to be used as a foundational base model for application-specific fine-tuning.

### Limitations and Bias
As a base model, this model may exhibit unreliable, unsafe, or other undesirable behaviors that must be corrected through evaluation and fine-tuning prior to deployment.

## How to Cite
“`bibtex
@misc{StableLM-2-1.6B,
url={[https://huggingface.co/stabilityai/stablelm-2-1.6b](https://huggingface.co/stabilityai/stablelm-2-1.6b)},
title={Stable LM 2 1.6B},
author={Stability AI Language Team}
}
“`

For more information, please visit the [HuggingFace website](https://huggingface.co/).



Model Description

Stable LM 2 1.6B is a 1.6 billion parameter decoder-only language model pre-trained on 2 trillion tokens of diverse multilingual and code datasets for two epochs.



Usage

Get started generating text with Stable LM 2 1.6B by using the following code snippet:

from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-2-1_6b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
  "stabilityai/stablelm-2-1_6b",
  trust_remote_code=True,
  torch_dtype="auto",
)
model.cuda()
inputs = tokenizer("The weather is always wonderful", return_tensors="pt").to(model.device)
tokens = model.generate(
  **inputs,
  max_new_tokens=64,
  temperature=0.70,
  top_p=0.95,
  do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))



Run with Flash Attention 2 ⚡️

Click to expand
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-2-1_6b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
  "stabilityai/stablelm-2-1_6b",
  trust_remote_code=True,
  torch_dtype="auto",
  attn_implementation="flash_attention_2",
)
model.cuda()
inputs = tokenizer("The weather is always wonderful", return_tensors="pt").to(model.device)
tokens = model.generate(
  **inputs,
  max_new_tokens=64,
  temperature=0.70,
  top_p=0.95,
  do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))



Model Details

  • Developed by: Stability AI
  • Model type: Stable LM 2 1.6B models are auto-regressive language models based on the transformer decoder architecture.
  • Language(s): English
  • Library: GPT-NeoX
  • License: Stability AI Non-Commercial Research Community License. If you’d like to use this model for commercial products or purposes, please contact us here to learn more.
  • Contact: For questions and comments about the model, please email lm@stability.ai



Model Architecture

The model is a decoder-only transformer similar to the LLaMA (Touvron et al., 2023) architecture with the following modifications:

Parameters Hidden Size Layers Heads Sequence Length
1,644,417,024 2048 24 32 4096



Training



Training Dataset

The dataset is comprised of a filtered mixture of open-source large-scale datasets available on the HuggingFace Hub: Falcon RefinedWeb extract (Penedo et al., 2023), RedPajama-Data (Together Computer., 2023) and The Pile (Gao et al., 2020) both without the Books3 subset, and StarCoder (Li et al., 2023). We further supplement our training with multi-lingual data from CulturaX (Nguyen et al., 2023) and, in particular, from its OSCAR corpora, as well as restructured data in the style of Yuan & Liu (2022).

  • Given the large amount of web data, we recommend fine-tuning the base Stable LM 2 1.6B for your downstream tasks.



Training Procedure

The model is pre-trained on the aforementioned datasets in bfloat16 precision, optimized with AdamW, and trained using the NeoX tokenizer with a vocabulary size of 100,352. We outline the complete hyperparameters choices in the project’s GitHub repository – config*. The final checkpoint of pre-training, before cooldown, is provided in the global_step420000 branch.



Training Infrastructure

  • Hardware: Stable LM 2 1.6B was trained on the Stability AI cluster across 512 NVIDIA A100 40GB GPUs (AWS P4d instances).

  • Software: We use a fork of gpt-neox (EleutherAI, 2021), train under 2D parallelism (Data and Tensor Parallel) with ZeRO-1 (Rajbhandari et al., 2019), and rely on flash-attention as well as SwiGLU and Rotary Embedding kernels from FlashAttention-2 (Dao et al., 2023)



Use and Limitations



Intended Use

The model is intended to be used as a foundational base model for application-specific fine-tuning. Developers must evaluate and fine-tune the model for safe performance in downstream applications.



Limitations and Bias


As a base model, this model may exhibit unreliable, unsafe, or other undesirable behaviors that must be corrected through evaluation and fine-tuning prior to deployment. The pre-training dataset may have contained offensive or inappropriate content, even after applying data cleansing filters, which can be reflected in the model-generated text. We recommend that users exercise caution when using these models in production systems. 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

@misc{StableLM-2-1.6B,
      url={[https://huggingface.co/stabilityai/stablelm-2-1.6b](https://huggingface.co/stabilityai/stablelm-2-1.6b)},
      title={Stable LM 2 1.6B},
      author={Stability AI Language Team}
}

The

tag in HTML is a versatile container that can be used for a variety of purposes. Here are some use cases for the

tag in the provided code snippet:

1. Structuring Content: The

tag can be used to structure the content of a web page. In this code snippet, it is used to wrap different sections of the model description, usage, model details, model architecture, training, use and limitations, and how to cite.

2. Providing Anchors for Navigation: The

tag can be used to create anchor points within a web page. These anchor points allow users to navigate to specific sections of the page by clicking on hyperlinks. In this code snippet, the

tag is used to wrap different headings and sections, providing anchor points for navigation.

3. Displaying Information in Columns: The

tag can be used to create columns in a web page layout. By using CSS, the content within the

tag can be styled to display in columns, allowing for a more visually appealing layout.

4. Creating Modal Boxes: The

tag can be used to create modal boxes or pop-up windows on a web page. While not directly used for this purpose in the provided code snippet, the

tag can be styled and manipulated using JavaScript to create modal boxes for displaying additional information or interactive elements.

5. Applying CSS and Styling: The

tag can be used as a target for applying specific CSS and styling. By assigning classes or IDs to

elements, developers can apply custom styles to the content within the

tag, allowing for greater control over the visual presentation of the web page.

Overall, the

tag is a fundamental building block in HTML, providing developers with a flexible tool for structuring and styling web page content. Its versatility makes it an essential element in web development, allowing for a wide range of use cases to create visually appealing and functional web pages.

2024-01-21T08:24:19+01:00