Commit
·
6e5665b
1
Parent(s):
fe673f4
Upload folder using huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- ctranslate2
|
| 7 |
+
- flan-t5-small
|
| 8 |
+
- quantization
|
| 9 |
+
- int8
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Model Card for FLAN T5 Small Q8
|
| 13 |
+
|
| 14 |
+
The model is quantized version of the [google/flan-t5-small](https://huggingface.co/google/flan-t5-small) with int8 quantization.
|
| 15 |
+
|
| 16 |
+
## Model Details
|
| 17 |
+
|
| 18 |
+
### Model Description
|
| 19 |
+
|
| 20 |
+
The model being quantized using [CTranslate2](https://opennmt.net/CTranslate2/) with the following command:
|
| 21 |
+
|
| 22 |
+
```
|
| 23 |
+
ct2-transformers-converter --model google/flan-t5-small --output_dir google/flan-t5-small-ct2 --quantization int8
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
If you want to perform the quantization yourself, you need to install the following dependencies:
|
| 27 |
+
|
| 28 |
+
```
|
| 29 |
+
pip install -qU ctranslate2 transformers[torch] sentencepiece
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
- **Shared by:** Lim Chee Kin
|
| 33 |
+
- **License:** Apache 2.0
|
| 34 |
+
|
| 35 |
+
## How to Get Started with the Model
|
| 36 |
+
|
| 37 |
+
Use the code below to get started with the model.
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
import ctranslate2
|
| 41 |
+
import transformers
|
| 42 |
+
|
| 43 |
+
translator = ctranslate2.Translator("google/flan-t5-small-ct2")
|
| 44 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained("google/flan-t5-small-ct2")
|
| 45 |
+
|
| 46 |
+
input_text = "translate English to German: The house is wonderful."
|
| 47 |
+
input_tokens = tokenizer.convert_ids_to_tokens(tokenizer.encode(input_text))
|
| 48 |
+
|
| 49 |
+
results = translator.translate_batch([input_tokens])
|
| 50 |
+
|
| 51 |
+
output_tokens = results[0].hypotheses[0]
|
| 52 |
+
output_text = tokenizer.decode(tokenizer.convert_tokens_to_ids(output_tokens))
|
| 53 |
+
|
| 54 |
+
print(output_text)
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
The code is taken from https://opennmt.net/CTranslate2/guides/transformers.html#t5.
|
| 58 |
+
|
| 59 |
+
The key method of the code above is `translate_batch`, you can find out [its supported parameters here](https://opennmt.net/CTranslate2/python/ctranslate2.Translator.html#ctranslate2.Translator.translate_batch).
|