sasha-smirnov commited on
Commit
eb55ec9
·
verified ·
1 Parent(s): e6c8f61

Initial publish via teradata-opus-translate

Browse files
Files changed (2) hide show
  1. README.md +12 -9
  2. 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-int8.onnx", local_dir="./")
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-int8.onnx",
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 = '{{model_id}}') AS ModelTable DIMENSION
102
  ON (SELECT model AS tokenizer FROM translation_tokenizers
103
- WHERE model_id = '{{model_id}}') AS TokenizerTable DIMENSION
104
  USING
105
  Accumulate('id')
106
  ModelOutputTensor('sequences')
107
  SkipSpecialTokens('true')
108
  OutputLength(512)
109
- OverwriteCachedModel('{{model_id}}')
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
- Use `model-int8.onnx` unless you have a measured accuracy reason to ship `fp32`.
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-int8.onnx",
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-int8.onnx` and `tokenizer.json` are ready to deploy
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:82246af52158c0692c87263c545f491747f60517fd4e9199f732b3ce5a776fe2
3
- size 94483810
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0edaff9b6d878d8fb3c2226135185419603bc2ee78ef92f192a3e52b77bafe45
3
+ size 94960801