Text Generation
Transformers
Safetensors
taonet
trust-remote-code
sentencepiece
custom-architecture
custom_code
Instructions to use TaoTern/TaoNet-mini-A2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TaoTern/TaoNet-mini-A2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TaoTern/TaoNet-mini-A2", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("TaoTern/TaoNet-mini-A2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TaoTern/TaoNet-mini-A2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TaoTern/TaoNet-mini-A2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TaoTern/TaoNet-mini-A2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/TaoTern/TaoNet-mini-A2
- SGLang
How to use TaoTern/TaoNet-mini-A2 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 "TaoTern/TaoNet-mini-A2" \ --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": "TaoTern/TaoNet-mini-A2", "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 "TaoTern/TaoNet-mini-A2" \ --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": "TaoTern/TaoNet-mini-A2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use TaoTern/TaoNet-mini-A2 with Docker Model Runner:
docker model run hf.co/TaoTern/TaoNet-mini-A2
| """Pretrain dataset for HuggingFace datasets.""" | |
| from typing import Dict | |
| import torch | |
| from taoTrain.config import TrainingConfig | |
| from taoTrain.data.hf_base import BaseHFDataset | |
| class PretrainDataset(BaseHFDataset): | |
| """Dataset for pretraining with raw text.""" | |
| def _preprocess(self): | |
| """Tokenize text data.""" | |
| dataset_config = self.config.dataset | |
| text_column = dataset_config.text_column | |
| def tokenize_function(examples): | |
| # Concatenate all texts | |
| concatenated_examples = { | |
| k: sum(examples[k], []) for k in examples.keys() | |
| } | |
| total_length = len(concatenated_examples[text_column]) | |
| # We'll use max_seq_length for training | |
| total_length = (total_length // self.config.model.max_seq_length) * self.config.model.max_seq_length | |
| # Tokenize | |
| tokenized = self.tokenizer( | |
| concatenated_examples[text_column], | |
| truncation=False, # We'll chunk below | |
| return_special_tokens_mask=False, | |
| ) | |
| # Chunk tokenized text | |
| result = { | |
| "input_ids": [], | |
| "attention_mask": [], | |
| } | |
| for i in range(0, total_length, self.config.model.max_seq_length): | |
| result["input_ids"].append( | |
| tokenized["input_ids"][i:i + self.config.model.max_seq_length] | |
| ) | |
| result["attention_mask"].append( | |
| tokenized["attention_mask"][i:i + self.config.model.max_seq_length] | |
| ) | |
| return result | |
| # Preprocess in batches | |
| self.data = self.data.map( | |
| tokenize_function, | |
| batched=True, | |
| batch_size=100, | |
| remove_columns=self.data.column_names, | |
| desc="Tokenizing...", | |
| ) | |
| def __getitem__(self, idx: int) -> Dict[str, torch.Tensor]: | |
| """Get preprocessed sample.""" | |
| item = self.data[idx] | |
| input_ids = torch.tensor(item["input_ids"], dtype=torch.long) | |
| attention_mask = torch.tensor(item["attention_mask"], dtype=torch.long) | |
| # For pretrain, labels = input_ids shifted by 1 (next token prediction) | |
| # Position i predicts token at position i+1 | |
| labels = input_ids[1:].clone() | |
| labels = torch.cat([labels, torch.tensor([-100])], dim=0) | |
| # Mark padding tokens as -100 to ignore in loss computation | |
| labels[attention_mask == 0] = -100 | |
| return { | |
| "input_ids": input_ids, | |
| "attention_mask": attention_mask, | |
| "labels": labels, | |
| } | |