Views
No views yet
| Corpus | train | valid | test |
|---|---|---|---|
| Propicto-commonvoice | 527,390 | 16,124 | 16,120 |
| Propicto-orfeo | 231,374 | 28,796 | 29,009 |
| Propicto-tedx | 85,106 | 749 | 804 |
| Propicto-polylexical | 1,462 | - | - |
| TOTAL | 845,332 | 45,669 | 45,933 |
1training_args = Seq2SeqTrainingArguments(
2 output_dir="checkpoints_corpus_v2/",
3 evaluation_strategy="epoch",
4 save_strategy="epoch",
5 learning_rate=2e-5,
6 per_device_train_batch_size=32,
7 per_device_eval_batch_size=32,
8 weight_decay=0.01,
9 save_total_limit=3,
10 num_train_epochs=40,
11 predict_with_generate=True,
12 fp16=True,
13 load_best_model_at_end=True
14)| Model | validation | test |
|---|---|---|
| t2p-nllb-200-distilled-600M-all | 92.4 | - |
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3source_lang = "fr"
4target_lang = "frp"
5max_input_length = 128
6max_target_length = 128
7
8tokenizer = AutoTokenizer.from_pretrained("Propicto/t2p-nllb-200-distilled-600M-all")
9model = AutoModelForSeq2SeqLM.from_pretrained("Propicto/t2p-nllb-200-distilled-600M-all")
10
11inputs = tokenizer("Je mange une pomme", return_tensors="pt").input_ids
12outputs = model.generate(inputs.to("cuda:0"), max_new_tokens=40, do_sample=True, top_k=30, top_p=0.95)
13pred = tokenizer.decode(outputs[0], skip_special_tokens=True)1import pandas as pd
2
3def process_output_trad(pred):
4 return pred.split()
5
6def read_lexicon(lexicon):
7 df = pd.read_csv(lexicon, sep='\t')
8 df['keyword_no_cat'] = df['lemma'].str.split(' #').str[0].str.strip().str.replace(' ', '_')
9 return df
10
11def get_id_picto_from_predicted_lemma(df_lexicon, lemma):
12 id_picto = df_lexicon.loc[df_lexicon['keyword_no_cat'] == lemma, 'id_picto'].tolist()
13 return (id_picto[0], lemma) if id_picto else (0, lemma)
14
15lexicon = read_lexicon("lexicon.csv")
16sentence_to_map = process_output_trad(pred)
17pictogram_ids = [get_id_picto_from_predicted_lemma(lexicon, lemma) for lemma in sentence_to_map]1def generate_html(ids):
2 html_content = '<html><body>'
3 for picto_id, lemma in ids:
4 if picto_id != 0: # ignore invalid IDs
5 img_url = f"https://static.arasaac.org/pictograms/{picto_id}/{picto_id}_500.png"
6 html_content += f'''
7 <figure style="display:inline-block; margin:1px;">
8 <img src="{img_url}" alt="{lemma}" width="200" height="200" />
9 <figcaption>{lemma}</figcaption>
10 </figure>
11 '''
12 html_content += '</body></html>'
13 return html_content
14
15html = generate_html(pictogram_ids)
16with open("pictograms.html", "w") as file:
17 file.write(html)