Upload folder using huggingface_hub
Browse filesFiles changed (8)
- LICENSEAdded+21
- README.mdAdded+98
- config.jsonAdded+22
- manifest.jsonAdded+17
- model_quantized.onnxAdded+3
- special_tokens_map.jsonAdded+51
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+58
123456789101112131415161718192021MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798---license: mittags: - onnx - int8 - quantized - code - embeddings - justembedbase_model: microsoft/codebert-baselibrary_name: onnxruntimepipeline_tag: feature-extraction---
# CodeBERT INT8 — ONNX Quantized
ONNX INT8 quantized version of [microsoft/codebert-base](https://huggingface.co/microsoft/codebert-base) for efficient code and natural language embeddings.
## Model Details
| Property | Value ||----------|-------|| Base Model | [microsoft/codebert-base](https://huggingface.co/microsoft/codebert-base) || Format | ONNX || Quantization | INT8 (dynamic quantization) || Embedding Dimension | 768 || Quantized by | [JustEmbed](https://pypi.org/project/justembed/) |
## What is this?
This is a quantized ONNX export of CodeBERT, a bimodal pre-trained model for programming and natural language by Microsoft Research. The INT8 quantization reduces model size and improves inference speed while maintaining high accuracy for code-related embeddings.
CodeBERT is trained on both natural language and programming language data (Python, Java, JavaScript, PHP, Ruby, Go).
## Use Cases
- Code search and retrieval- Code documentation matching- Programming language embeddings- Code similarity detection- Natural language to code matching
## Files
- `model_quantized.onnx` — INT8 quantized ONNX model- `tokenizer.json` — Fast tokenizer- `config.json` — Model configuration
## Usage with JustEmbed
```pythonfrom justembed import Embedder
embedder = Embedder("codebert-int8")vectors = embedder.embed(["def sort_list(arr): return sorted(arr)"])```
## Usage with ONNX Runtime
```pythonimport onnxruntime as ortfrom transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(".")session = ort.InferenceSession("model_quantized.onnx")
inputs = tokenizer("def sort_list(arr): return sorted(arr)", return_tensors="np")outputs = session.run(None, dict(inputs))```
## Quantization Details
- Method: Dynamic INT8 quantization via ONNX Runtime- Source: Original PyTorch weights converted to ONNX, then quantized- Speed: ~2-3x faster inference than FP32- Size: ~4x smaller than FP32
## License
This model is a derivative work of [microsoft/codebert-base](https://huggingface.co/microsoft/codebert-base).
The original model is licensed under **MIT License**. This quantized version is distributed under the same license. See the [LICENSE](LICENSE) file for the full text.
## Citation
```bibtex@inproceedings{feng2020codebert, title={CodeBERT: A Pre-Trained Model for Programming and Natural Languages}, author={Feng, Zhangyin and Guo, Daya and Tang, Duyu and Duan, Nan and Feng, Xiaocheng and Gong, Ming and Shou, Linjun and Qin, Bing and Liu, Ting and Jiang, Daxin and Zhou, Ming}, booktitle={Findings of EMNLP}, year={2020}}```
## Acknowledgments
- Original model by [Microsoft Research](https://github.com/microsoft/CodeBERT)- Quantization and packaging by [JustEmbed](https://pypi.org/project/justembed/)12345678910111213141516171819202122{ "architectures": [ "RobertaModel" ], "attention_probs_dropout_prob": 0.1, "bos_token_id": 0, "eos_token_id": 2, "hidden_act": "gelu", "hidden_dropout_prob": 0.1, "hidden_size": 768, "initializer_range": 0.02, "intermediate_size": 3072, "layer_norm_eps": 1e-05, "max_position_embeddings": 514, "model_type": "roberta", "num_attention_heads": 12, "num_hidden_layers": 12, "output_past": true, "pad_token_id": 1, "type_vocab_size": 1, "vocab_size": 50265}1234567891011121314151617{ "schema_version": "1.0", "name": "codebert-int8", "version": "1.0.1", "type": "single", "model_class": "BERTEmbedder", "embedding_dim": 768, "min_justembed_version": "0.1.1a9", "description": "Code embeddings for programming and software documentation (INT8 quantized)", "files": null, "metadata": null, "stages": null, "max_sequence_length": 512, "license": "MIT", "source": "microsoft/codebert-base", "quantization": "int8"}123version https://git-lfs.github.com/spec/v1oid sha256:149eb7ed0e3b5b1cf6a7e0194c56a1b83ba104baecb746b40a6b6c0c4ba1b061size 126315271123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051{ "bos_token": { "content": "<s>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }, "cls_token": { "content": "<s>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }, "eos_token": { "content": "</s>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }, "mask_token": { "content": "<mask>", "lstrip": true, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "<pad>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }, "sep_token": { "content": "</s>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }, "unk_token": { "content": "<unk>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758{ "add_prefix_space": false, "added_tokens_decoder": { "0": { "content": "<s>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false, "special": true }, "1": { "content": "<pad>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false, "special": true }, "2": { "content": "</s>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false, "special": true }, "3": { "content": "<unk>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false, "special": true }, "50264": { "content": "<mask>", "lstrip": true, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "bos_token": "<s>", "clean_up_tokenization_spaces": false, "cls_token": "<s>", "eos_token": "</s>", "errors": "replace", "extra_special_tokens": {}, "mask_token": "<mask>", "model_max_length": 512, "pad_token": "<pad>", "sep_token": "</s>", "tokenizer_class": "RobertaTokenizer", "trim_offsets": true, "unk_token": "<unk>"}LICENSEAdded+21
README.mdAdded+98
config.jsonAdded+22
manifest.jsonAdded+17
model_quantized.onnxAdded+3
special_tokens_map.jsonAdded+51
tokenizer.jsonAdded
tokenizer_config.jsonAdded+58