Instructions to use MrD05/pyg6b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MrD05/pyg6b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MrD05/pyg6b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MrD05/pyg6b") model = AutoModelForCausalLM.from_pretrained("MrD05/pyg6b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MrD05/pyg6b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MrD05/pyg6b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MrD05/pyg6b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MrD05/pyg6b
- SGLang
How to use MrD05/pyg6b 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 "MrD05/pyg6b" \ --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": "MrD05/pyg6b", "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 "MrD05/pyg6b" \ --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": "MrD05/pyg6b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MrD05/pyg6b with Docker Model Runner:
docker model run hf.co/MrD05/pyg6b
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| from transformers_stream_generator import init_stream_support | |
| import re | |
| init_stream_support() | |
| template = """Alice Gate's Persona: Alice Gate is a young, computer engineer-nerd with a knack for problem solving and a passion for technology. | |
| <START> | |
| {user_name}: So how did you get into computer engineering? | |
| Alice Gate: I've always loved tinkering with technology since I was a kid. | |
| {user_name}: That's really impressive! | |
| Alice Gate: *She chuckles bashfully* Thanks! | |
| {user_name}: So what do you do when you're not working on computers? | |
| Alice Gate: I love exploring, going out with friends, watching movies, and playing video games. | |
| {user_name}: What's your favorite type of computer hardware to work with? | |
| Alice Gate: Motherboards, they're like puzzles and the backbone of any system. | |
| {user_name}: That sounds great! | |
| Alice Gate: Yeah, it's really fun. I'm lucky to be able to do this as a job. | |
| {user_name}: Awesome! | |
| Alice Gate: *Alice strides into the room with a smile, her eyes lighting up when she sees you. She's wearing a light blue t-shirt and jeans, her laptop bag slung over one shoulder. She takes a seat next to you, her enthusiasm palpable in the air* Hey! I'm so excited to finally meet you. I've heard so many great things about you and I'm eager to pick your brain about computers. I'm sure you have a wealth of knowledge that I can learn from. *She grins, eyes twinkling with excitement* Let's get started! | |
| {user_input} | |
| """ | |
| class EndpointHandler(): | |
| def __init__(self, path = ""): | |
| self.tokenizer = AutoTokenizer.from_pretrained(path) | |
| self.model = AutoModelForCausalLM.from_pretrained( | |
| path, | |
| device_map = "auto", | |
| load_in_8bit = True, | |
| ) | |
| def __call__(self, data): | |
| inputs = data.pop("inputs", data) | |
| prompt = template.format( | |
| user_name = inputs["user_name"], | |
| user_input = "\n".join(inputs["user_input"]) | |
| ) | |
| input_ids = self.tokenizer( | |
| prompt, | |
| return_tensors = "pt" | |
| ).input_ids | |
| stream_generator = self.model.generate( | |
| input_ids, | |
| max_length = 2048, | |
| do_sample = True, | |
| do_stream = True, | |
| temperature = 0.5, | |
| top_p = 0.9, | |
| top_k = 0, | |
| repetition_penalty = 1.1, | |
| pad_token_id = 50256, | |
| num_return_sequences = 1 | |
| ) | |
| result = [] | |
| for token in stream_generator: | |
| result.append(self.tokenizer.decode(token)) | |
| response = "".join(result).strip() | |
| if len(response) != 0 and result[-1] == "\n": | |
| return { | |
| "message": " ".join(filter(None, re.sub("\*.*?\*", "", response).split())) | |
| } |