|
--- |
|
library_name: transformers |
|
widget: |
|
- text: > |
|
<|input|> |
|
|
|
|
|
|
|
{ |
|
"estaciones": [], |
|
"noches": [ |
|
{ |
|
"descripcion": "" |
|
} |
|
], |
|
"dias": [ |
|
{ |
|
"descripcion": "" |
|
} |
|
], |
|
"mejor_epoca": "", |
|
"frontera": "", |
|
"terreno": { |
|
"descripcion": "" |
|
} |
|
} |
|
|
|
|
|
|
|
El oeste de Texas divide la frontera entre Mexico y Nuevo México. Es muy |
|
bella pero aspera, llena de cactus, en esta region se encuentran las Davis |
|
Mountains. Todo el terreno esta lleno de piedra caliza, torcidos arboles de |
|
mezquite y espinosos nopales. Para admirar la verdadera belleza desertica, |
|
visite el Parque Nacional de Big Bend, cerca de Brownsville. Es el lugar |
|
favorito para los excurcionistas, acampadores y entusiastas de las rocas. |
|
Pequeños pueblos y ranchos se encuentran a lo largo de las planicies y |
|
cañones de esta region. El area solo tiene dos estaciones, tibia y realmente |
|
caliente. La mejor epoca para visitarla es de Diciembre a Marzo cuando los |
|
dias son tibios, las noches son frescas y florecen las plantas del desierto |
|
con la humedad en el aire. |
|
|
|
<|output|> |
|
pipeline_tag: text2text-generation |
|
inference: |
|
parameters: |
|
max_length: 512 |
|
license: apache-2.0 |
|
language: |
|
- es |
|
--- |
|
|
|
<p align="center"> |
|
<img src="Brain.png" width="600"> |
|
</p> |
|
|
|
# Structure Extraction Model |
|
|
|
nebuia_extract_small is an extraction model inspired by NuExtract. nebuia_extract_small 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. |
|
|
|
|
|
## Model Details |
|
|
|
### Model Description |
|
|
|
<!-- Provide a longer summary of what this model is. --> |
|
|
|
- **Developed by:** [NebuIA](https://nebuia.com) |
|
- **Language(s) (NLP):** es |
|
- **License:** mit |
|
- **Finetuned from model [optional]:** [Qween2 1.5b](https://huggingface.co/Qwen/Qwen2-1.5B-Instruct) |
|
|
|
## Uses |
|
|
|
Same template as NuExtract |
|
|
|
```python |
|
import json |
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
import torch |
|
|
|
|
|
def predict_extract(model, tokenizer, text, schema): |
|
schema = json.dumps(json.loads(schema), indent=4) |
|
input_llm = "<|input|>\n### Template:\n" + schema + "\n" |
|
|
|
input_llm += "### Text:\n"+text +"\n<|output|>\n" |
|
input_ids = tokenizer(input_llm, return_tensors="pt", truncation=True, max_length=4000).to("cuda") |
|
|
|
output = tokenizer.decode(model.generate(**input_ids)[0], skip_special_tokens=True) |
|
return output.split("<|output|>")[1].split("<|end-output|>")[0] |
|
|
|
|
|
model = AutoModelForCausalLM.from_pretrained("NebuIA/nebuia_extract_small", trust_remote_code=True, torch_dtype=torch.bfloat16) |
|
tokenizer = AutoTokenizer.from_pretrained("NebuIA/nebuia_extract_small", trust_remote_code=True) |
|
|
|
model.to("cuda") |
|
|
|
model.eval() |
|
|
|
text = """large legal text""" |
|
|
|
schema = """{ |
|
"calusulas": [], |
|
"notario": "", |
|
"jurisdiccion": { |
|
"clausula_jurisdiccion": "", |
|
"lugar": "" |
|
} |
|
}""" |
|
|
|
prediction = predict_extract(model, tokenizer, text, schema) |
|
print(prediction) |
|
|
|
``` |
|
|
|
|