Edit model card
YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/model-cards#model-card-metadata)

This is the CreoleM2M model. If you know, you know!

Usage:

from transformers import MBartForConditionalGeneration, AutoModelForSeq2SeqLM
from transformers import AlbertTokenizer, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("prajdabre/CreoleM2M", do_lower_case=False, use_fast=False, keep_accents=True)

# Or use tokenizer = AlbertTokenizer.from_pretrained("prajdabre/CreoleM2M", do_lower_case=False, use_fast=False, keep_accents=True)

model = AutoModelForSeq2SeqLM.from_pretrained("prajdabre/CreoleM2M")

# Or use model = MBartForConditionalGeneration.from_pretrained("prajdabre/CreoleM2M")

# Some initial mapping
bos_id = tokenizer._convert_token_to_id_with_added_voc("<s>")
eos_id = tokenizer._convert_token_to_id_with_added_voc("</s>")
pad_id = tokenizer._convert_token_to_id_with_added_voc("<pad>")
# To get lang_id use any of ["<s>", "</s>", "<2acf>", "<2eng>", "<2bis>", "<2bzj>", "<2cbk>", "<2crs>", "<2djk>", "<2gul>", "<2hat>", "<2hwc>", "<2icr>", "<2jam>", "<2kri>", "<2ktu>", "<2mbf>", "<2mfe>", "<2mkn>", "<2pap>", "<2pcm>", "<2pis>", "<2rop>", "<2sag>", "<2srm>", "<2srn>", "<2tcs>", "<2tdt>", "<2tpi>"]

# First tokenize the input and outputs. The format below is how CreoleM2M was trained so the input should be "Sentence </s> <2xxx>" where xxx is the language code. Similarly, the output should be "<2yyy> Sentence </s>". 
inp = tokenizer('Wen dey wen stretch him out fo whip him real hard , Paul wen tell da captain dat stay dea , "Dis okay in da rules fo da Rome peopo ? fo you fo whip one guy dat get da same rights jalike da Rome peopo ? even one guy dat neva do notting wrong ?" </s> <2hwc>', add_special_tokens=False, return_tensors="pt", padding=True).input_ids

model.eval() # Set dropouts to zero

model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=60, min_length=1, early_stopping=True, pad_token_id=pad_id, bos_token_id=bos_id, eos_token_id=eos_id, decoder_start_token_id=tokenizer._convert_token_to_id_with_added_voc("<2eng>"))


# Decode to get output strings

decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)

print(decoded_output)

Notes:

  1. This is compatible with the latest version of transformers but was developed with version 4.3.2 so consider using 4.3.2 if possible.
  2. While I have only shown how to let logits and loss and how to generate outputs, you can do pretty much everything the MBartForConditionalGeneration class can do as in https://huggingface.co/docs/transformers/model_doc/mbart#transformers.MBartForConditionalGeneration
  3. Note that the tokenizer I have used is based on sentencepiece and not BPE. Therefore I use the AlbertTokenizer class and not the MBartTokenizer class.
Downloads last month
2
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Space using prajdabre/CreoleM2M 1