Text Generation
Transformers
Safetensors
Italian
mistral
conversational
text-generation-inference
Inference Endpoints
giux78 commited on
Commit
1dbb553
1 Parent(s): 83b439a

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +149 -0
README.md ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - mii-community/ultrafeedback-preferences-translated-ita
5
+ language:
6
+ - it
7
+ pipeline_tag: text-generation
8
+ ---
9
+ <img src="https://hoodie-creator.s3.eu-west-1.amazonaws.com/15be78c6-original.png" alt="zefiro" border="0" width="400px">
10
+
11
+
12
+
13
+ # Model Card for zefiro-7b-dpo-ITA
14
+ *Last Update: 20/02/2024*<br>
15
+
16
+
17
+ <!-- Provide a quick summary of what the model is/does. -->
18
+
19
+ Zefiro is a DPO fine tuned model for the Italian language based on [Zefiro-7b-sft-ita](https://huggingface.co/mii-community/zefiro-7b-sft-ITA).
20
+ The model can be used as base model for more specific conversationl tasks for Italian language
21
+
22
+ ## Model Details
23
+
24
+ Zefiro DPO is a porting of the [Zephyr](https://huggingface.co/HuggingFaceH4/zephyr-7b-beta) model to the italian language using the wonderful recipes
25
+ from [alignment-handbook](https://huggingface.co/alignment-handbook) . It has also taken ispiration and insights from the [Llamantino](https://huggingface.co/swap-uniba/LLaMAntino-2-chat-7b-hf-UltraChat-ITA) model
26
+ developed by Università di Bari. For the implementation we combined different approaches from the two models mentioned but also from the wondeful communtity of open source.
27
+
28
+
29
+ ## Model description
30
+
31
+ - **Model type:** A 7B parameter GPT-like model fine-tuned on a mix of publicly available, synthetic datasets.
32
+ - **Language(s) (NLP):** Primarily Italian
33
+ - **License:** Apache 2
34
+ - **Finetuned from model:** [Zefiro-7b-sft-ita](https://huggingface.co/mii-community/zefiro-7b-sft-ITA)
35
+ - **Developed by:** [giux78](https://alessandroercolani.webflow.io/)
36
+ - **Funded by:** [Business Operating System](https://www.businessos.xyz)
37
+
38
+ ## Code
39
+ Can be reproduced running this [colab](https://colab.research.google.com/drive/1styiJ7qaSdax8_YbA1uASVb9myihIOHB?usp=sharing).
40
+
41
+ ## Computation
42
+ It has been trained on one A100 from [seeweb.it](https://www.seeweb.it/) who sponsered the training. I strongly
43
+ suggest is one of the cheapest and solid GPUs provider.
44
+
45
+
46
+ ## Evaluations:
47
+
48
+ | Model | Arc-c | HellaS | MMUL | AVG |
49
+ | --- | --- | --- | --- | --- |
50
+ | Mixtral 7x8 | 52.8 | 75.1 | 70.9 | 66.26666667 |
51
+ | LLama2 70b | 49.4 | 70.9 | 65.1 | 61.8 |
52
+ | **zefiro-dpo-7b** | **52.69** | **67.09** | **50.8** | **56.86** |
53
+ | zefiro-base-7b | 51.07 | 63.47 | 52.97 | 55.83666667 |
54
+ | zefiro-sft-7b | 50.98 | 62.71 | 51.96 | 55.21666667 |
55
+ | LLama1 34B | 42.9 | 65.4 | 49.0 | 52.43333333 |
56
+
57
+
58
+ ## Intended uses & limitations
59
+
60
+ The model was initially fine-tuned on a filtered and preprocessed version of [ultrafeedback-preferences-ITA](https://huggingface.co/datasets/mii-community/ultrafeedback-preferences-translated-ita).
61
+
62
+ Here's how you can run the model using Transformers from 🤗 :
63
+
64
+ ```python
65
+ # Install transformers from source - only needed for versions <= v4.34
66
+ # pip install git+https://github.com/huggingface/transformers.git
67
+ # pip install accelerate
68
+ from transformers import AutoModelForCausalLM, AutoTokenizer
69
+
70
+ model_id = "mii-community/zefiro-7b-dpo-ITA"
71
+ model = AutoModelForCausalLM.from_pretrained(model_id)
72
+ model.to('cuda')
73
+ tokenizer = AutoTokenizer.from_pretrained(model_id, padding_side="left")
74
+
75
+
76
+ sys_prompt = "Sei un assistente disponibile, rispettoso e onesto. " \
77
+ "Rispondi sempre nel modo piu' utile possibile, pur essendo sicuro. " \
78
+ "Le risposte non devono includere contenuti dannosi, non etici, razzisti, sessisti, tossici, pericolosi o illegali. " \
79
+ "Assicurati che le tue risposte siano socialmente imparziali e positive. " \
80
+ "Se una domanda non ha senso o non e' coerente con i fatti, spiegane il motivo invece di rispondere in modo non corretto. " \
81
+ "Se non conosci la risposta a una domanda, non condividere informazioni false."
82
+
83
+ messages = [{ 'content' : sys_prompt, 'role' : 'assistant'},
84
+ {'content' : 'Crea una lista su cosa mangiare a pranzo ogni giorno della settimana a pranzo e cena', 'role' : 'user'}]
85
+
86
+
87
+ def generate_text(sys_prompt, user_prompt):
88
+ messages = [{ 'content' : sys_prompt, 'role' : 'assistant'},
89
+ {'content' : user_prompt, 'role' : 'user'}]
90
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
91
+ model_inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
92
+ generated_ids = model.generate(**model_inputs, max_new_tokens=1024)
93
+ return tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
94
+
95
+
96
+ generate_text(sys_prompt, 'cosa ne pensi della politica italiana?')
97
+ ```
98
+
99
+ ## Bias, Risks, and Limitations
100
+
101
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
102
+
103
+ Zefiro-7b-sft-ITA has not been aligned to human preferences for safety within the RLHF phase or deployed with in-the-loop filtering of responses like ChatGPT, so the model can produce problematic outputs (especially when prompted to do so).
104
+ It is also unknown what the size and composition of the corpus was used to train the base model (`mistralai/Mistral-7B-v0.1`), however it is likely to have included a mix of Web data and technical sources like books and code. See the [Falcon 180B model card](https://huggingface.co/tiiuae/falcon-180B#training-data) for an example of this.
105
+
106
+
107
+
108
+ ### Training Data
109
+
110
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
111
+
112
+ We used [UltraChat-ITA](https://huggingface.co/datasets/mii-community/ultrafeedback-translated-ita) as training data that is a filtered version of the [`UltraChat`](https://huggingface.co/datasets/stingning/ultrachat).
113
+ For translating the dataset we combined different tools and API we are also evaluating the best approach for translating many more datasets.
114
+ We have seen that the translation phase is critical and can introduce incorrect syntax and semantics.
115
+
116
+ #### Summary
117
+ Zefiro-7b-beta-ITA-v0.1 is finetuned version of mistral-7b using the zephyr approach for the italian language.
118
+
119
+ ## Citation
120
+
121
+ ```
122
+ @misc{tunstall2023zephyr,
123
+ title={Zephyr: Direct Distillation of LM Alignment},
124
+ author={Lewis Tunstall and Edward Beeching and Nathan Lambert and Nazneen Rajani and Kashif Rasul and Younes Belkada and Shengyi Huang and Leandro von Werra and Clémentine Fourrier and Nathan Habib and Nathan Sarrazin and Omar Sanseviero and Alexander M. Rush and Thomas Wolf},
125
+ year={2023},
126
+ eprint={2310.16944},
127
+ archivePrefix={arXiv},
128
+ primaryClass={cs.LG}
129
+ }
130
+
131
+ @misc{basile2023llamantino,
132
+ title={LLaMAntino: LLaMA 2 Models for Effective Text Generation in Italian Language},
133
+ author={Pierpaolo Basile and Elio Musacchio and Marco Polignano and Lucia Siciliani and Giuseppe Fiameni and Giovanni Semeraro},
134
+ year={2023},
135
+ eprint={2312.09993},
136
+ archivePrefix={arXiv},
137
+ primaryClass={cs.CL}
138
+ }
139
+
140
+ ```
141
+
142
+
143
+ ## Model Card Authors
144
+
145
+ [giux78](https://huggingface.co/giux78)
146
+
147
+ ## Model Card Contact
148
+
149
+ **ale.ercolani@gmail.com