Read the disclaimer below before using this model.
codesage-small -- ONNX for Teradata BYOM
This repository hosts an
ONNX-converted version of the upstream
model
codesage/codesage-small,
packaged for the Teradata Vantage
mldb.ONNXEmbeddings BYOM
function. It is
not the original PyTorch model -- only the
inference graph and tokenizer needed for in-database embedding
generation.
What's different from upstream:
- Format: ONNX (opset 14, IR version 8 -- BYOM 6+ compatible),
produced from the upstream weights with architecture-aware
post-processing baked in.
- Precision: dynamic int8 quantization. See the variants table
below for what is shipped for this model.
- Pooling and post-processing: this graph emits the raw
sentence_embedding tensor. Pooling rule is
mean.
- Verification: every variant's cosine fidelity vs. the
upstream PyTorch reference is recorded on a fixed
CodeSearchNet sample. Numbers may not generalize
to your data.
Model details
| |
|---|
| Upstream repo | codesage/codesage-small |
| Architecture | CodeSage (encoder) |
| Parameters | 128,010,240 |
| Output dimensions | 1024 |
| Pooling | mean |
| Instruction prefix | no |
| Max input tokens (advertised) | 2048 |
| Languages | 9 |
| License | apache-2.0 |
| ONNX opset | 14 |
| ONNX IR version | 8 (BYOM 6+ compatible) |
Full language list (9)
c
c-sharp
go
java
javascript
typescript
php
python
ruby
Quantization variants
This repository ships the following variants. Quality numbers are
measured against the upstream PyTorch reference on a fixed
CodeSearchNet sample. The Size column is the
on-disk size of the ONNX weight file in megabytes (MB, 10^6 bytes).
| Variant | Size (MB) | p50 cosine | R@1 |
|---|
fp32 | 512.2 | 1.000000 | — |
How to read the quality columns:
- p50 cosine is the median cosine similarity between this
variant's embeddings and the fp32 ONNX reference, computed over
a fixed evaluation set. Higher means closer to the unquantized
model; 1.0 is identical.
- R@1 is top-1 retrieval consistency: if you use this variant
as a search index, R@1 is the fraction of queries that get the
same nearest neighbor as the fp32 reference would. Higher is
better.
Notes:
- fp32: full-precision reference. Useful for an accuracy ceiling,
but BYOM users almost always want one of the int8 variants for
in-database scoring -- they are 3-4x smaller and load much faster.
Quickstart: using this model with Teradata BYOM
Requires Teradata Vantage with BYOM 6+ (mldb.ONNXEmbeddings).
1import getpass
2import teradataml as tdml
3from huggingface_hub import hf_hub_download
4
5repo_id = "Teradata/codesage-small"
6model_id = "codesage-small" # arbitrary, used as the BYOM model_id
7onnx_file = "onnx/model-fp32.onnx"
8
9# 1. Download the ONNX + tokenizer for the chosen variant.
10hf_hub_download(repo_id=repo_id, filename=onnx_file, local_dir="./")
11hf_hub_download(repo_id=repo_id, filename="tokenizer.json", local_dir="./")
12
13# 2. Connect to Vantage.
14tdml.create_context(
15 host=input("host: "),
16 username=input("user: "),
17 password=getpass.getpass("password: "),
18)
19
20# 3. Load model + tokenizer into BYOM tables (one-time per model_id).
21tdml.save_byom(model_id=model_id, model_file=onnx_file,
22 table_name="embeddings_models")
23tdml.save_byom(model_id=model_id, model_file="tokenizer.json",
24 table_name="embeddings_tokenizers")
Then call mldb.ONNXEmbeddings against an input table whose
txt column carries the strings to embed:
1SELECT *
2FROM mldb.ONNXEmbeddings(
3 ON (SELECT id, txt FROM your_input_table) AS InputTable
4 ON (SELECT model_id, model FROM embeddings_models
5 WHERE model_id = 'codesage-small') AS ModelTable DIMENSION
6 ON (SELECT model_id, tokenizer FROM embeddings_tokenizers
7 WHERE model_id = 'codesage-small') AS TokenizerTable DIMENSION
8 USING
9 Accumulate('id')
10 ModelOutputTensor('sentence_embedding')
11 OutputFormat('FLOAT32(1024)')
12 OverwriteCachedModel('*')
13) AS t
14ORDER BY id;
Pooling rule mean is applied inside the converted
ONNX graph -- the output tensor named above already contains the
pooled, post-processed embedding vector.
Original model attribution
The original weights and training methodology belong to
the CodeSage authors. Please cite their work, not this
repository, in academic contexts. The canonical upstream model card
is at
codesage/codesage-small;
refer to it for benchmarks, training details, intended use, and
citation information.
Reporting issues
For ONNX-conversion or BYOM-compatibility issues specific to this
Teradata-converted artifact, please open a Discussion on this
model's Hugging Face page. Questions about the underlying model
quality, training, or intended use should go to the upstream
maintainer's model card.
DISCLAIMER: The content herein ("Content") is provided "AS IS" and is not covered by any Teradata Operations, Inc. and its affiliates ("Teradata") agreements. Its listing here does not constitute certification or endorsement by Teradata.
To the extent any of the Content contains or is related to any artificial intelligence ("AI") or other language learning models ("Models") that interoperate with the products and services of Teradata, by accessing, bringing, deploying or using such Models, you acknowledge and agree that you are solely responsible for ensuring compliance with all applicable laws, regulations, and restrictions governing the use, deployment, and distribution of AI technologies. This includes, but is not limited to, AI Diffusion Rules, European Union AI Act, AI-related laws and regulations, privacy laws, export controls, and financial or sector-specific regulations.
While Teradata may provide support, guidance, or assistance in the deployment or implementation of Models to interoperate with Teradata's products and/or services, you remain fully responsible for ensuring that your Models, data, and applications comply with all relevant legal and regulatory obligations. Our assistance does not constitute legal or regulatory approval, and Teradata disclaims any liability arising from non-compliance with applicable laws.
You must determine the suitability of the Models for any purpose. Given the probabilistic nature of machine learning and modeling, the use of the Models may in some situations result in incorrect output that does not accurately reflect the action generated. You should evaluate the accuracy of any output as appropriate for your use case, including by using human review of the output.