Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
| 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-7b-mt-bt](https://huggingface.co/google/madlad400-7b-mt-bt) 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-7b-mt-bt-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)
|
| 32 |
+
|
| 33 |
+
```
|