doinv commited on
Commit
28659cc
·
verified ·
1 Parent(s): c1455c6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +17 -0
README.md CHANGED
@@ -41,7 +41,23 @@ This modelcard aims to be a base template for new models. It has been generated
41
  ## Uses
42
 
43
  <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
 
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  ### Direct Use
46
 
47
  <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
@@ -155,6 +171,7 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
155
  - **Compute Region:** [More Information Needed]
156
  - **Carbon Emitted:** [More Information Needed]
157
 
 
158
  ## Technical Specifications [optional]
159
 
160
  ### Model Architecture and Objective
 
41
  ## Uses
42
 
43
  <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
44
+ import ctranslate2
45
+ import transformers
46
 
47
+ translator = ctranslate2.Translator("t5_ct2")
48
+ tokenizer = transformers.AutoTokenizer.from_pretrained("t5_ct2")
49
+
50
+ input_text = " translate German to English: Ich erkläre die am Freitag, dem 17. Dezember 1999 unterbrochene Sitzungsperiode des Europäischen Parlaments für wieder aufgenommen, und wünsche Ihnen nochmals ein glückliches neues Jahr in der Hoffnung, daß Sie eine angenehme Festzeit genossen haben. Obwohl der gefürchtete 'Jahrtausendfehler' nicht zustande gekommen ist, erlitten die Menschen in einigen Ländern noch immer eine Reihe von Naturkatastrophen, die wirklich furchtbar waren."
51
+ input_tokens = tokenizer.convert_ids_to_tokens(tokenizer.encode(input_text))
52
+
53
+ results = translator.translate_batch([input_tokens])
54
+
55
+ output_tokens = results[0].hypotheses[0]
56
+ output_text = tokenizer.decode(tokenizer.convert_tokens_to_ids(output_tokens))
57
+
58
+ print(output_text)
59
+
60
+ If u want to translate en to de , you can change the prefix " translate English to German" is ok.
61
  ### Direct Use
62
 
63
  <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
171
  - **Compute Region:** [More Information Needed]
172
  - **Carbon Emitted:** [More Information Needed]
173
 
174
+
175
  ## Technical Specifications [optional]
176
 
177
  ### Model Architecture and Objective