File size: 3,605 Bytes
1bbb032
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f258cf1
 
 
 
 
 
 
 
 
 
 
 
 
9f42f16
f258cf1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f42f16
f258cf1
 
 
 
1bbb032
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
115
116
117
118
119
---
language:
- mt
base_model: utter-project/EuroLLM-1.7B
pipeline_tag: text-generation
tags:
- maltese
- malti
- continued-pretraining
datasets:
- MLRS/korpus_malti
- saillab/alpaca-maltese-cleaned
- CohereForAI/aya_collection
---

# Fredu 1.7B Instruct

A Maltese-specialised model built from `utter-project/EuroLLM-1.7B` in two stages
on a single consumer GPU (RTX 5060 Ti, 16 GB).

It is fluent in Maltese but hallucinates and does not always reply with anything related to the prompt.
It's able to translate english sentences into a related sentence in Maltese. It's quite bad at it but the Maltese translation is related somehow.

## How to run

### Ollama

```sh
ollama run hf.co/Cabbache/Fredu-1.7B-Instruct
```

The prompt template and sampling parameters are stored in the repo, so nothing
else is needed. Pick a build with a tag:

| tag | size | notes |
|---|---|---|
| *(none)* / `:Q4_K_M` | 1.0 GB | 4-bit, the default. |
| `:Q8_0` | 1.8 GB | 8-bit, close to full quality |
| `:F16` | 3.3 GB | no quantization |


### transformers

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

tok = AutoTokenizer.from_pretrained("Cabbache/Fredu-1.7B-Instruct")
model = AutoModelForCausalLM.from_pretrained("Cabbache/Fredu-1.7B-Instruct",
                                             dtype="bfloat16", device_map="auto")

q = "X'inhu l-Kunsill Lokali f'Malta?"
ids = tok(f"Mistoqsija: {q}\nTweġiba:", return_tensors="pt").to(model.device)
out = model.generate(**ids, max_new_tokens=200, temperature=0.3, do_sample=True)
print(tok.decode(out[0], skip_special_tokens=True))
```

There is no chat template. Use the `Mistoqsija:/Tweġiba:` framing above, which
is what the model was trained on. A low temperature helps: what factual
knowledge it has is held with very little margin and does not survive sampling
at 0.7.

## What was done

| stage | data | result |
|---|---|---|
| Continued pretraining | 336M tokens, 125,900 documents from Korpus Malti | perplexity 8.29 → 5.98 |
| Supervised fine-tuning | 43,988 Maltese question/answer pairs | answer-loss 1.70 → 1.40 |

Both stages were full fine-tunes (all 1.657B parameters), bf16 weights and
gradients with 8-bit AdamW and gradient checkpointing, ~14 GB VRAM.

## Prompt format

The model was trained on this exact framing, with loss computed **only** on the
answer:

```
Mistoqsija: {question}
Tweġiba: {answer}
```

## It reads informal Maltese and replies in correct Maltese

35% of training questions had their diacritics stripped (`ħ→h, ġ→g, ċ→c, ż→z`,
so `għ→gh`) while every answer was left correct. Because loss lands only on the
answer, the model is shown informal spelling and never rewarded for producing it.

```
Q: X'inhu n-numru medju ta' sighat ta' rqad li persuna ghandha tiehu?
A: In-numru medju ta' sigħat ta' rqad li persuna għandha tieħu huwa madwar
   7.5 sigħat kuljum.
```

Note `sighat → sigħat`, `ghandha → għandha`, `tiehu → tieħu`.

## Evaluation

Perplexity on held-out documents, by register, against the untrained base:

| source | base | this model | change |
|---|---|---|---|
| government gazette | 7.84 | 2.97 | −62.1% |
| parliament | 6.89 | 3.19 | −53.6% |
| press | 7.72 | 6.01 | −22.1% |
| academic | 12.61 | 10.38 | −17.7% |
| blogs | 10.43 | 8.93 | −14.4% |
| wikipedia | 6.51 | 6.06 | −6.9% |

A 57-item Malta factual eval (greedy decoding, an upper bound on knowledge):

| | this model | base |
|---|---|---|
| overall | **27/57** | 22/57 |
| history | **12/13** | 8/13 |
| geography | 4/17 | 6/17 |

## Licence

Do whatever you want with it