Text Generation
Transformers
Safetensors
English
notoken_gen55
notokenlm
byte-level
tokenizer-free
hybrid
hierarchical
code
code-generation
custom_code
Instructions to use VeroLM/NoTokenLM-CodeGen-5.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use VeroLM/NoTokenLM-CodeGen-5.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="VeroLM/NoTokenLM-CodeGen-5.5", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("VeroLM/NoTokenLM-CodeGen-5.5", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use VeroLM/NoTokenLM-CodeGen-5.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "VeroLM/NoTokenLM-CodeGen-5.5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "VeroLM/NoTokenLM-CodeGen-5.5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/VeroLM/NoTokenLM-CodeGen-5.5
- SGLang
How to use VeroLM/NoTokenLM-CodeGen-5.5 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "VeroLM/NoTokenLM-CodeGen-5.5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "VeroLM/NoTokenLM-CodeGen-5.5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "VeroLM/NoTokenLM-CodeGen-5.5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "VeroLM/NoTokenLM-CodeGen-5.5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use VeroLM/NoTokenLM-CodeGen-5.5 with Docker Model Runner:
docker model run hf.co/VeroLM/NoTokenLM-CodeGen-5.5
File size: 1,973 Bytes
ce569ef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | """Byte "tokenizer" of NoTokenLM-Gen-5.5: token id == UTF-8 byte value (0..255). Byte 0 is the end-of-document marker (EOD)."""
import json
import os
from typing import Dict, List, Optional, Tuple
from transformers import PreTrainedTokenizer
class NoTokenGen55Tokenizer(PreTrainedTokenizer):
vocab_files_names = {}
model_input_names = ["input_ids"]
def __init__(self, eod_token="\x00", **kwargs):
self._byte_tokens = [chr(i) for i in range(256)] # token i is the single character whose code point is i (only used as a label)
super().__init__(eos_token=eod_token, pad_token=eod_token, bos_token=None, unk_token=None, **kwargs)
@property
def vocab_size(self) -> int:
return 256
def get_vocab(self) -> Dict[str, int]:
return {t: i for i, t in enumerate(self._byte_tokens)}
# text <-> byte ids (does not go through a vocabulary)
def encode(self, text, add_special_tokens=False, **kwargs) -> List[int]:
ids = list(text.encode("utf-8"))
return ids + [0] if add_special_tokens else ids
def decode(self, token_ids, skip_special_tokens=True, **kwargs) -> str:
if hasattr(token_ids, "tolist"):
token_ids = token_ids.tolist()
bs = bytes(int(i) for i in token_ids if not (skip_special_tokens and int(i) == 0))
return bs.decode("utf-8", errors="replace")
def _tokenize(self, text, **kwargs) -> List[str]:
return [self._byte_tokens[b] for b in text.encode("utf-8")]
def _convert_token_to_id(self, token) -> int:
return ord(token) if len(token) == 1 and ord(token) < 256 else 0
def _convert_id_to_token(self, index) -> str:
return self._byte_tokens[int(index)]
def convert_tokens_to_string(self, tokens) -> str:
return bytes(ord(t) for t in tokens).decode("utf-8", errors="replace")
def save_vocabulary(self, save_directory, filename_prefix: Optional[str] = None) -> Tuple[str]:
return ()
|