munish0838
commited on
Commit
•
76b5637
1
Parent(s):
f27995a
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: llama3
|
3 |
+
language:
|
4 |
+
- de
|
5 |
+
library_name: transformers
|
6 |
+
base_model: DiscoResearch/Llama3-German-8B
|
7 |
+
pipeline_tag: text-generation
|
8 |
+
---
|
9 |
+
|
10 |
+
# Llama3-German-8B-GGUF
|
11 |
+
|
12 |
+
This is quantized version of [DiscoResearch/Llama3-German-8B](https://huggingface.co/DiscoResearch/Llama3-German-8B) created using llama.cpp
|
13 |
+
|
14 |
+
## Model Description
|
15 |
+
|
16 |
+
Llama3-German-8B-v0.1 is a large language model based on [Meta's Llama3-8B](https://huggingface.co/meta-llama/Meta-Llama-3-8B). It is specialized for the German language through continuous pretraining on 65 billion high-quality tokens, similar to previous [LeoLM](https://huggingface.co/LeoLM) or [Occiglot](https://huggingface.co/collections/occiglot/occiglot-eu5-7b-v01-65dbed502a6348b052695e01) models.
|
17 |
+
|
18 |
+
Llama3 itself was trained on 15T tokens, of which only <1T were multilingual, resulting in suboptimal performance in German with reduced linguistic capabilities and frequent grammatical errors, motivating the necessity for continued pretraining. Benchmark results on our model show minimal degradation in English performance, despite the absence of replay during training. Importantly, Llama3-German-8B-v0.1 demonstrates strong improvements in German, particularly on the Hellaswag benchmark, which measures linguistic understanding and general reasoning.
|
19 |
+
|
20 |
+
[DiscoResearch/Llama3-German-8B-v0.1](https://huggingface.co/collections/DiscoResearch/discoleo-8b-llama3-for-german-6650527496c0fafefd4c9729) is the result of a joint effort between [DiscoResearch](https://huggingface.co/DiscoResearch) and [Occiglot](https://huggingface.co/occiglot) with support from the [DFKI](https://www.dfki.de/web/) (German Research Center for Artificial Intelligence) and [hessian.Ai](https://hessian.ai). Occiglot kindly handled data preprocessing, filtering, and deduplication as part of their latest [dataset release](https://huggingface.co/datasets/occiglot/occiglot-fineweb-v0.5), as well as sharing their compute allocation at hessian.Ai's 42 Supercomputer.
|
21 |
+
|
22 |
+
## How to use
|
23 |
+
This is a base model and should probably be subject to finetuning before use. See our [collection](https://huggingface.co/collections/DiscoResearch/discoleo-8b-llama3-for-german-6650527496c0fafefd4c9729) for various finetuned and long-context versions.
|
24 |
+
|
25 |
+
## Model Training and Hyperparameters
|
26 |
+
The model was trained on 128 GPUs on [hessian.Ai 42](hessian.ai) for ~60 hours. See detailed hyperparameters below.
|
27 |
+
|
28 |
+
| Parameter | Value |
|
29 |
+
|-------------------|-----------------------------------|
|
30 |
+
| Sequence Length | 8192 tokens |
|
31 |
+
| Learning Rate | 1.5e-5 to 1.5e-6 (cosine schedule)|
|
32 |
+
| Batch Size | 4194304 (512*8192) tokens |
|
33 |
+
| Micro Batch Size | 4*8192 tokens |
|
34 |
+
| Training Steps | 15500 |
|
35 |
+
| Warmup Steps | 155 (1%) |
|
36 |
+
| Weight Decay | 0.05 |
|
37 |
+
| Optimizer | AdamW |
|
38 |
+
|
39 |
+
|
40 |
+
## Data Collection and Preprocessing
|
41 |
+
|
42 |
+
For pre-training, we used 65B German tokens from the [occiglot-fineweb-0.5](https://huggingface.co/datasets/occiglot/occiglot-fineweb-v0.5) dataset.
|
43 |
+
The data comprises multiple curated datasets from [LLM-Datasets](https://github.com/malteos/llm-datasets) as well as 12 [Common-Crawl](https://commoncrawl.org) releases that were processed with [OSCAR's Ungoliant pipeline](https://github.com/oscar-project/ungoliant).
|
44 |
+
|
45 |
+
All data was further filtered with a set of language-specific filters based on [Huggingface's fine-web](https://github.com/huggingface/datatrove/blob/main/examples/fineweb.py) and globally deduplicated.
|
46 |
+
|
47 |
+
For more information please refer to the [dataset card](https://huggingface.co/datasets/occiglot/occiglot-fineweb-v0.5) and corresponding [blog-post](https://occiglot.eu/posts/occiglot-fineweb/).
|
48 |
+
|
49 |
+
## Evaluation and Results
|
50 |
+
|
51 |
+
We evaluated the model using a suite of common English Benchmarks and their German counterparts with [GermanBench](https://github.com/bjoernpl/GermanBenchmark).
|
52 |
+
|
53 |
+
The following figure shows the benchmark results in comparison to the base model [meta-llama/Meta-Llama3-8B](https://huggingface.co/meta-llama/Meta-Llama-3-8B) and two different hyperparameter configurations.
|
54 |
+
We swept different learning rates to identify a well-working setup. The final released model is the 1.5e-5 lr version.
|
55 |
+
![alt text](base_model_evals.png)
|
56 |
+
|
57 |
+
Find the detailed benchmark scores for the base and long-context models in this table.
|
58 |
+
|
59 |
+
| Model | truthful_qa_de | truthfulqa_mc | arc_challenge | arc_challenge_de | hellaswag | hellaswag_de | MMLU | MMLU-DE | mean |
|
60 |
+
|--------------------------------------|----------------|---------------|---------------|------------------|-----------|--------------|--------|---------|------------|
|
61 |
+
| DiscoResearch/Llama3-German-8B | **0.49499** | 0.44838 | 0.55802 | **0.49829** | 0.79924 | **0.65395** | 0.62240| **0.54413** | **0.57743** |
|
62 |
+
| DiscoResearch/Llama3-German-8B-32k | 0.48920 | **0.45138** | 0.54437 | 0.49232 | 0.79078 | 0.64310 | 0.58774| 0.47971 | 0.55982 |
|
63 |
+
| meta-llama/Meta-Llama-3-8B-Instruct | 0.47498 | 0.43923 | **0.59642** | 0.47952 | **0.82025**| 0.60008 | **0.66658**| 0.53541 | 0.57656 |
|
64 |
+
|
65 |
+
## Long-Context Extension
|
66 |
+
|
67 |
+
In addition to the base model, we release a long-context version of Llama3-German-8B ([DiscoResearch/Llama3-German-8B-32k](https://huggingface.co/DiscoResearch/Llama3-German-8B-32k) capable of processing context lengths up to 65k tokens. This variant was trained on an additional 100 million tokens at 32k context length, using a rope_theta value of `1.5e6` and a learning rate of `1.5e-5` with a batch size of `256*8192` tokens and otherwise equal hyperparameters to the base model.
|
68 |
+
|
69 |
+
## Instruction Tuning
|
70 |
+
|
71 |
+
We also provide an instruction-tuned version: [DiscoResearch/Llama3-DiscoLeo-Instruct-8B-v0.1](https://huggingface.co/DiscoResearch/Llama3-DiscoLeo-Instruct-8B-v0.1), utilizing the DiscoLM German dataset for fine-tuning (also available as a long-context model at [DiscoResearch/Llama3-DiscoLeo-Instruct-8B-32k-v0.1](https://huggingface.co/DiscoResearch/Llama3-DiscoLeo-Instruct-8B-v0.1)).
|
72 |
+
Find more details in the respective model cards. Also check out our experimental merge ([DiscoResearch/Llama3-DiscoLeo-8B-DARE-Experimental](https://huggingface.co/DiscoResearch/Llama3-DiscoLeo-8B-DARE-Experimental)) between [meta-llama/Meta-Llama3-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) and our finetuned model in an attempt to keep the extraordinary capabilities of Llama3-Instruct and add exceptional German skills.
|
73 |
+
|
74 |
+
## Document Packing
|
75 |
+
|
76 |
+
We employed a more intelligent document packing strategy based on the ["Fewer Truncations Improve Language Modeling" paper by Ding et al.](https://arxiv.org/abs/2404.10830v2), using the first-fit-decreasing algorithm to pack documents into batches without truncation.
|
77 |
+
We packed our data in chunks of 10000 documents for more efficient processing while maintaining >99% packing efficiency. Documents longer than the sequence length are split into chunks of sequence length.
|
78 |
+
|
79 |
+
This approach results in overall higher benchmark scores when training on the same data with equal hyperparameters. The following numbers are from initial experiments with `3e-5 lr` and 12k steps and show improvements comparable to those shown in the original paper.
|
80 |
+
|
81 |
+
| Task | Naive Packing | Fewer Truncations Packing | Percentage Increase |
|
82 |
+
|-------------------|---------------|---------------------------|---------------------|
|
83 |
+
| truthfulqa_mc | 0.452648 | 0.467687 | 3.32% |
|
84 |
+
| arc_challenge | 0.517918 | 0.528157 | 1.98% |
|
85 |
+
| truthful_qa_de | 0.485529 | 0.492979 | 1.53% |
|
86 |
+
| arc_challenge_de | 0.480375 | 0.493174 | 2.66% |
|
87 |
+
| hellaswag | 0.776041 | 0.773352 | -0.35% |
|
88 |
+
| hellaswag_de | 0.655248 | 0.653356 | -0.29% |
|
89 |
+
| MMLU | 0.573719 | 0.579802 | 1.06% |
|
90 |
+
| MMLU-DE | 0.504509 | 0.503863 | -0.13% |
|
91 |
+
|
92 |
+
The following is our simple implementation of the first-fit-decreasing algorithm described in the paper.
|
93 |
+
```python
|
94 |
+
def pack_documents(tokenized_documents):
|
95 |
+
# Sort documents by their length in descending order
|
96 |
+
sorted_docs = sorted(tokenized_documents, key=len, reverse=True)
|
97 |
+
|
98 |
+
# Initialize bins
|
99 |
+
bins = []
|
100 |
+
|
101 |
+
# Function to find the first bin that can accommodate the document
|
102 |
+
def find_bin(doc):
|
103 |
+
for b in bins:
|
104 |
+
if sum(len(d) for d in b) + len(doc) <= 8192:
|
105 |
+
return b
|
106 |
+
return None
|
107 |
+
|
108 |
+
# Place each document in the first available bin or create a new bin
|
109 |
+
for doc in sorted_docs:
|
110 |
+
target_bin = find_bin(doc)
|
111 |
+
if target_bin is not None:
|
112 |
+
target_bin.append(doc)
|
113 |
+
else:
|
114 |
+
# Create a new bin with this document if no suitable bin is found
|
115 |
+
bins.append([doc])
|
116 |
+
|
117 |
+
# Return results
|
118 |
+
return bins
|
119 |
+
```
|
120 |
+
|
121 |
+
## Model Configurations
|
122 |
+
|
123 |
+
We release DiscoLeo-8B in the following configurations:
|
124 |
+
1. [Base model with continued pretraining](https://huggingface.co/DiscoResearch/Llama3-German-8B)
|
125 |
+
2. [Long-context version (32k context length)](https://huggingface.co/DiscoResearch/Llama3-German-8B-32k)
|
126 |
+
3. [Instruction-tuned version of the base model](https://huggingface.co/DiscoResearch/Llama3-DiscoLeo-Instruct-8B-v0.1)
|
127 |
+
4. [Instruction-tuned version of the long-context model](https://huggingface.co/DiscoResearch/Llama3-DiscoLeo-Instruct-8B-32k-v0.1)
|
128 |
+
5. [Experimental `DARE-TIES` Merge with Llama3-Instruct](https://huggingface.co/DiscoResearch/Llama3-DiscoLeo-8B-DARE-Experimental)
|
129 |
+
6. [Collection of Quantized versions](https://huggingface.co/collections/DiscoResearch/discoleo-8b-quants-6651bcf8f72c9a37ce485d42)
|
130 |
+
|
131 |
+
## How to use:
|
132 |
+
Here's how to use the model with transformers:
|
133 |
+
```python
|
134 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
135 |
+
import torch
|
136 |
+
|
137 |
+
device="cuda"
|
138 |
+
|
139 |
+
model = AutoModelForCausalLM.from_pretrained(
|
140 |
+
"DiscoResearch/Llama3-DiscoLeo-Instruct-8B-v0.1",
|
141 |
+
torch_dtype="auto",
|
142 |
+
device_map="auto"
|
143 |
+
)
|
144 |
+
tokenizer = AutoTokenizer.from_pretrained("DiscoResearch/Llama3-DiscoLeo-Instruct-8B-v0.1")
|
145 |
+
|
146 |
+
prompt = "Schreibe ein Essay über die Bedeutung der Energiewende für Deutschlands Wirtschaft"
|
147 |
+
messages = [
|
148 |
+
{"role": "system", "content": "Du bist ein hilfreicher Assistent."},
|
149 |
+
{"role": "user", "content": prompt}
|
150 |
+
]
|
151 |
+
text = tokenizer.apply_chat_template(
|
152 |
+
messages,
|
153 |
+
tokenize=False,
|
154 |
+
add_generation_prompt=True
|
155 |
+
)
|
156 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
157 |
+
|
158 |
+
generated_ids = model.generate(
|
159 |
+
model_inputs.input_ids,
|
160 |
+
max_new_tokens=512
|
161 |
+
)
|
162 |
+
generated_ids = [
|
163 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
164 |
+
]
|
165 |
+
|
166 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
167 |
+
```
|
168 |
+
|
169 |
+
## Acknowledgements
|
170 |
+
|
171 |
+
The model was trained and evaluated by [Björn Plüster](https://huggingface.co/bjoernp) ([DiscoResearch](https://huggingface.co/DiscoResearch), [ellamind](https://ellamind.com)) with data preparation and project supervision by [Manuel Brack](http://manuel-brack.eu) ([DFKI](https://www.dfki.de/web/), [TU-Darmstadt](https://www.tu-darmstadt.de/)). Initial work on dataset collection and curation was performed by [Malte Ostendorff](https://ostendorff.org) and [Pedro Ortiz Suarez](https://portizs.eu). Instruction tuning was done with the DiscoLM German dataset created by [Jan-Philipp Harries](https://huggingface.co/jphme) and [Daniel Auras](https://huggingface.co/rasdani) ([DiscoResearch](https://huggingface.co/DiscoResearch), [ellamind](https://ellamind.com)). We extend our gratitude to [LAION](https://laion.ai/) and friends, especially [Christoph Schuhmann](https://entwickler.de/experten/christoph-schuhmann) and [Jenia Jitsev](https://huggingface.co/JJitsev), for initiating this collaboration.
|
172 |
+
|
173 |
+
The model training was supported by a compute grant at the [42 supercomputer](https://hessian.ai/) which is a central component in the development of [hessian AI](https://hessian.ai/), the [AI Innovation Lab](https://hessian.ai/infrastructure/ai-innovationlab/) (funded by the [Hessian Ministry of Higher Education, Research and the Art (HMWK)](https://wissenschaft.hessen.de) & the [Hessian Ministry of the Interior, for Security and Homeland Security (HMinD)](https://innen.hessen.de)) and the [AI Service Centers](https://hessian.ai/infrastructure/ai-service-centre/) (funded by the [German Federal Ministry for Economic Affairs and Climate Action (BMWK)](https://www.bmwk.de/Navigation/EN/Home/home.html)).
|
174 |
+
The curation of the training data is partially funded by the [German Federal Ministry for Economic Affairs and Climate Action (BMWK)](https://www.bmwk.de/Navigation/EN/Home/home.html)
|
175 |
+
through the project [OpenGPT-X](https://opengpt-x.de/en/) (project no. 68GX21007D).
|