Run this model with HF Jobs
Run Teradata/codesage-large-v2 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Teradata/codesage-large-v2. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Teradata/codesage-large-v2 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Teradata/codesage-large-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Teradata/codesage-large-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Teradata/codesage-large-v2", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import CodeSage model = CodeSage.from_pretrained("Teradata/codesage-large-v2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Initial publish via td-embeddings
Browse filesFiles changed (6)
- README.mdAdded+230
- config.jsonAdded+25
- onnx/model-ffn_skip.onnxAdded+3
- special_tokens_map.jsonAdded+28
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+34
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230---license: apache-2.0language: - codelibrary_name: transformerspipeline_tag: feature-extractionbase_model: codesage/codesage-large-v2tags: - onnx - teradata - byom - embeddings - feature-extraction---
> Read the disclaimer below before using this model.
----
# codesage-large-v2 -- ONNX for Teradata BYOM
This repository hosts an **ONNX-converted** version of the upstreammodel [`codesage/codesage-large-v2`](https://huggingface.co/codesage/codesage-large-v2),packaged for the Teradata Vantage `mldb.ONNXEmbeddings` BYOMfunction. It is **not** the original PyTorch model -- only theinference graph and tokenizer needed for in-database embeddinggeneration.
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-large-v2`](https://huggingface.co/codesage/codesage-large-v2) || Architecture | `CodeSage` (encoder) || Parameters | 1,313,464,320 || Output dimensions | 2048 || 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) |
<details><summary>Full language list (9)</summary>
- `c`- `c-sharp`- `go`- `java`- `javascript`- `typescript`- `php`- `python`- `ruby`
</details>
## Quantization variants
This repository ships the following variants. Quality numbers aremeasured against the upstream PyTorch reference on a fixedCodeSearchNet sample. The **Size** column is theon-disk size of the ONNX weight file in megabytes (MB, 10^6 bytes).
| Variant | Size (MB) | p50 cosine | R@1 ||---|---|---|---|| `ffn_skip` | 1318.9 | 0.819499 | 0.919 |
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:- **ffn_skip**: dynamic int8 with the feed-forward (FFN) MatMul layers kept in **fp32**, while attention and projection MatMuls stay quantized. The FFN layers are where most of the quantization error in transformer blocks concentrates; leaving them in fp32 recovers most of the quality loss for a modest size increase. The artifact is roughly **3x smaller than fp32** (larger than the per_channel int8 sibling).
## Quickstart: using this model with Teradata BYOM
Requires Teradata Vantage with **BYOM 6+** (`mldb.ONNXEmbeddings`).
```pythonimport getpassimport teradataml as tdmlfrom huggingface_hub import hf_hub_download
repo_id = "Teradata/codesage-large-v2"model_id = "codesage-large-v2" # arbitrary, used as the BYOM model_idonnx_file = "onnx/model-ffn_skip.onnx"
# 1. Download the ONNX + tokenizer for the chosen variant.hf_hub_download(repo_id=repo_id, filename=onnx_file, local_dir="./")hf_hub_download(repo_id=repo_id, filename="tokenizer.json", local_dir="./")
# 2. Connect to Vantage.tdml.create_context( host=input("host: "), username=input("user: "), password=getpass.getpass("password: "),)
# 3. Load model + tokenizer into BYOM tables (one-time per model_id).tdml.save_byom(model_id=model_id, model_file=onnx_file, table_name="embeddings_models")tdml.save_byom(model_id=model_id, model_file="tokenizer.json", table_name="embeddings_tokenizers")```
Then call `mldb.ONNXEmbeddings` against an input table whose`txt` column carries the strings to embed:
This model emits a **2048-dimensional** embedding.Teradata's wide-table output projection is capped at **2048 columns**,which blocks the `FLOAT32(2048) + Accumulate('id')`projection that smaller models use. Pick the SQL form that matchesyour Vantage version:
**Option A -- `VARBYTE` (works on TD 17.20 and TD 20.0+)**
The vector lands as raw header-less float32 bytes(`2048 * 4 = 8192` bytes),which fits in a single `VARBYTE` column and dodges the 2048-column cap.Decode on the client side or wrap the call in a UDF that returns`FLOAT[]`.
```sqlSELECT *FROM mldb.ONNXEmbeddings( ON (SELECT id, txt FROM your_input_table) AS InputTable ON (SELECT model_id, model FROM embeddings_models WHERE model_id = 'codesage-large-v2') AS ModelTable DIMENSION ON (SELECT model_id, tokenizer FROM embeddings_tokenizers WHERE model_id = 'codesage-large-v2') AS TokenizerTable DIMENSION USING Accumulate('id') ModelOutputTensor('sentence_embedding') OutputFormat('VARBYTE(8192)') OverwriteCachedModel('*')) AS tORDER BY id;```
**Option B -- `VECTOR` (TD 20.0+ only)**
Vantage 20.0 introduced a native `VECTOR` datatype that holds thefull embedding as a single typed column, with native vector-similarityoperators available on it.
```sqlSELECT *FROM mldb.ONNXEmbeddings( ON (SELECT id, txt FROM your_input_table) AS InputTable ON (SELECT model_id, model FROM embeddings_models WHERE model_id = 'codesage-large-v2') AS ModelTable DIMENSION ON (SELECT model_id, tokenizer FROM embeddings_tokenizers WHERE model_id = 'codesage-large-v2') AS TokenizerTable DIMENSION USING Accumulate('id') ModelOutputTensor('sentence_embedding') OutputFormat('VECTOR') OverwriteCachedModel('*')) AS tORDER BY id;```
Use `VECTOR` if your Vantage version supports it; otherwise fall backto `VARBYTE`. Both forms emit the same underlying float32 values.
Pooling rule **`mean`** is applied **inside** the convertedONNX graph -- the output tensor named above already contains thepooled, post-processed embedding vector.
## Original model attribution
The original weights and training methodology belong to**the CodeSage authors**. Please cite their work, not thisrepository, in academic contexts. The canonical upstream model cardis at[`codesage/codesage-large-v2`](https://huggingface.co/codesage/codesage-large-v2);refer to it for benchmarks, training details, intended use, andcitation information.
## Reporting issues
For ONNX-conversion or BYOM-compatibility issues specific to thisTeradata-converted artifact, please open a **Discussion** on thismodel's Hugging Face page. Questions about the underlying modelquality, training, or intended use should go to the upstreammaintainer'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.12345678910111213141516171819202122232425{ "_name_or_path": "codesage/codesage-large-v2", "architectures": [ "CodeSage" ], "auto_map": { "AutoConfig": "config_codesage.CodeSageConfig", "AutoTokenizer": "tokenization_codesage.CodeSageTokenizer", "AutoModel": "modeling_codesage.CodeSageModel", "AutoModelForMaskedLM": "modeling_codesage.CodeSageForMaskedLM", "AutoModelForSequenceClassification": "modeling_codesage.CodeSageForSequenceClassification" }, "activation_function": "gelu_new", "attention_dropout_prob": 0.1, "embedding_dropout_prob": 0.1, "initializer_range": 0.02, "layer_norm_epsilon": 1e-05, "hidden_size": 2048, "num_attention_heads": 16, "num_hidden_layers": 24, "intermediate_size": 8192, "max_position_embeddings": 2048, "residual_dropout_prob": 0.1, "vocab_size": 49154}123version https://git-lfs.github.com/spec/v1oid sha256:e276a373d90da222c97e3248bd8f40c595a01c1613a022958fe93de24a8e41b4size 131891613512345678910111213141516171819202122232425262728{ "additional_special_tokens": [ "<|endoftext|>", "<fim_prefix>", "<fim_middle>", "<fim_suffix>", "<fim_pad>", "<filename>", "<gh_stars>", "<issue_start>", "<issue_comment>", "<issue_closed>", "<jupyter_start>", "<jupyter_text>", "<jupyter_code>", "<jupyter_output>", "<empty_output>", "<commit_before>", "<commit_msg>", "<commit_after>", "<reponame>" ], "bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "mask_token": "<mask>", "pad_token": "<pad>", "unk_token": "<|endoftext|>"}12345678910111213141516171819202122232425262728293031323334{ "add_prefix_space": false, "additional_special_tokens": [ "<|endoftext|>", "<fim_prefix>", "<fim_middle>", "<fim_suffix>", "<fim_pad>", "<filename>", "<gh_stars>", "<issue_start>", "<issue_comment>", "<issue_closed>", "<jupyter_start>", "<jupyter_text>", "<jupyter_code>", "<jupyter_output>", "<empty_output>", "<commit_before>", "<commit_msg>", "<commit_after>", "<reponame>" ], "bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "add_eos_token": true, "model_max_length": 1000000000000000019884624838656, "unk_token": "<|endoftext|>", "vocab_size": 49152, "tokenizer_class": "CodeSageTokenizer", "auto_map": { "AutoTokenizer": ["tokenization_codesage.CodeSageTokenizer", null] }}README.mdAdded+230
config.jsonAdded+25
onnx/model-ffn_skip.onnxAdded+3
special_tokens_map.jsonAdded+28
tokenizer.jsonAdded
tokenizer_config.jsonAdded+34