Text Generation
Transformers
Safetensors
friday
vision-language
multimodal
custom_code
bf16
conversational
Instructions to use kevin510/friday with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kevin510/friday with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kevin510/friday", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("kevin510/friday", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use kevin510/friday with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kevin510/friday" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kevin510/friday", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/kevin510/friday
- SGLang
How to use kevin510/friday 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 "kevin510/friday" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kevin510/friday", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "kevin510/friday" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kevin510/friday", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use kevin510/friday with Docker Model Runner:
docker model run hf.co/kevin510/friday
Download friday_model/util/s2wrapper/utils.py from kevin510/friday: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/kevin510/friday/resolve/main/friday_model/util/s2wrapper/utils.py
- Command line
-
hf download hf://kevin510/friday/friday_model/util/s2wrapper/utils.py
-
curl -L -o utils.py https://huggingface.co/kevin510/friday/resolve/main/friday_model/util/s2wrapper/utils.py
1.58 kB
| # ------------------------------------------------------------------------------------------ | |
| # Copyright (c) 2024 Baifeng Shi. | |
| # All rights reserved. | |
| # | |
| # Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | |
| # ------------------------------------------------------------------------------------------ | |
| import torch | |
| def split_chessboard(x, num_split): | |
| """ | |
| x: b * c * h * w | |
| Deividing x into num_split**2 sub-squares, and concatenate all the sub-squares on the batch dimension | |
| """ | |
| B, C, H, W = x.shape | |
| assert H % num_split == 0 and W % num_split == 0 | |
| h, w = H // num_split, W // num_split | |
| x_split = torch.cat([x[:, :, i*h:(i+1)*h, j*w:(j+1)*w] for i in range(num_split) for j in range(num_split)], dim=0) | |
| return x_split | |
| def merge_chessboard(x, num_split): | |
| """ | |
| x: b * c * h * w | |
| Assuming x contains num_split**2 sub-squares concatenated along batch dimension, merge the sub-squares back to the original whole square. | |
| (inverse of split_chessboard) | |
| """ | |
| B, C, H, W = x.shape | |
| assert B % (num_split**2) == 0 | |
| b = B // (num_split**2) | |
| x_merge = torch.cat([torch.cat([x[(i*num_split + j)*b:(i*num_split + j + 1)*b] for j in range(num_split)], dim=-1) | |
| for i in range(num_split)], dim=-2) | |
| return x_merge | |
| def batched_forward(model, x, batch_size=-1): | |
| if batch_size == -1: | |
| return model(x) | |
| else: | |
| x_batched = x.split(batch_size) | |
| outs = [model(x) for x in x_batched] | |
| return torch.cat(outs, dim=0) | |