zenoverflow
commited on
Commit
•
4456358
1
Parent(s):
a0da67a
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
pipeline_tag: translation
|
4 |
+
inference: false
|
5 |
---
|
6 |
+
|
7 |
+
Quantization of [madlad400-10b-mt](https://huggingface.co/google/madlad400-10b-mt) using [Ctranslate2](https://github.com/OpenNMT/CTranslate2) for running on CPU or Nvidia GPU.
|
8 |
+
|
9 |
+
Example usage:
|
10 |
+
|
11 |
+
```python
|
12 |
+
import ctranslate2, transformers
|
13 |
+
from huggingface_hub import snapshot_download
|
14 |
+
|
15 |
+
model_path = snapshot_download("zenoverflow/madlad400-10b-mt-ct2-int8-float16")
|
16 |
+
print("\n", end="")
|
17 |
+
|
18 |
+
translator = ctranslate2.Translator(model_path, device="auto")
|
19 |
+
tokenizer = transformers.T5Tokenizer.from_pretrained(model_path)
|
20 |
+
|
21 |
+
target_lang_code = "ja"
|
22 |
+
|
23 |
+
source_text = "This sentence has no meaning."
|
24 |
+
|
25 |
+
input_text = f"<2{target_lang_code}> {source_text}"
|
26 |
+
input_tokens = tokenizer.convert_ids_to_tokens(tokenizer.encode(input_text))
|
27 |
+
results = translator.translate_batch([input_tokens])
|
28 |
+
output_tokens = results[0].hypotheses[0]
|
29 |
+
output_text = tokenizer.decode(tokenizer.convert_tokens_to_ids(output_tokens))
|
30 |
+
|
31 |
+
print(output_text)
|