Feature Extraction
Safetensors
Model2Vec
sentence-transformers
code
distiller
code-search
code-embeddings
distillation
static-embeddings
tokenlearn
Instructions to use sarthak1/codemalt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Model2Vec
How to use sarthak1/codemalt with Model2Vec:
from model2vec import StaticModel model = StaticModel.from_pretrained("sarthak1/codemalt") - sentence-transformers
How to use sarthak1/codemalt with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("sarthak1/codemalt") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
| from string import punctuation | |
| from tokenizers import Regex, Tokenizer | |
| from tokenizers.normalizers import Replace, Sequence, Strip | |
| def replace_normalizer( | |
| tokenizer: Tokenizer, | |
| ) -> Tokenizer: | |
| """ | |
| Replace the normalizer for the tokenizer. | |
| The new normalizer will replace punctuation with a space before and after the punctuation. | |
| It will also replace multiple spaces with a single space and strip the right side of the string. | |
| If the tokenizer already has a normalizer, it will be added to the new normalizer. | |
| If the tokenizer does not have a normalizer, a new normalizer will be created. | |
| :param tokenizer: The tokenizer to change. | |
| :return: The tokenizer with a replaced normalizer. | |
| """ | |
| normalizer = tokenizer.normalizer | |
| new_normalizers = [] | |
| for char in punctuation: | |
| new_normalizers.append(Replace(char, f" {char} ")) | |
| new_normalizers.append(Replace(Regex(r"\s+"), " ")) | |
| new_normalizers.append(Strip(right=True)) | |
| if normalizer is None: | |
| normalizer = Sequence(new_normalizers) # type: ignore | |
| else: | |
| normalizer = Sequence([normalizer, *new_normalizers]) # type: ignore | |
| tokenizer.normalizer = normalizer # type: ignore | |
| return tokenizer | |