Run this model with HF Jobs
Run InstaDeepAI/ChatNT 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 and TRL to fine-tune https://huggingface.co/InstaDeepAI/ChatNT. 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/InstaDeepAI/ChatNT 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.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/InstaDeepAI/ChatNT. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/InstaDeepAI/ChatNT. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use InstaDeepAI/ChatNT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use InstaDeepAI/ChatNT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="InstaDeepAI/ChatNT", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("InstaDeepAI/ChatNT", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use InstaDeepAI/ChatNT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "InstaDeepAI/ChatNT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "InstaDeepAI/ChatNT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/InstaDeepAI/ChatNT
- SGLang
How to use InstaDeepAI/ChatNT 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 "InstaDeepAI/ChatNT" \ --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": "InstaDeepAI/ChatNT", "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 "InstaDeepAI/ChatNT" \ --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": "InstaDeepAI/ChatNT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use InstaDeepAI/ChatNT with Docker Model Runner:
docker model run hf.co/InstaDeepAI/ChatNT
Update chatNT.py
Browse files404 unmodified lines4054064074084094104114124135 unmodified lines4194204214224234244254264 unmodified lines43143243343443543643734 unmodified lines4724734744754764777 unmodified lines48548648748848949010 unmodified lines50150250350450550612 unmodified lines519520521522523524525526174 unmodified lines7017027037047057067077087097107117127134 unmodified lines718719720721722723724725726727728729730731167 unmodified lines89990090190290390490575 unmodified lines981982983984985986987404 unmodified lines"""# Compute English token embeddingsprint("(debug) in biobraindecoder, english tokens ids : ", english_token_ids.shape)tokens_embeddings = self.gpt_model.token_embed(english_token_ids)print("(debug) tokens_embeddings shape : ", tokens_embeddings.shape)if projected_bio_embeddings is not None:(5 unmodified lines# Insert the bio embeddings at the SEQ token positionsprocessed_tokens_ids = english_token_ids.clone()print("(debug) Inside : processed tokens ids shape : ", processed_tokens_ids.shape)print("(debug) Inside : projected bio embeddings shape : ", projected_bio_embeddings.shape)for bio_seq_num in range(num_bio_sequences):tokens_embeddings, processed_tokens_ids = self.insert_embeddings(processed_tokens_ids,4 unmodified linesprint("After call : ", tokens_embeddings.shape)# Regular GPT pass throughprint("(debug) tokens embeddings shape : ", tokens_embeddings.shape)embeddings = self.gpt_model.apply_transformer_layers(tokens_embeddings)embeddings = self.gpt_model.final_norm(embeddings)34 unmodified lines- input_embeddings with resampled_embeddings inserted at the SEQ token- tokens with the SEQ token set to -1"""def _insert(tokens_1d: torch.Tensor,7 unmodified linesresampled_embeddings (torch.Tensor):Shape (bio_sequence_length, embed_dim,)"""indices = torch.where(tokens_1d == self.seq_token_id)[0]if indices.numel() > 0:idx = indices[0].item()10 unmodified lines:-1, :]tokens_1d[idx] = -1return x, tokens_1delse:return (12 unmodified lines)tokens_acc.append(tokens_out)embeddings_acc.append(embeddings_out)tokens_acc = torch.stack(tokens_acc)embeddings_acc = torch.stack(embeddings_acc)return embeddings_acc, tokens_acc174 unmodified linesif projected_bio_embeddings is None:# Compute bio sequences embeddingsprint("(debug) shape bio tokens ids : ", bio_token_ids.shape)bio_embeddings_list = [self.biobrain_encoder(bio_token_ids=bio_token_ids[:, bio_seq_num])for bio_seq_num in range(num_bio_sequences)]print("(debug) shape of embeddings : ", bio_embeddings_list[0].shape)# Project these embeddingsprojected_bio_embeddings = [4 unmodified lines)for bio_seq_num, bio_embeddings in enumerate(bio_embeddings_list)]print("(debug) Shape output projection model : ", projected_bio_embeddings[0].shape)projected_bio_embeddings = torch.stack(projected_bio_embeddings, dim=1)print("(debug) Shape projected bio embeddings : ", projected_bio_embeddings.shape)# decodeprint("(debug) Going in biobrain decoder : ")print("(debug) English token ids : ", english_token_ids.shape)print("(debug) Projected bio embeddings : ", projected_bio_embeddings.shape)logits = self.biobrain_decoder(english_token_ids=english_token_ids,projected_bio_embeddings=projected_bio_embeddings,167 unmodified linesvalue_inputs: torch.Tensor,attention_mask: torch.Tensor = None,) -> torch.Tensor:print("(debug) Query input shape : ", query_inputs.shape)batch_size, seq_len, _ = query_inputs.shapequeries = self.query_linear(query_inputs).view( # noqa75 unmodified linesif attention_mask is None:attention_mask = build_causal_attention_mask(1, embeddings.shape[1])for layer in self.layers:print("Embedding shape in apply_transformer_layers : ", embeddings.shape)embeddings = layer(embeddings, attention_mask)return embeddings404 unmodified lines4054064074084094104115 unmodified lines4174184194204214224234244254264 unmodified lines43143243343443543634 unmodified lines4714724734744754764774784794804817 unmodified lines48949049149249349449510 unmodified lines50650750850951051151212 unmodified lines525526527528529530531532533534535174 unmodified lines7107117127137147157167177187197204 unmodified lines725726727728729730731732733167 unmodified lines90190290390490590675 unmodified lines982983984985986987404 unmodified lines"""# Compute English token embeddingstokens_embeddings = self.gpt_model.token_embed(english_token_ids)if projected_bio_embeddings is not None:(5 unmodified lines# Insert the bio embeddings at the SEQ token positionsprocessed_tokens_ids = english_token_ids.clone()print("(debug) Before call tokens embeddings shape : ", tokens_embeddings.shape)print("(debug) Before call Processed tokens ids shape : ", processed_tokens_ids.shape)print("(debug) Before call Projected bio embeddings shape : ", projected_bio_embeddings.shape)print("num bio sequences : ", num_bio_sequences)for bio_seq_num in range(num_bio_sequences):tokens_embeddings, processed_tokens_ids = self.insert_embeddings(processed_tokens_ids,4 unmodified linesprint("After call : ", tokens_embeddings.shape)# Regular GPT pass throughembeddings = self.gpt_model.apply_transformer_layers(tokens_embeddings)embeddings = self.gpt_model.final_norm(embeddings)34 unmodified lines- input_embeddings with resampled_embeddings inserted at the SEQ token- tokens with the SEQ token set to -1"""print("Insert_embeddings input shape : ")print("Tokens : ", tokens.shape)print("Input embeddings : ", input_embeddings.shape)print("Resampled embeddings : ", resampled_embeddings.shape)print("Bio seq num : ", bio_seq_num)def _insert(tokens_1d: torch.Tensor,7 unmodified linesresampled_embeddings (torch.Tensor):Shape (bio_sequence_length, embed_dim,)"""print("_insert input : ", input_embeddings_1d.shape, resampled_embeddings_1d.shape)indices = torch.where(tokens_1d == self.seq_token_id)[0]if indices.numel() > 0:idx = indices[0].item()10 unmodified lines:-1, :]tokens_1d[idx] = -1print("_insert output : ", x.shape)return x, tokens_1delse:return (12 unmodified lines)tokens_acc.append(tokens_out)embeddings_acc.append(embeddings_out)print("(Embeddings_acc[0] shape : ", embeddings_acc[0].shape)tokens_acc = torch.stack(tokens_acc)embeddings_acc = torch.stack(embeddings_acc)print("Embeddings acc shape : ", embeddings_acc.shape)return embeddings_acc, tokens_acc174 unmodified linesif projected_bio_embeddings is None:# Compute bio sequences embeddingsbio_embeddings_list = [self.biobrain_encoder(bio_token_ids=bio_token_ids[:, bio_seq_num])for bio_seq_num in range(num_bio_sequences)]# Project these embeddingsprojected_bio_embeddings = [4 unmodified lines)for bio_seq_num, bio_embeddings in enumerate(bio_embeddings_list)]projected_bio_embeddings = torch.stack(projected_bio_embeddings, dim=1)# decodelogits = self.biobrain_decoder(english_token_ids=english_token_ids,projected_bio_embeddings=projected_bio_embeddings,167 unmodified linesvalue_inputs: torch.Tensor,attention_mask: torch.Tensor = None,) -> torch.Tensor:batch_size, seq_len, _ = query_inputs.shapequeries = self.query_linear(query_inputs).view( # noqa75 unmodified linesif attention_mask is None:attention_mask = build_causal_attention_mask(1, embeddings.shape[1])for layer in self.layers:embeddings = layer(embeddings, attention_mask)return embeddings
chatNT.py+14-14