himani commited on
Commit
dbfebbd
1 Parent(s): a60de7e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -11
README.md CHANGED
@@ -49,25 +49,27 @@ inp = tokenizer("I am a boy </s> <2en>", add_special_tokens=False, return_tensor
49
 
50
  # For generation. Pardon the messiness. Note the decoder_start_token_id.
51
  model.eval() # Set dropouts to zero
52
- model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=20, 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("<2en>"))
53
  # Decode to get output strings
54
  decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
55
  print(decoded_output) # I am a boy
56
  # Note that if your output language is not Hindi or Marathi, you should convert its script from Devanagari to the desired language using the Indic NLP Library.
57
  # What if we mask?
58
  inp = tokenizer("I am [MASK] </s> <2en>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
59
- model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=20, 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("<2en>"))
60
  decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
61
  print(decoded_output) # I am happy
62
  inp = tokenizer("मैं [MASK] हूँ </s> <2hi>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
63
- model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=20, 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("<2en>"))
64
  decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
65
  print(decoded_output) # मैं जानता हूँ
66
  inp = tokenizer("मला [MASK] पाहिजे </s> <2mr>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
67
- model_output=model.generate(inp, use_cache=True, num_beams=4, max_length=20, 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("<2en>"))
68
  decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
69
  print(decoded_output) # मला ओळखलं पाहिजे
70
  ```
 
 
71
 
72
  ## Benchmarks
73
 
@@ -76,13 +78,13 @@ Scores on the `IndicParaphrase` test sets are as follows:
76
  Language | BLEU / Self-BLEU / iBLEU
77
  ---------|----------------------------
78
  as | 1.66 / 2.06 / 0.54
79
- bn | 11.57 / 1.69 / 0.54
80
- gu | 22.10 / 2.76 / 7.59
81
- hi | 27.29 / 2.87 / 14.64
82
- kn | 15.40 / 2.98 / 18.24
83
- ml | 10.57 / 1.70 / 9.89
84
- mr | 20.38 / 2.20 / 6.89
85
- or | 19.26 / 2.10 / 13.61
86
  pa | 14.87 / 1.35 / 10.00
87
  ta | 18.52 / 2.88 / 12.10
88
  te | 16.70 / 3.34 / 10.69
 
49
 
50
  # For generation. Pardon the messiness. Note the decoder_start_token_id.
51
  model.eval() # Set dropouts to zero
52
+ model_output=model.generate(inp, use_cache=True,no_repeat_ngram_size=3,encoder_no_repeat_ngram_size=3, num_beams=4, max_length=20, 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("<2en>"))
53
  # Decode to get output strings
54
  decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
55
  print(decoded_output) # I am a boy
56
  # Note that if your output language is not Hindi or Marathi, you should convert its script from Devanagari to the desired language using the Indic NLP Library.
57
  # What if we mask?
58
  inp = tokenizer("I am [MASK] </s> <2en>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
59
+ model_output=model.generate(inp, use_cache=True,no_repeat_ngram_size=3,encoder_no_repeat_ngram_size=3, num_beams=4, max_length=20, 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("<2en>"))
60
  decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
61
  print(decoded_output) # I am happy
62
  inp = tokenizer("मैं [MASK] हूँ </s> <2hi>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
63
+ model_output=model.generate(inp, use_cache=True,no_repeat_ngram_size=3,encoder_no_repeat_ngram_size=3, num_beams=4, max_length=20, 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("<2en>"))
64
  decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
65
  print(decoded_output) # मैं जानता हूँ
66
  inp = tokenizer("मला [MASK] पाहिजे </s> <2mr>", add_special_tokens=False, return_tensors="pt", padding=True).input_ids
67
+ model_output=model.generate(inp, use_cache=True,no_repeat_ngram_size=3,encoder_no_repeat_ngram_size=3, num_beams=4, max_length=20, 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("<2en>"))
68
  decoded_output=tokenizer.decode(model_output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
69
  print(decoded_output) # मला ओळखलं पाहिजे
70
  ```
71
+ # Note:
72
+ If you wish to use any language written in a non-Devanagari script (except English), then you should first convert it to Devanagari using the <a href="https://github.com/anoopkunchukuttan/indic_nlp_library">Indic NLP Library</a>. After you get the output, you should convert it back into the original script.
73
 
74
  ## Benchmarks
75
 
 
78
  Language | BLEU / Self-BLEU / iBLEU
79
  ---------|----------------------------
80
  as | 1.66 / 2.06 / 0.54
81
+ bn | 11.57 / 1.69 / 7.59
82
+ gu | 22.10 / 2.76 / 14.64
83
+ hi | 27.29 / 2.87 / 18.24
84
+ kn | 15.40 / 2.98 / 9.89
85
+ ml | 10.57 / 1.70 / 6.89
86
+ mr | 20.38 / 2.20 / 13.61
87
+ or | 19.26 / 2.10 / 12.85
88
  pa | 14.87 / 1.35 / 10.00
89
  ta | 18.52 / 2.88 / 12.10
90
  te | 16.70 / 3.34 / 10.69