Instructions to use ryefoxlime/TADBot with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ryefoxlime/TADBot with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ryefoxlime/TADBot")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ryefoxlime/TADBot", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ryefoxlime/TADBot with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ryefoxlime/TADBot" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ryefoxlime/TADBot", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ryefoxlime/TADBot
- SGLang
How to use ryefoxlime/TADBot 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 "ryefoxlime/TADBot" \ --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": "ryefoxlime/TADBot", "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 "ryefoxlime/TADBot" \ --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": "ryefoxlime/TADBot", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ryefoxlime/TADBot with Docker Model Runner:
docker model run hf.co/ryefoxlime/TADBot
| import torch | |
| class SAM(torch.optim.Optimizer): | |
| def __init__(self, params, base_optimizer, rho=0.05, adaptive=False, **kwargs): | |
| assert rho >= 0.0, f"Invalid rho, should be non-negative: {rho}" | |
| defaults = dict(rho=rho, adaptive=adaptive, **kwargs) | |
| super(SAM, self).__init__(params, defaults) | |
| self.base_optimizer = base_optimizer(self.param_groups, **kwargs) | |
| self.param_groups = self.base_optimizer.param_groups | |
| def first_step(self, zero_grad=False): | |
| grad_norm = self._grad_norm() | |
| for group in self.param_groups: | |
| scale = group["rho"] / (grad_norm + 1e-12) | |
| for p in group["params"]: | |
| if p.grad is None: continue | |
| self.state[p]["old_p"] = p.data.clone() | |
| e_w = (torch.pow(p, 2) if group["adaptive"] else 1.0) * p.grad * scale.to(p) | |
| p.add_(e_w) # climb to the local maximum "w + e(w)" | |
| if zero_grad: self.zero_grad() | |
| def second_step(self, zero_grad=False): | |
| for group in self.param_groups: | |
| for p in group["params"]: | |
| if p.grad is None: continue | |
| p.data = self.state[p]["old_p"] # get back to "w" from "w + e(w)" | |
| self.base_optimizer.step() # do the actual "sharpness-aware" update | |
| if zero_grad: self.zero_grad() | |
| def step(self, closure=None): | |
| assert closure is not None, "Sharpness Aware Minimization requires closure, but it was not provided" | |
| closure = torch.enable_grad()(closure) # the closure should do a full forward-backward pass | |
| self.first_step(zero_grad=True) | |
| closure() | |
| self.second_step() | |
| def _grad_norm(self): | |
| shared_device = self.param_groups[0]["params"][0].device # put everything on the same device, in case of model parallelism | |
| norm = torch.norm( | |
| torch.stack([ | |
| ((torch.abs(p) if group["adaptive"] else 1.0) * p.grad).norm(p=2).to(shared_device) | |
| for group in self.param_groups for p in group["params"] | |
| if p.grad is not None | |
| ]), | |
| p=2 | |
| ) | |
| return norm | |
| def load_state_dict(self, state_dict): | |
| super().load_state_dict(state_dict) | |
| self.base_optimizer.param_groups = self.param_groups | |