Translation
Transformers
ONNX
Safetensors
English
German
marian
text2text-generation
LiteRT
Helsinki-NLP/tatoeba
openlanguagedata/flores_plus
teradata
Instructions to use Teradata/opus-mt_tiny_eng-deu with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Teradata/opus-mt_tiny_eng-deu with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="Teradata/opus-mt_tiny_eng-deu")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Teradata/opus-mt_tiny_eng-deu") model = AutoModelForSeq2SeqLM.from_pretrained("Teradata/opus-mt_tiny_eng-deu") - Notebooks
- Google Colab
- Kaggle
Initial publish via teradata-opus-translate
Browse files- README.md +12 -9
- onnx/model-int8.onnx +2 -2
README.md
CHANGED
|
@@ -67,6 +67,10 @@ Generation parameters are configurable at SQL time via the
|
|
| 67 |
Requires Teradata 17.20+ with **BYOM 7.0.0.4** or newer (the conversion
|
| 68 |
targets ONNX IR version 8, which BYOM 7.0.x requires).
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
```python
|
| 71 |
import getpass
|
| 72 |
import teradataml as tdml
|
|
@@ -76,7 +80,7 @@ repo_id = "Teradata/opus-mt_tiny_eng-deu"
|
|
| 76 |
model_id = "opus-mt_tiny_eng-deu" # used as BYOM model_id
|
| 77 |
|
| 78 |
# 1. Download artifacts from this repo
|
| 79 |
-
hf_hub_download(repo_id=repo_id, filename="onnx/model-
|
| 80 |
hf_hub_download(repo_id=repo_id, filename="tokenizer.json", local_dir="./")
|
| 81 |
|
| 82 |
# 2. Connect to Teradata
|
|
@@ -87,7 +91,7 @@ tdml.create_context(
|
|
| 87 |
)
|
| 88 |
|
| 89 |
# 3. Load model + tokenizer into BYOM tables
|
| 90 |
-
tdml.save_byom(model_id=model_id, model_file="onnx/model-
|
| 91 |
table_name="translation_models")
|
| 92 |
tdml.save_byom(model_id=model_id, model_file="tokenizer.json",
|
| 93 |
table_name="translation_tokenizers")
|
|
@@ -98,15 +102,15 @@ SELECT id, sequences
|
|
| 98 |
FROM mldb.ONNXSeq2Seq(
|
| 99 |
ON (SELECT id, txt FROM your_input_table) AS InputTable
|
| 100 |
ON (SELECT model_id, model FROM translation_models
|
| 101 |
-
WHERE model_id = '{
|
| 102 |
ON (SELECT model AS tokenizer FROM translation_tokenizers
|
| 103 |
-
WHERE model_id = '{
|
| 104 |
USING
|
| 105 |
Accumulate('id')
|
| 106 |
ModelOutputTensor('sequences')
|
| 107 |
SkipSpecialTokens('true')
|
| 108 |
OutputLength(512)
|
| 109 |
-
OverwriteCachedModel('
|
| 110 |
Const_min_length(1)
|
| 111 |
Const_max_length(64)
|
| 112 |
Const_num_beams(4)
|
|
@@ -117,7 +121,7 @@ FROM mldb.ONNXSeq2Seq(
|
|
| 117 |
print(tdml.DataFrame.from_query(query))
|
| 118 |
```
|
| 119 |
|
| 120 |
-
|
| 121 |
|
| 122 |
## How this model was converted
|
| 123 |
|
|
@@ -137,8 +141,7 @@ small sample set.
|
|
| 137 |
>
|
| 138 |
> convert_model(
|
| 139 |
> "Helsinki-NLP/<your-model>",
|
| 140 |
-
> output_path="model-
|
| 141 |
-
> precision="int8",
|
| 142 |
> )
|
| 143 |
> convert_tokenizer(
|
| 144 |
> "Helsinki-NLP/<your-model>",
|
|
@@ -146,7 +149,7 @@ small sample set.
|
|
| 146 |
> )
|
| 147 |
> ```
|
| 148 |
>
|
| 149 |
-
> The resulting `model-
|
| 150 |
> with the Quickstart flow above.
|
| 151 |
|
| 152 |
## Disclaimer
|
|
|
|
| 67 |
Requires Teradata 17.20+ with **BYOM 7.0.0.4** or newer (the conversion
|
| 68 |
targets ONNX IR version 8, which BYOM 7.0.x requires).
|
| 69 |
|
| 70 |
+
> **Note on schema name:** the SQL example below uses `mldb.ONNXSeq2Seq`.
|
| 71 |
+
> On modern Teradata deployments BYOM is installed in the `td_mldb` database —
|
| 72 |
+
> adjust the schema prefix in the SQL accordingly.
|
| 73 |
+
|
| 74 |
```python
|
| 75 |
import getpass
|
| 76 |
import teradataml as tdml
|
|
|
|
| 80 |
model_id = "opus-mt_tiny_eng-deu" # used as BYOM model_id
|
| 81 |
|
| 82 |
# 1. Download artifacts from this repo
|
| 83 |
+
hf_hub_download(repo_id=repo_id, filename="onnx/model-fp32.onnx", local_dir="./")
|
| 84 |
hf_hub_download(repo_id=repo_id, filename="tokenizer.json", local_dir="./")
|
| 85 |
|
| 86 |
# 2. Connect to Teradata
|
|
|
|
| 91 |
)
|
| 92 |
|
| 93 |
# 3. Load model + tokenizer into BYOM tables
|
| 94 |
+
tdml.save_byom(model_id=model_id, model_file="onnx/model-fp32.onnx",
|
| 95 |
table_name="translation_models")
|
| 96 |
tdml.save_byom(model_id=model_id, model_file="tokenizer.json",
|
| 97 |
table_name="translation_tokenizers")
|
|
|
|
| 102 |
FROM mldb.ONNXSeq2Seq(
|
| 103 |
ON (SELECT id, txt FROM your_input_table) AS InputTable
|
| 104 |
ON (SELECT model_id, model FROM translation_models
|
| 105 |
+
WHERE model_id = '{model_id}') AS ModelTable DIMENSION
|
| 106 |
ON (SELECT model AS tokenizer FROM translation_tokenizers
|
| 107 |
+
WHERE model_id = '{model_id}') AS TokenizerTable DIMENSION
|
| 108 |
USING
|
| 109 |
Accumulate('id')
|
| 110 |
ModelOutputTensor('sequences')
|
| 111 |
SkipSpecialTokens('true')
|
| 112 |
OutputLength(512)
|
| 113 |
+
OverwriteCachedModel('true')
|
| 114 |
Const_min_length(1)
|
| 115 |
Const_max_length(64)
|
| 116 |
Const_num_beams(4)
|
|
|
|
| 121 |
print(tdml.DataFrame.from_query(query))
|
| 122 |
```
|
| 123 |
|
| 124 |
+
An int8-quantized variant is also published as `onnx/model-int8.onnx`. The int8 variant does not accept `num_beams` (configured internally).
|
| 125 |
|
| 126 |
## How this model was converted
|
| 127 |
|
|
|
|
| 141 |
>
|
| 142 |
> convert_model(
|
| 143 |
> "Helsinki-NLP/<your-model>",
|
| 144 |
+
> output_path="model-fp32.onnx",
|
|
|
|
| 145 |
> )
|
| 146 |
> convert_tokenizer(
|
| 147 |
> "Helsinki-NLP/<your-model>",
|
|
|
|
| 149 |
> )
|
| 150 |
> ```
|
| 151 |
>
|
| 152 |
+
> The resulting `model-fp32.onnx` and `tokenizer.json` are ready to deploy
|
| 153 |
> with the Quickstart flow above.
|
| 154 |
|
| 155 |
## Disclaimer
|
onnx/model-int8.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0edaff9b6d878d8fb3c2226135185419603bc2ee78ef92f192a3e52b77bafe45
|
| 3 |
+
size 94960801
|