rpand002 commited on
Commit
87dbf20
1 Parent(s): 6004a31

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +94 -3
README.md CHANGED
@@ -1,3 +1,94 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ tags:
5
+ - language
6
+ - granite-3.1
7
+ ---
8
+
9
+ # Granite-3.1-2B-Base
10
+
11
+ **Model Summary:**
12
+ Granite-3.1-2B-Base extends the context length of Granite-3.0-2B-Base from 4K to 128K using a progressive training strategy by increasing the supported context length in increments while adjusting RoPE theta until the model has successfully adapted to desired length of 128K. This long-context pre-training stage was performed using approximately 500B tokens.
13
+
14
+ - **Developers:** Granite Team, IBM
15
+ - **GitHub Repository:** [ibm-granite/granite-3.1-language-models](https://github.com/ibm-granite/granite-3.1-language-models)
16
+ - **Website**: [Granite Docs](https://www.ibm.com/granite/docs/)
17
+ - **Paper:** [Granite 3.1 Language Models (coming soon)](https://huggingface.co/collections/ibm-granite/granite-31-language-models-6751dbbf2f3389bec5c6f02d)
18
+ - **Release Date**: December 18th, 2024
19
+ - **License:** [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
20
+
21
+ **Supported Languages:**
22
+ English, German, Spanish, French, Japanese, Portuguese, Arabic, Czech, Italian, Korean, Dutch, and Chinese. Users may finetune Granite 3.1 models for languages beyond these 12 languages.
23
+
24
+ **Intended Use:**
25
+ Prominent use cases of LLMs in text-to-text generation include summarization, text classification, extraction, question-answering, and other long-context tasks. All Granite Base models are able to handle these tasks as they were trained on a large amount of data from various domains. Moreover, they can serve as baseline to create specialized models for specific application scenarios.
26
+
27
+ **Generation:**
28
+ This is a simple example of how to use Granite-3.1-2B-Base model.
29
+
30
+ Install the following libraries:
31
+
32
+ ```shell
33
+ pip install torch torchvision torchaudio
34
+ pip install accelerate
35
+ pip install transformers
36
+ ```
37
+ Then, copy the code snippet below to run the example.
38
+
39
+ ```python
40
+ from transformers import AutoModelForCausalLM, AutoTokenizer
41
+ device = "auto"
42
+ model_path = "ibm-granite/Granite-3.1-2B-base"
43
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
44
+ # drop device_map if running on CPU
45
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
46
+ model.eval()
47
+ # change input text as desired
48
+ input_text = "Where is the Thomas J. Watson Research Center located?"
49
+ # tokenize the text
50
+ input_tokens = tokenizer(input_text, return_tensors="pt").to(device)
51
+ # generate output tokens
52
+ output = model.generate(**input_tokens,
53
+ max_length=4000)
54
+ # decode output tokens into text
55
+ output = tokenizer.batch_decode(output)
56
+ # print output
57
+ print(output)
58
+ ```
59
+
60
+ **Model Architecture:**
61
+ Granite-3.1-2B-Base is based on a decoder-only dense transformer architecture. Core components of this architecture are: GQA and RoPE, MLP with SwiGLU, RMSNorm, and shared input/output embeddings.
62
+
63
+ | Model | 2B Dense | 8B Dense | 1B MoE | 3B MoE |
64
+ | :-------- | :--------| :-------- | :------| :------|
65
+ | Embedding size | **2048** | 4096 | 1024 | 1536 |
66
+ | Number of layers | **40** | 40 | 24 | 32 |
67
+ | Attention head size | **64** | 128 | 64 | 64 |
68
+ | Number of attention heads | **32** | 32 | 16 | 24 |
69
+ | Number of KV heads | **8** | 8 | 8 | 8 |
70
+ | MLP hidden size | **8192** | 12800 | 512 | 512 |
71
+ | MLP activation | **SwiGLU** | SwiGLU | SwiGLU | SwiGLU |
72
+ | Number of experts | **—** | — | 32 | 40 |
73
+ | MoE TopK | **—** | — | 8 | 8 |
74
+ | Initialization std | **0.1** | 0.1 | 0.1 | 0.1 |
75
+ | Sequence length | **128K** | 128K | 128K | 128K |
76
+ | Position embedding | **RoPE** | RoPE | RoPE | RoPE |
77
+ | # Parameters | **2.5B** | 8.1B | 1.3B | 3.3B |
78
+ | # Active parameters | **2.5B** | 8.1B | 400M | 800M |
79
+ | # Training tokens | **12T** | 12T | 10T | 10T |
80
+
81
+ **Training Data:**
82
+ This model is trained on a mix of open source and proprietary data following a three-stage training strategy.
83
+ * Stage 1 data: The data for stage 1 is sourced from diverse domains, such as: web, code, academic sources, books, and math data.
84
+ * Stage 2 data: The data for stage 2 comprises a curated mix of high-quality data from the same domains, plus multilingual and instruction data. The goal of this second training phase is to enhance the model’s performance on specific tasks.
85
+ * Stage 3 data: The data for stage 3 consists of original stage-2 pretraining data with additional synthetic long-context data in form of QA/summary pairs where the answer
86
+ contains a recitation of the related paragraph before the answer.
87
+
88
+ A detailed attribution of datasets can be found in the [Granite 3.0 Technical Report](https://github.com/ibm-granite/granite-3.0-language-models/blob/main/paper.pdf), [Granite 3.1 Technical Report (coming soon)](https://huggingface.co/collections/ibm-granite/granite-31-language-models-6751dbbf2f3389bec5c6f02d), and [Accompanying Author List](https://github.com/ibm-granite/granite-3.0-language-models/blob/main/author-ack.pdf).
89
+
90
+ **Infrastructure:**
91
+ We train Granite 3.1 Language Models using IBM's super computing cluster, Blue Vela, which is outfitted with NVIDIA H100 GPUs. This cluster provides a scalable and efficient infrastructure for training our models over thousands of GPUs.
92
+
93
+ **Ethical Considerations and Limitations:**
94
+ The use of Large Language Models involves risks and ethical considerations people must be aware of, including but not limited to: bias and fairness, misinformation, and autonomous decision-making. Granite-3.1-2B-Base model is not the exception in this regard. Even though this model is suited for multiple generative AI tasks, it has not undergone any safety alignment, there it may produce problematic outputs. Additionally, it remains uncertain whether smaller models might exhibit increased susceptibility to hallucination in generation scenarios by copying text verbatim from the training dataset due to their reduced sizes and memorization capacities. This aspect is currently an active area of research, and we anticipate more rigorous exploration, comprehension, and mitigations in this domain. Regarding ethics, a latent risk associated with all Large Language Models is their malicious utilization. We urge the community to use Granite-3.1-2B-Base model with ethical intentions and in a responsible way.