Instructions to use WilliamSotoM/PTHQL_language_French with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use WilliamSotoM/PTHQL_language_French with PEFT:
from peft import PeftModel from transformers import AutoModelForSeq2SeqLM base_model = AutoModelForSeq2SeqLM.from_pretrained("google/mt5-large") model = PeftModel.from_pretrained(base_model, "WilliamSotoM/PTHQL_language_French") - Notebooks
- Google Colab
- Kaggle
| language: | |
| - fr | |
| license: mit | |
| library_name: peft | |
| tags: | |
| - peft | |
| - text2text-generation | |
| - text-generation | |
| base_model: google/mt5-large | |
| # PTHQL_language_French | |
| This is the French (fra_Latn) Phylogenetic Tree Hierarquical QLoRAs (PTHQL) adapter from [Generating from AMRs into High and Low-Resource Languages using Phylogenetic Knowledge and Hierarchical QLoRA Training (HQL)](https://aclanthology.org/2024.inlg-main.7/) used for AMR-to-Text generation. | |
| # Use | |
| This model is the last of 4 hierarquical LoRAs. It is strongly adviseable to load all 4 LoRAs in order. | |
| The following is minimal code to generate French text from an AMR graph: | |
| ``` | |
| from transformers import MT5ForConditionalGeneration, AutoTokenizer | |
| from peft import PeftModel | |
| model = MT5ForConditionalGeneration.from_pretrained('google/mt5-large') | |
| tokennizer = AutoTokenizer.from_pretrained('google/mt5-large') | |
| model = PeftModel.from_pretrained(model, 'WilliamSotoM/PTHQL_level0_Indo_European') | |
| model = model.merge_and_unload() | |
| model = PeftModel.from_pretrained(model, 'WilliamSotoM/PTHQL_level1_Romance') | |
| model = model.merge_and_unload() | |
| model = PeftModel.from_pretrained(model, 'WilliamSotoM/PTHQL_level2_Gallo_Romance') | |
| model = model.merge_and_unload() | |
| model = PeftModel.from_pretrained(model, 'WilliamSotoM/PTHQL_language_French') | |
| model = model.merge_and_unload() | |
| graph = ''' | |
| (w / want-01 | |
| :ARG0 (b / boy) | |
| :ARG1 (b2 / believe-01 | |
| :ARG0 (g / girl) | |
| :ARG1 b)) | |
| ''' | |
| tokenized_input = tokenizer(graph, return_tensors='pt') | |
| with torch.inference_mode(): | |
| prediction = model.generate(**tokenized_input) | |
| generated_text = tokenizer.batch_decode(prediction, skip_special_tokens=True)[0] | |
| print(f'Generated text:', generated_text) | |
| ``` | |
| Expected outpu: | |
| ``` | |
| Le garçon veut que la fille le croit. | |
| ``` | |