Instructions to use aframson/RDPD-mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aframson/RDPD-mini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aframson/RDPD-mini", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("aframson/RDPD-mini", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aframson/RDPD-mini with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aframson/RDPD-mini" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aframson/RDPD-mini", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/aframson/RDPD-mini
- SGLang
How to use aframson/RDPD-mini 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 "aframson/RDPD-mini" \ --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": "aframson/RDPD-mini", "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 "aframson/RDPD-mini" \ --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": "aframson/RDPD-mini", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use aframson/RDPD-mini with Docker Model Runner:
docker model run hf.co/aframson/RDPD-mini
File size: 1,785 Bytes
88541c2 | 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 | from tokenizers import Tokenizer, models, pre_tokenizers, trainers, decoders
import json
class OBITokenizer:
def __init__(self):
# Initialize a BPE model for tokenization
bpe_model = models.BPE()
# Initialize the tokenizer
self.tokenizer = Tokenizer(bpe_model)
# Add pre-tokenization and decoding steps if needed
self.tokenizer.pre_tokenizer = pre_tokenizers.ByteLevel()
self.tokenizer.decoder = decoders.ByteLevel()
def train(self, files,save_path):
# Training: Fit the tokenizer on your text data
trainer = trainers.BpeTrainer(special_tokens=["[PAD]", "[CLS]", "[SEP]", "[MASK]", "[UNK]"])
self.tokenizer.train(trainer=trainer, files=files)
# Save the trained tokenizer to a file
self.tokenizer.save(save_path)
def save_config(self, config_file):
# Serialize the tokenizer's config to a JSON file
config_dict = {
"tokenizer_type": "custom",
"vocab_size": self.tokenizer.get_vocab_size(),
"tokenizer_class": "OBITokenizer",
"auto_map": {
"AutoTokenizer": ["tokenizeConfig.OBITokenizer"]
},
"bos_token": "[CLS]",
"eos_token": "[SEP]",
"unk_token": "[UNK]",
"pad_token": "[PAD]",
"mask_token": "[MASK]"
# Add other custom settings if needed
}
with open(config_file, "w") as f:
json.dump(config_dict, f)
def encode(self, text):
# Encode text using the custom tokenizer
encoding = self.tokenizer.encode(text)
return encoding.ids
def decode(self, ids):
# Decode IDs to text using the custom tokenizer
return self.tokenizer.decode(ids) |