readme: ---
  language: "ca"
  license: mit
  tags:
  - text classification
  task_categories:
  - text-scoring
  task_ids:
  - semantic-similarity-scoring
  datasets:
  - projecte-aina/gencata
  ---
  
  ## mBERT fine-tuned on the GEnCaTa dataset for Parallel Corpus Filtering
  
  ## Table of Contents
  <details>
  <summary>Click to expand</summary>
  
  - [Model description](#model-description)
  - [Intended uses and limitations](#intended-use)
  - [How to use](#how-to-use)
  - [Limitations and bias](#limitations-and-bias)
  - [Training](#training)
    - [Training data](#training-data)
    - [Training procedure](#training-procedure)
      - [Tokenization](#tokenization)
      - [Hyperparameters](#hyperparameters)
  - [Evaluation](#evaluation)
     - [Variable and metrics](#variable-and-metrics)
     - [Evaluation results](#evaluation-results)
  - [Additional information](#additional-information)
    - [Author](#author)
    - [Contact information](#contact-information)
    - [Copyright](#copyright)
    - [Licensing information](#licensing-information)
    - [Funding](#funding)
    - [Citing information](#citing-information)
    - [Disclaimer](#disclaimer)
  </details>
  
  ## Model description
  
  We fine-tuned [mBERT](https://huggingface.co/bert-base-multilingual-cased) for the task of Catalan-English Parallel Corpus Filtering with the [GEnCaTa](https://huggingface.co/datasets/projecte-aina/gencata) dataset.
  
  The model has been fine-tuned on general domain data and is expected to work best with that type of text.
  
  ## Intended uses and limitations
  
  You can use this model for parallel corpus fitering, also known as, sentence alignment filtering. 
  
  ## How to use
  
  Here is how to use this model with the [pipeline API](https://huggingface.co/transformers/main_classes/pipelines.html):
  
  ```python
  from transformers import AutoModelForSequenceClassification, pipeline,AutoTokenizer
  
  filterer = pipeline("text-classification", model="projecte-aina/mbert-base-gencata")
  
  tokenizer = AutoTokenizer.from_pretrained("projecte-aina/mbert-base-gencata")
  
  def prepare(sentence_pairs):
      sentence_pairs_prep = []
      for s1, s2 in sentence_pairs:
          sentence_pairs_prep.append(f"{tokenizer.cls_token} {s1}{tokenizer.sep_token}{tokenizer.sep_token} {s2}{tokenizer.sep_token}")
      return sentence_pairs_prep
  
  sentence_pairs = [("La depressió pot afectar a persones de qualsevol edat.", "Depression can affect people at any age."),
                    ("Publicació de la llista dels resultats de la 5a prova: entrevista personal (Annex 1), i de la llista de les persones convocades a la realització del curs de formació selectiu (Annex 2)", "It also receives accident reports from 112 calls made by the public, or from businesses, the police, etc. When an incident alert is received, CECAT carries out a real-time analysis of the consequences and any significant risk associated with it, to determine if an emergency plan and its relevant procedures should be activated.")]
  
  print(filterer(prepare(sentence_pairs), max_length=512, truncation=True,padding=True))
  ```
  
  Expected output:
  ```
  [{'label': 'aligned', 'score': 0.9081919193267822},
  {'label': 'not_aligned', 'score': 0.5506048798561096}]
  ```
  
  ## Limitations and bias
  At the time of submission, no measures have been taken to estimate the bias embedded in the model. However, we are well aware that our models may be biased since the corpora have been collected using crawling techniques on multiple web sources. We intend to conduct research in these areas in the future, and if completed, this model card will be updated.
  
  ## Training
  
  ### Training data
  
  As training data, we used the [GEnCaTa](https://huggingface.co/datasets/projecte-aina/gencata) dataset, a Catalan-English dataset annotated for Parallel Corpus Filtering for MT. It is extracted from a general domain corpus crawled from the Catalan Government domains and subdomains.
  
  ### Training procedure
  
  #### Tokenization
  
  The training corpus has been tokenized using a byte version of [Byte-Pair Encoding (BPE)](https://github.com/openai/gpt-2) with a vocabulary size of 51,200 tokens. 
  
  #### Hyperparameters
  
  | Hyper-parameter                    | Value  |
  |------------------------------------|--------|
  | Learning Rate                      | 0.8e-5 |
  | Learning Rate Decay                | Linear |
  | Warmup                             | 0.06   |
  | Batch Size                         | 64     |
  | Weight Decay                       | 0.01   |
  | Max. Training Epochs               | 10     |
  
  ## Variable and metrics
  
  Although we can report accuracy scores, the best way to evaluate this model is to filter a parallel corpus and train a Machine Translation system with the filtered data. For that, we train two different MT models and evaluate them on [Flores-101](https://huggingface.co/datasets/gsarti/flores_101) with BLEU scores.
  
  ## Evaluation results
  
  Below the evaluation results on [Flores-101](https://huggingface.co/datasets/gsarti/flores_101) from two MT systems: RAW and FIL (filtered corpus with our model).
  
  |Direction  | RAW  | FIL  |
  | ---