Update README.md
Browse files
README.md
CHANGED
@@ -40,13 +40,11 @@ tobe_translated = ['講筵官','判司簿尉','散騎常侍','殿中省尚輦奉
|
|
40 |
|
41 |
<font color="cornflowerblue"> 3. Make a prediction </font>
|
42 |
```python
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
print(f'{chinese_sentence}: {tran}')
|
49 |
-
trans_list.append(tran[0])
|
50 |
```
|
51 |
講筵官: Lecturer<br>
|
52 |
判司簿尉: Supervisor of the Commandant of Records<br>
|
|
|
40 |
|
41 |
<font color="cornflowerblue"> 3. Make a prediction </font>
|
42 |
```python
|
43 |
+
inputs = tokenizer(tobe_translated, return_tensors="pt", padding=True).to(device)
|
44 |
+
translated = model.generate(**inputs, max_length=128)
|
45 |
+
tran = [tokenizer.decode(t, skip_special_tokens=True) for t in translated]
|
46 |
+
for c, t in zip(tobe_translated, tran):
|
47 |
+
print(f'{c}: {t}')
|
|
|
|
|
48 |
```
|
49 |
講筵官: Lecturer<br>
|
50 |
判司簿尉: Supervisor of the Commandant of Records<br>
|