xellDart13 commited on
Commit
362c2e3
1 Parent(s): 1ef7554

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -169
README.md CHANGED
@@ -49,10 +49,9 @@ language:
49
  - es
50
  ---
51
 
52
- # Model Card for Model ID
53
-
54
- <!-- Provide a quick summary of what the model is/does. -->
55
 
 
56
 
57
 
58
  ## Model Details
@@ -61,185 +60,52 @@ language:
61
 
62
  <!-- Provide a longer summary of what this model is. -->
63
 
64
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
65
-
66
- - **Developed by:** [More Information Needed]
67
- - **Funded by [optional]:** [More Information Needed]
68
- - **Shared by [optional]:** [More Information Needed]
69
- - **Model type:** [More Information Needed]
70
- - **Language(s) (NLP):** [More Information Needed]
71
- - **License:** [More Information Needed]
72
- - **Finetuned from model [optional]:** [More Information Needed]
73
-
74
- ### Model Sources [optional]
75
-
76
- <!-- Provide the basic links for the model. -->
77
-
78
- - **Repository:** [More Information Needed]
79
- - **Paper [optional]:** [More Information Needed]
80
- - **Demo [optional]:** [More Information Needed]
81
 
82
  ## Uses
83
 
84
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
85
-
86
- ### Direct Use
87
-
88
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
89
-
90
- [More Information Needed]
91
-
92
- ### Downstream Use [optional]
93
-
94
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
95
-
96
- [More Information Needed]
97
-
98
- ### Out-of-Scope Use
99
-
100
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
101
-
102
- [More Information Needed]
103
-
104
- ## Bias, Risks, and Limitations
105
-
106
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
107
-
108
- [More Information Needed]
109
-
110
- ### Recommendations
111
-
112
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
113
-
114
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
115
-
116
- ## How to Get Started with the Model
117
-
118
- Use the code below to get started with the model.
119
-
120
- [More Information Needed]
121
-
122
- ## Training Details
123
-
124
- ### Training Data
125
-
126
- <!-- 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. -->
127
-
128
- [More Information Needed]
129
-
130
- ### Training Procedure
131
-
132
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
133
-
134
- #### Preprocessing [optional]
135
-
136
- [More Information Needed]
137
-
138
-
139
- #### Training Hyperparameters
140
-
141
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
142
-
143
- #### Speeds, Sizes, Times [optional]
144
-
145
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
146
-
147
- [More Information Needed]
148
 
149
- ## Evaluation
 
 
 
150
 
151
- <!-- This section describes the evaluation protocols and provides the results. -->
152
 
153
- ### Testing Data, Factors & Metrics
 
 
 
 
 
154
 
155
- #### Testing Data
 
156
 
157
- <!-- This should link to a Dataset Card if possible. -->
158
 
159
- [More Information Needed]
 
160
 
161
- #### Factors
162
 
163
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
164
 
165
- [More Information Needed]
166
 
167
- #### Metrics
168
-
169
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
170
-
171
- [More Information Needed]
172
-
173
- ### Results
174
-
175
- [More Information Needed]
176
-
177
- #### Summary
178
-
179
-
180
-
181
- ## Model Examination [optional]
182
-
183
- <!-- Relevant interpretability work for the model goes here -->
184
-
185
- [More Information Needed]
186
-
187
- ## Environmental Impact
188
-
189
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
190
-
191
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
192
-
193
- - **Hardware Type:** [More Information Needed]
194
- - **Hours used:** [More Information Needed]
195
- - **Cloud Provider:** [More Information Needed]
196
- - **Compute Region:** [More Information Needed]
197
- - **Carbon Emitted:** [More Information Needed]
198
-
199
- ## Technical Specifications [optional]
200
-
201
- ### Model Architecture and Objective
202
-
203
- [More Information Needed]
204
-
205
- ### Compute Infrastructure
206
-
207
- [More Information Needed]
208
-
209
- #### Hardware
210
-
211
- [More Information Needed]
212
-
213
- #### Software
214
-
215
- [More Information Needed]
216
-
217
- ## Citation [optional]
218
-
219
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
220
-
221
- **BibTeX:**
222
-
223
- [More Information Needed]
224
-
225
- **APA:**
226
-
227
- [More Information Needed]
228
-
229
- ## Glossary [optional]
230
-
231
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
232
-
233
- [More Information Needed]
234
-
235
- ## More Information [optional]
236
-
237
- [More Information Needed]
238
-
239
- ## Model Card Authors [optional]
240
 
241
- [More Information Needed]
 
242
 
243
- ## Model Card Contact
244
 
245
- [More Information Needed]
 
49
  - es
50
  ---
51
 
52
+ # Structure Extraction Model
 
 
53
 
54
+ nebuia_extract_small is an extraction model inspired by NuExtract. LegalExtract-ES is a version of qween 1.5b, fine-tuned on a private high-quality synthetic dataset for entity extraction in Spanish legal texts with an 8k context length. Supports JSON template like nu extract describing the information you need to extract. NebuIA Extract specializes in identifying and extracting legal entities and relevant information from Spanish legal documents.
55
 
56
 
57
  ## Model Details
 
60
 
61
  <!-- Provide a longer summary of what this model is. -->
62
 
63
+ - **Developed by:** [NebuIA](https://nebuia.com)
64
+ - **Language(s) (NLP):** es
65
+ - **License:** mit
66
+ - **Finetuned from model [optional]:** [Qween2 1.5b](https://huggingface.co/Qwen/Qwen2-1.5B-Instruct)
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  ## Uses
69
 
70
+ Same template as NuExtract
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
+ ```python
73
+ import json
74
+ from transformers import AutoModelForCausalLM, AutoTokenizer
75
+ import torch
76
 
 
77
 
78
+ def predict_extract(model, tokenizer, text, schema):
79
+ schema = json.dumps(json.loads(schema), indent=4)
80
+ input_llm = "<|input|>\n### Template:\n" + schema + "\n"
81
+
82
+ input_llm += "### Text:\n"+text +"\n<|output|>\n"
83
+ input_ids = tokenizer(input_llm, return_tensors="pt", truncation=True, max_length=4000).to("cuda")
84
 
85
+ output = tokenizer.decode(model.generate(**input_ids)[0], skip_special_tokens=True)
86
+ return output.split("<|output|>")[1].split("<|end-output|>")[0]
87
 
 
88
 
89
+ model = AutoModelForCausalLM.from_pretrained("NebuIA/nebuia_extract_small", trust_remote_code=True, torch_dtype=torch.bfloat16)
90
+ tokenizer = AutoTokenizer.from_pretrained("NebuIA/nebuia_extract_small", trust_remote_code=True)
91
 
92
+ model.to("cuda")
93
 
94
+ model.eval()
95
 
96
+ text = """large legal text"""
97
 
98
+ schema = """{
99
+ "calusulas": [],
100
+ "notario": "",
101
+ "jurisdiccion": {
102
+ "clausula_jurisdiccion": "",
103
+ "lugar": ""
104
+ }
105
+ }"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
+ prediction = predict_extract(model, tokenizer, text, schema)
108
+ print(prediction)
109
 
110
+ ```
111