Text Generation
Transformers
PyTorch
Italian
Inference Endpoints
stefanoscotta commited on
Commit
ab03ec0
1 Parent(s): 8be35b4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -60
README.md CHANGED
@@ -31,42 +31,92 @@ This repository contains the model merged with the LoRA adapters obtained in the
31
  ## Uses
32
 
33
  <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
34
 
35
- ### Direct Use
36
 
37
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
38
 
39
- [More Information Needed]
40
 
41
- ### Downstream Use [optional]
 
42
 
43
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
44
 
45
- [More Information Needed]
 
46
 
47
- ### Out-of-Scope Use
 
48
 
49
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
50
 
51
- [More Information Needed]
 
52
 
53
- ## Bias, Risks, and Limitations
 
54
 
55
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
 
 
 
 
 
56
 
57
- [More Information Needed]
 
 
 
58
 
59
- ### Recommendations
 
 
60
 
61
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
 
62
 
63
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
64
 
65
- ## How to Get Started with the Model
 
 
66
 
67
- Use the code below to get started with the model.
 
 
 
68
 
69
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  ## Training Details
72
 
@@ -108,8 +158,6 @@ The fine-tuning procedure was done using [LoRA](https://arxiv.org/pdf/2106.09685
108
 
109
 
110
 
111
- [More Information Needed]
112
-
113
  ## Environmental Impact
114
 
115
  <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
@@ -121,47 +169,8 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
121
  - **Cloud Provider:** Private Infrastructure
122
  - **Carbon Emitted:** 7.34 kg eq. CO2
123
 
124
- ## Technical Specifications [optional]
125
-
126
- ### Model Architecture and Objective
127
-
128
- [More Information Needed]
129
-
130
- ### Compute Infrastructure
131
-
132
- [More Information Needed]
133
-
134
- #### Hardware
135
-
136
- [More Information Needed]
137
-
138
- #### Software
139
-
140
- [More Information Needed]
141
-
142
- ## Citation [optional]
143
-
144
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
145
-
146
- **BibTeX:**
147
-
148
- [More Information Needed]
149
-
150
- **APA:**
151
-
152
- [More Information Needed]
153
-
154
- ## Glossary [optional]
155
-
156
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
157
-
158
- [More Information Needed]
159
-
160
- ## More Information [optional]
161
-
162
- [More Information Needed]
163
 
164
- ## Model Card Authors [optional]
165
 
166
  Stefano Scotta (stefano.scotta@rai.it)
167
 
 
31
  ## Uses
32
 
33
  <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
34
+ The model can be used as is to respond to simple instructions in Italian or can be further fine-tuned to perform specific tasks.
35
 
 
36
 
 
37
 
38
+ ## Bias, Risks, and Limitations
39
 
40
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
41
+ As any other LLM it is possible that the model generates content which does not correspond to the reality as well as wrong, biased, offensive and inappropriate answers.
42
 
 
43
 
44
+ ## How to Get Started with the Model
45
+ **Prompt template:**
46
 
47
+ ``` python
48
+ "Di seguito è riportata un'istruzione che descrive un compito, abbinata a un input che fornisce un ulteriore contesto. Scrivete una risposta che completi in modo appropriato la richiesta.
49
 
50
+ ### Istruzione:
51
+ {instruction}
52
 
53
+ ### Input:
54
+ {input}
55
 
56
+ ### Risposta:"
57
+ ```
58
 
59
+ **Usage:**
60
+ Use the code below to get started with the model.
61
+ ``` python
62
+ import os
63
+ import torch
64
+ import sys
65
+ from transformers import LlamaTokenizer, LlamaForCausalLM
66
 
67
+ if torch.cuda.is_available():
68
+ device = "cuda"
69
+ else:
70
+ device = "cpu"
71
 
72
+ def generate_prompt(instruction, input=None):
73
+ if input:
74
+ return f"""Di seguito è riportata un'istruzione che descrive un compito, abbinata a un input che fornisce un ulteriore contesto. Scrivete una risposta che completi in modo appropriato la richiesta.
75
 
76
+ ### Istruzione:
77
+ {instruction}
78
 
79
+ ### Input:
80
+ {input}
81
 
82
+ ### Risposta:"""
83
+ else:
84
+ return f"""Di seguito è riportata un'istruzione che descrive un compito. Scrivete una risposta che completi in modo appropriato la richiesta..
85
 
86
+ ### Istruzione:
87
+ {instruction}
88
+
89
+ ### Risposta:"""
90
 
91
+ model_name = "raicrits/OpenLLama13b_Loquace_ITA"
92
+
93
+ model = LlamaForCausalLM.from_pretrained(
94
+ model_name,
95
+ torch_dtype=torch.float16,
96
+ device_map="auto"
97
+ )
98
+
99
+ tokenizer = LlamaTokenizer.from_pretrained(model_name)
100
+
101
+ instruction = "qual'è la relazione tra i seguenti oggetti"
102
+ input = "sedia, tavolo, divano"
103
+ prompt = generate_prompt("instruction", input)
104
+ inputs = tokenizer(prompt, return_tensors="pt")
105
+ input_ids = inputs["input_ids"].to(device)
106
+
107
+ generation_output = model.generate(
108
+ input_ids=input_ids,
109
+ max_new_tokens=256,
110
+ )
111
+
112
+
113
+ output = tokenizer.decode(generation_output[0])
114
+ output = output.split("### Risposta:")[1].strip().replace("</s>","")
115
+ print(output)
116
+ ```
117
+ ``` python
118
+ "Sedia, tavolo e divano sono tutti oggetti che possono essere utilizzati per creare un'atmosfera rilassante in una stanza."
119
+ ```
120
 
121
  ## Training Details
122
 
 
158
 
159
 
160
 
 
 
161
  ## Environmental Impact
162
 
163
  <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
 
169
  - **Cloud Provider:** Private Infrastructure
170
  - **Carbon Emitted:** 7.34 kg eq. CO2
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
+ ## Model Card Authors
174
 
175
  Stefano Scotta (stefano.scotta@rai.it)
176