MattBoraske commited on
Commit
0631861
·
1 Parent(s): 10daf54

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -1
README.md CHANGED
@@ -3,4 +3,24 @@ license: apache-2.0
3
  pipeline_tag: translation
4
  ---
5
 
6
- This is a base BART model fine-tuned for English to German translation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  pipeline_tag: translation
4
  ---
5
 
6
+ This is a base BART model fine-tuned for English to German translation.
7
+
8
+ ## Usage
9
+
10
+ ```python
11
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
12
+
13
+ # Load model and tokenizer
14
+ tokenizer = AutoTokenizer.from_pretrained("MattBoraske/BART_De-En_Translation")
15
+ model = AutoModelForSeq2SeqLM.from_pretrained("MattBoraske/BART_De-En_Translation")
16
+
17
+ # Sample English sentence
18
+ sentence = "Good morning! How are you?"
19
+
20
+ # Translate English to Deutsch (German)
21
+ inputs = tokenizer.encode(sentence, return_tensors="pt")
22
+ outputs = model.generate(inputs, max_length=40, num_beams=4, early_stopping=True)
23
+ translated_sentence = tokenizer.decode(outputs[0], skip_special_tokens=True)
24
+
25
+ print(translated_sentence)
26
+ ```