Update README.md
Browse files
README.md
CHANGED
@@ -1,23 +1,152 @@
|
|
1 |
---
|
2 |
-
base_model: unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit
|
3 |
language:
|
4 |
-
-
|
5 |
license: apache-2.0
|
|
|
6 |
tags:
|
7 |
- text-generation-inference
|
8 |
-
- transformers
|
9 |
- unsloth
|
10 |
- llama
|
|
|
11 |
- trl
|
12 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
---
|
14 |
|
15 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
- **License:** apache-2.0
|
19 |
-
- **Finetuned from model :** unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit
|
20 |
|
21 |
-
|
22 |
|
23 |
-
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
1 |
---
|
|
|
2 |
language:
|
3 |
+
- it
|
4 |
license: apache-2.0
|
5 |
+
library_name: transformers
|
6 |
tags:
|
7 |
- text-generation-inference
|
|
|
8 |
- unsloth
|
9 |
- llama
|
10 |
+
- llama3.1
|
11 |
- trl
|
12 |
+
- word-game
|
13 |
+
- rebus
|
14 |
+
- italian
|
15 |
+
- word-puzzle
|
16 |
+
- crossword
|
17 |
+
datasets:
|
18 |
+
- gsarti/eureka-rebus
|
19 |
+
base_model: unsloth/Meta-Llama-3.1-8B-bnb-4bit
|
20 |
+
|
21 |
+
model-index:
|
22 |
+
- name: gsarti/llama-3.1-8b-rebus-solver-fp16
|
23 |
+
results:
|
24 |
+
- task:
|
25 |
+
type: verbalized-rebus-solving
|
26 |
+
name: Verbalized Rebus Solving
|
27 |
+
dataset:
|
28 |
+
type: gsarti/eureka-rebus
|
29 |
+
name: EurekaRebus
|
30 |
+
config: llm_sft
|
31 |
+
split: test
|
32 |
+
revision: 0f24ebc3b66cd2f8968077a5eb058be1d5af2f05
|
33 |
+
metrics:
|
34 |
+
- type: exact_match
|
35 |
+
value: 0.59
|
36 |
+
name: First Pass Exact Match
|
37 |
+
- type: exact_match
|
38 |
+
value: 0.56
|
39 |
+
name: Solution Exact Match
|
40 |
---
|
41 |
|
42 |
+
# LLaMA-3.1 8B Verbalized Rebus Solver 🇮🇹
|
43 |
+
|
44 |
+
This model is a parameter-efficient fine-tuned version of LLaMA-3.1 8B trained for verbalized rebus solving in Italian, as part of the [release](https://huggingface.co/collections/gsarti/verbalized-rebus-clic-it-2024-66ab8f11cb04e68bdf4fb028) for our paper [Non Verbis, Sed Rebus: Large Language Models are Weak Solvers of Italian Rebuses](https://arxiv.org/abs/2408.00584). The task of verbalized rebus solving consists of converting an encrypted sequence of letters and crossword definitions into a solution phrase matching the word lengths specified in the solution key. An example is provided below.
|
45 |
+
|
46 |
+
The model was trained in 4-bit precision for 5070 steps on the verbalized subset of the [EurekaRebus](https://huggingface.co/datasets/gsarti/eureka-rebus) using QLora via [Unsloth](https://github.com/unslothai/unsloth) and [TRL](https://github.com/huggingface/trl). This version has merged adapter weights in half precision, enabling out-of-the-box for usage with the `transformers` library.
|
47 |
+
|
48 |
+
We also provide [adapter checkpoints through training](https://huggingface.co/gsarti/llama-3.1-8b-rebus-solver-adapters) and [8-bit GGUF](https://huggingface.co/gsarti/gsarti/llama-3.1-8b-rebus-solver-Q8_0-GGUF) versions of this model for analysis and local execution.
|
49 |
+
|
50 |
+
## Using the Model
|
51 |
+
|
52 |
+
The following example shows how to perform inference using Unsloth or Transformers:
|
53 |
+
|
54 |
+
```python
|
55 |
+
|
56 |
+
# With Unsloth (efficient, requires GPU)
|
57 |
+
from unsloth import FastLanguageModel
|
58 |
+
|
59 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
60 |
+
model_name = "gsarti/llama-3.1-8b-rebus-solver-fp16",
|
61 |
+
max_seq_length = 1248,
|
62 |
+
load_in_4bit = True,
|
63 |
+
)
|
64 |
+
|
65 |
+
# Or with Transformers
|
66 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
67 |
+
|
68 |
+
tokenizer = AutoTokenizer.from_pretrained("gsarti/llama-3.1-8b-rebus-solver-fp16")
|
69 |
+
model = AutoModelForCausalLM.from_pretrained("gsarti/llama-3.1-8b-rebus-solver-fp16")
|
70 |
+
|
71 |
+
# Inference
|
72 |
+
verbalized_rebus = "[Materiale espulso dai vulcani] R O [Strumento del calzolaio] [Si trovano ai lati del bacino] C I [Si ingrassano con la polenta] E I N [Contiene scorte di cibi] B [Isola in francese]"
|
73 |
+
solution_key = "1 ' 5 6 5 3 3 1 14"
|
74 |
+
template = """<|begin_of_text|><|start_header_id|>user<|end_header_id|>
|
75 |
+
|
76 |
+
Risolvi gli indizi tra parentesi per ottenere una prima lettura, e usa la chiave di lettura per ottenere la soluzione del rebus.
|
77 |
+
|
78 |
+
Rebus: {rebus}
|
79 |
+
Chiave risolutiva: {key}<|eot_id|><|start_header_id|>assistant<|end_header_id|>"""
|
80 |
+
input = template.format(rebus=verbalized_rebus, key=solution_key)
|
81 |
+
inputs = tokenizer(input, return_tensors="pt")["input_ids"]
|
82 |
+
outputs = model.generate(input_ids = inputs, max_new_tokens = 500, use_cache = True)
|
83 |
+
model_generations = tokenizer.batch_decode(outputs)
|
84 |
+
print(model_generations[0])
|
85 |
+
|
86 |
+
# Procediamo alla risoluzione del rebus passo per passo:
|
87 |
+
# - [Materiale espulso dai vulcani] = lava
|
88 |
+
# - R O = R O
|
89 |
+
# - [Strumento del calzolaio] = lesina
|
90 |
+
# - [Si trovano ai lati del bacino] = anche
|
91 |
+
# - C I = C I
|
92 |
+
# - [Si ingrassano con la polenta] = oche
|
93 |
+
# - E I N = E I N
|
94 |
+
# - [Contiene scorte di cibi] = dispensa
|
95 |
+
# - B = B
|
96 |
+
# - [Isola in francese] = ile
|
97 |
+
#
|
98 |
+
# Prima lettura: lava R O lesina anche C I oche E I N silos B ile
|
99 |
+
#
|
100 |
+
# Ora componiamo la soluzione seguendo la chiave risolutiva:
|
101 |
+
# 1 = L
|
102 |
+
# ' = '
|
103 |
+
# 5 = avaro
|
104 |
+
# 6 = lesina
|
105 |
+
# 5 = anche
|
106 |
+
# 3 = ciò
|
107 |
+
# 3 = che
|
108 |
+
# 1 = è
|
109 |
+
# 14 = indispensabile
|
110 |
+
#
|
111 |
+
# Soluzione: L'avaro lesina anche ciò che è indispensabile
|
112 |
+
```
|
113 |
+
|
114 |
+
See the official [code release](https://github.com/gsarti/verbalized-rebus) for more examples.
|
115 |
+
|
116 |
+
### Local usage with Ollama
|
117 |
+
|
118 |
+
A ready-to-use local version of this model is hosted on the [Ollama Hub](https://ollama.com/gsarti/llama3.1-8b-rebus-solver) and can be used as follows:
|
119 |
+
|
120 |
+
```shell
|
121 |
+
ollama run gsarti/llama3.1-8b-rebus-solver "Rebus: [Materiale espulso dai vulcani] R O [Strumento del calzolaio] [Si trovano ai lati del bacino] C I [Si ingrassano con la polenta] E I N [Contiene scorte di cibi] B [Isola in francese]\nChiave risolutiva: 1 ' 5 6 5 3 3 1 14"
|
122 |
+
```
|
123 |
+
|
124 |
+
## Limitations
|
125 |
+
|
126 |
+
**Lexical overfitting**: As remarked in the related publication, the model overfitted the set of definitions/answers for first pass words. As a result, words that were [explicitly witheld](https://huggingface.co/datasets/gsarti/eureka-rebus/blob/main/ood_words.txt) from the training set cause significant performance degradation when used as solutions for verbalized rebuses' definitions. You can compare model performances between [in-domain](https://huggingface.co/datasets/gsarti/eureka-rebus/blob/main/id_test.jsonl) and [out-of-domain](https://huggingface.co/datasets/gsarti/eureka-rebus/blob/main/ood_test.jsonl) test examples to verify this limitation.
|
127 |
+
|
128 |
+
## Model curators
|
129 |
+
|
130 |
+
For problems or updates on this model, please contact [gabriele.sarti996@gmail.com](mailto:gabriele.sarti996@gmail.com).
|
131 |
+
|
132 |
+
### Citation Information
|
133 |
+
|
134 |
+
If you use this model in your work, please cite our paper as follows:
|
135 |
+
|
136 |
+
```bibtex
|
137 |
+
@article{sarti-etal-2024-rebus,
|
138 |
+
title = "Non Verbis, Sed Rebus: Large Language Models are Weak Solvers of Italian Rebuses",
|
139 |
+
author = "Sarti, Gabriele and Caselli, Tommaso and Nissim, Malvina and Bisazza, Arianna",
|
140 |
+
journal = "ArXiv",
|
141 |
+
month = jul,
|
142 |
+
year = "2024",
|
143 |
+
volume = {abs/2408.00584},
|
144 |
+
url = {https://arxiv.org/abs/2408.00584},
|
145 |
+
}
|
146 |
+
```
|
147 |
|
148 |
+
## Acknowledgements
|
|
|
|
|
149 |
|
150 |
+
We are grateful to the [Associazione Culturale "Biblioteca Enigmistica Italiana - G. Panini"](http://www.enignet.it/home) for making its rebus collection freely accessible on the [Eureka5 platform](http://www.eureka5.it).
|
151 |
|
152 |
+
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|