File size: 4,330 Bytes
39d92a2
f04b09b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39d92a2
 
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
6880993
f04b09b
39d92a2
f04b09b
 
 
 
 
 
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
 
f04b09b
39d92a2
f04b09b
 
 
 
39d92a2
 
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
 
 
39d92a2
f04b09b
39d92a2
f04b09b
 
 
 
 
 
39d92a2
f04b09b
 
 
39d92a2
f04b09b
 
 
 
 
39d92a2
f04b09b
 
 
 
 
 
 
39d92a2
f04b09b
 
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
 
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
39d92a2
f04b09b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
license: llama3
base_model:
- catallama/CataLlama-v0.2-Instruct-SFT
- catallama/CataLlama-v0.2-Instruct-DPO
tags:
- llama
- llama-3
- catalan
model-index:
- name: CataLlama-v0.2-Instruct-SFT-DPO-Merged
  results: []
datasets:
- catallama/Catalan-DPO-V2
- catallama/Catalan-Instruct-V2
language:
- ca
- en
pipeline_tag: text-generation
---

![](https://huggingface.co/catallama/CataLlama-v0.2-Instruct-SFT/resolve/main/CataLlama-v0.2.png)

# CataLlama-v0.2-Instruct-SFT-DPO-Merged

**CataLlama-v0.2-Instruct-SFT-DPO-Merged** is a merge between [catallama/CataLlama-v0.2-Instruct-SFT](https://huggingface.co/catallama/CataLlama-v0.2-Instruct-SFT) and [catallama/CataLlama-v0.2-Instruct-DPO](https://huggingface.co/catallama/CataLlama-v0.2-Instruct-DPO)

The resulting model scores better than it's parents on both MMLU and GSM8K.

**This is an instruction fine-tuned model, optimised with DPO, proficient on the following tasks in Catalan**

- *Information extraction (suitable for RAG)*
- *Named Entity Recognition (NER)*
- *Translation from English to Catalan and Catalan to English*
- *Summarization - both short form and long form*
- *Sentiment analysis*
- *Chat*

**Model developers** [Laurentiu Petrea](https://www.linkedin.com/in/laurentiupetrea/) based on Llama-3 from Meta.

**Model Architecture** CataLlama is an auto-regressive language model that uses an optimized transformer architecture. The tuned versions use supervised fine-tuning (SFT) and direct preference optimisation (DPO) to align with human preferences for helpfulness and safety.

**License** The model uses the llama-3 license available at: [https://llama.meta.com/llama3/license](https://llama.meta.com/llama3/license)


## Benchmarks

| Model              | CataLlama-v0.2-Instruct-DPO | CataLlama-v0.2-Instruct-SFT     | CataLlama-v0.2-Instruct-SFT-DPO-Merged     |
| ------------------ | --------------------------- | ------------------------------- | ------------------------------------------ |
| MMLU 5 shot        | 58.89                       | 59.35                           | **60.53**                                  |
| GSM8K CoT 8 shot   | 60.05                       | 76.04                           | **77.26**                                  |


### Use with transformers

See the snippet below for usage with Transformers:

**The model follows the same prompt template as Llama-3 Instruct**

```python
import transformers
import torch

model_id = "catallama/CataLlama-v0.2-Instruct-SFT-DPO-Merged"

pipeline = transformers.pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device_map="auto",
)

messages = [
    {"role": "user", "content": "Ei com estàs avui?"},
]

prompt = pipeline.tokenizer.apply_chat_template(
    messages, 
    tokenize=False, 
    add_generation_prompt=True
)

outputs = pipeline(
    prompt,
    max_new_tokens=1024,
    do_sample=True,
    temperature=0.6,
    top_p=0.9,
)

print(outputs[0]["generated_text"][len(prompt):])
```

## Merging procedure

The merge was performed between the 32 layers of the two models, excluding the embedding, norm and the head layers.

The weights of the 32 layers were merged in equal proportion simply by calculating the average of the corresponding weights from the parent models.

The embedding, norm and head layers are copied from CataLlama-v0.2-Instruct-DPO without modification.

**This was done with a custom script, without mergekit.**


## Intended Use

**Note:** This model is not intended to beat benchmarks, but to demonstrate techniques for augmenting LLMs on new languages and preserve rare languages as part of our world heritage.

**Intended Use Cases** Llama 3 is intended for commercial and research use in English. Instruction tuned models are intended for assistant-like chat, whereas pretrained models can be adapted for a variety of natural language generation tasks.

**Out-of-scope** Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in any other way that is prohibited by the Acceptable Use Policy and Llama 3 Community License. Use in languages other than English**.

**Note: Developers may fine-tune Llama 3 models for languages beyond English provided they comply with the Llama 3 Community License and the Acceptable Use Policy.