Downloads · 30 days
12
2% of all-time downloads
somosnlp/bertin_base_climate_detection_spa
bertin_base_climate_detection_spa is a text classification model from somosnlp. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as cc-by-4.0.
Downloads · 30 days
12
2% of all-time downloads
All-time downloads
484
Public
Parameters
125M
500 MB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors499 MB · 99%
From the Hugging Face model README
README Spanish Version: README_ES
<p align="center"> <img src="https://huggingface.co/somosnlp/bertin_base_climate_detection_spa/resolve/main/model_image_repo_380.jpg" alt="Model Illustration" width="500"> </p>This model is a fine-tuning version of the model: bertin-project/bertin-roberta-base-spanish using the dataset somosnlp/spa_climate_detection. The model is focused on the identification of texts on topics related to climate change and sustainability. This project was based on the English version of climatebert/distilroberta-base-climate-detector.
The motivation of the project was to create a repository in Spanish on information or resources on topics such as: climate change, sustainability, global warming, energy, etc; the idea is to give visibility to solutions, examples of good environmental practices or news that help us to combat the effects of climate change; in a way similar to what the project Drawdown does but providing examples of solutions or new research on each topic. To achieve this In order to achieve this objective, we consider that the identification of texts that speak about these topics is the first step. Some of the direct applications are: classification of papers and scientific publications, news, opinions.
Future steps:
No specific studies on biases and limitations have been carried out at this point, however, we make the following points based on previous experience and model tests:
## Asumiendo tener instalados transformers, torch
from transformers import AutoModelForSequenceClassification
import torch
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("somosnlp/bertin_base_climate_detection_spa")
model = AutoModelForSequenceClassification.from_pretrained("somosnlp/bertin_base_climate_detection_spa")
# Traduccion del label
id2label = {0: "NEGATIVE", 1: "POSITIVE"}
label2id = {"NEGATIVE": 0, "POSITIVE": 1}
# Funcion de inferencia
def inference_fun(Texto):
inputs = tokenizer(Texto, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
predicted_class_id = logits.argmax().item()
output_tag = model.config.id2label[predicted_class_id]
return output_tag
input_text = "El uso excesivo de fertilizantes nitrogenados -un fenómeno frecuente en la agricultura- da lugar a la producción de óxido nitroso, un potente gas de efecto invernadero. Un uso más juicioso de los fertilizantes puede frenar estas emisiones y reducir la producción de fertilizantes, que consume mucha energía."
print(inference_fun(input_text))
The training data were obtained from the dataset somosnlp/spa_climate_detection. The training data represent about 79% of the total data in the dataset.
The labels are represented as follows:
Labels 1s
1000 - data on paragraphs extracted from company reports on the subject.
600 - data on various opinions, mostly short texts.
Labels 0s
300 - data on paragraphs extracted from business reports not related to the subject.
500 - data on news on various topics unrelated to the subject.
500 - data on opinions on various topics unrelated to the subject.
You can check our Google Colab to review the training procedure we take: Colab Entrenamiento The accelerate configuration is as follows: In which compute environment are you running?: 0 Which type of machine are you using?: No distributed training Do you want to run your training on CPU only (even if a GPU / Apple Silicon / Ascend NPU device is available)? [yes/NO]:NO Do you wish to optimize your script with torch dynamo?[yes/NO]:NO Do you want to use DeepSpeed? [yes/NO]: NO What GPU(s) (by id) should be used for training on this machine as a comma-seperated list? [all]:all Do you wish to use FP16 or BF16 (mixed precision)?: no
The following hyperparameters were used during training:
The model was trained in 2 epochs with a total training duration of 14.22 minutes, 'train_runtime': 853.6759. Additional information: No mixed precision (FP16 or BF16) was used.
| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|---|---|---|---|---|
| No log | 1.0 | 182 | 0.1964 | 0.9551 |
| No log | 2.0 | 364 | 0.1592 | 0.9705 |
The assessment data were obtained from the dataset somosnlp/spa_climate_detection. The assessment data represent about 21% of the total data in the dataset. The labels are represented as follows:
Labels 1s
320 - data on paragraphs extracted from company reports on the subject.
160 - data on various opinions, mostly short texts.
Labels 0s
80 - data on paragraphs extracted from business reports not related to the subject.
120 - data on news on various topics unrelated to the subject.
100 - data on opinions on various topics unrelated to the subject.
Model reached the following results on evaluation dataset:
The metric was precision.
Look at the Inference section of Colab: entrenamiento_del_modelo
Accuracy 0.95 Precision 0.916 Recall 0.99 F1 score 0.951
Using the tool ML CO2 IMPACT we estimate the following environmental impact due to training:
cc-by-nc-sa-4.0 Due to inheritance of the data used in the dataset.
BibTeX:
@software{BERTIN-ClimID,
author = {Gerardo Huerta, Gabriela Zuñiga},
title = {BERTIN-ClimID: BERTIN-Base Climate-related text Identification},
month = Abril,
year = 2024,
url = {https://huggingface.co/somosnlp/bertin_base_climate_detection_spa}
}
This project was developed during the Hackathon #Somos600M organized by SomosNLP. We thank all event organizers and sponsors for their support during the event.
Team: