Instructions to use willgrobots/checkpointsaved with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use willgrobots/checkpointsaved with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="willgrobots/checkpointsaved", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("willgrobots/checkpointsaved", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use willgrobots/checkpointsaved with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf willgrobots/checkpointsaved:F16 # Run inference directly in the terminal: llama cli -hf willgrobots/checkpointsaved:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf willgrobots/checkpointsaved:F16 # Run inference directly in the terminal: llama cli -hf willgrobots/checkpointsaved:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf willgrobots/checkpointsaved:F16 # Run inference directly in the terminal: ./llama-cli -hf willgrobots/checkpointsaved:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf willgrobots/checkpointsaved:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf willgrobots/checkpointsaved:F16
Use Docker
docker model run hf.co/willgrobots/checkpointsaved:F16
- LM Studio
- Jan
- vLLM
How to use willgrobots/checkpointsaved with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "willgrobots/checkpointsaved" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "willgrobots/checkpointsaved", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/willgrobots/checkpointsaved:F16
- SGLang
How to use willgrobots/checkpointsaved 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 "willgrobots/checkpointsaved" \ --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": "willgrobots/checkpointsaved", "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 "willgrobots/checkpointsaved" \ --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": "willgrobots/checkpointsaved", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use willgrobots/checkpointsaved with Ollama:
ollama run hf.co/willgrobots/checkpointsaved:F16
- Unsloth Studio
How to use willgrobots/checkpointsaved with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for willgrobots/checkpointsaved to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for willgrobots/checkpointsaved to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for willgrobots/checkpointsaved to start chatting
- Atomic Chat new
- Docker Model Runner
How to use willgrobots/checkpointsaved with Docker Model Runner:
docker model run hf.co/willgrobots/checkpointsaved:F16
- Lemonade
How to use willgrobots/checkpointsaved with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull willgrobots/checkpointsaved:F16
Run and chat with the model
lemonade run user.checkpointsaved-F16
List all available models
lemonade list
| import torch | |
| from .vision_encoder import VisionEncoder | |
| from .configuration_moondream import MoondreamConfig | |
| from transformers import PreTrainedModel | |
| from .modeling_phi import PhiForCausalLM | |
| from .configuration_moondream import PhiConfig | |
| class Moondream(PreTrainedModel): | |
| config_class = MoondreamConfig | |
| _supports_flash_attn_2 = True | |
| def __init__(self, config): | |
| super().__init__(config) | |
| self.vision_encoder = VisionEncoder( | |
| use_flash_attn=config._attn_implementation == "flash_attention_2" | |
| ) | |
| if type(config.text_config) == dict: | |
| phi_config = PhiConfig( | |
| **config.text_config, attn_implementation=config._attn_implementation | |
| ) | |
| else: | |
| phi_config = config.text_config | |
| self.text_model = PhiForCausalLM(phi_config) | |
| def device(self): | |
| return self.text_model.device | |
| def encode_image(self, image): | |
| with torch.no_grad(): | |
| return self.vision_encoder(image) | |
| def input_embeds(self, prompt, image_embeds, tokenizer): | |
| def _tokenize(txt): | |
| return tokenizer( | |
| txt, return_tensors="pt", add_special_tokens=False | |
| ).input_ids.to(self.device) | |
| text_emb = self.text_model.get_input_embeddings() | |
| # Add BOS token | |
| embeds = [] | |
| embeds.append( | |
| text_emb((torch.tensor([[tokenizer.bos_token_id]], device=self.device))) | |
| ) | |
| if "<image>" not in prompt: | |
| embeds.append(text_emb(_tokenize(prompt))) | |
| else: | |
| assert prompt.count("<image>") == 1 | |
| before, after = prompt.split("<image>") | |
| if len(before) > 0: | |
| embeds.append(text_emb(_tokenize(before))) | |
| embeds.append(image_embeds.to(self.device)) | |
| if len(after) > 0: | |
| embeds.append(text_emb(_tokenize(after))) | |
| return torch.cat(embeds, dim=1) | |
| def generate( | |
| self, | |
| image_embeds, | |
| prompt, | |
| tokenizer, | |
| max_new_tokens=128, | |
| **kwargs, | |
| ): | |
| generate_config = { | |
| "eos_token_id": tokenizer.eos_token_id, | |
| "bos_token_id": tokenizer.bos_token_id, | |
| "pad_token_id": tokenizer.bos_token_id, | |
| "max_new_tokens": max_new_tokens, | |
| **kwargs, | |
| } | |
| with torch.no_grad(): | |
| inputs_embeds = self.input_embeds(prompt, image_embeds, tokenizer) | |
| output_ids = self.text_model.generate( | |
| inputs_embeds=inputs_embeds, **generate_config | |
| ) | |
| return tokenizer.batch_decode(output_ids, skip_special_tokens=True) | |
| def answer_question( | |
| self, | |
| image_embeds, | |
| question, | |
| tokenizer, | |
| chat_history="", | |
| result_queue=None, | |
| **kwargs, | |
| ): | |
| prompt = f"<image>\n\n{chat_history}Question: {question}\n\nAnswer:" | |
| answer = self.generate( | |
| image_embeds, | |
| prompt, | |
| tokenizer=tokenizer, | |
| max_new_tokens=512, | |
| **kwargs, | |
| )[0] | |
| cleaned_answer = answer.strip() | |
| # Use the result_queue to pass the result if it is provided | |
| if result_queue: | |
| result_queue.put(cleaned_answer) | |
| else: | |
| return cleaned_answer | |
| def batch_answer( | |
| self, | |
| images, | |
| prompts, | |
| tokenizer, | |
| **kwargs, | |
| ): | |
| image_embeds = self.encode_image(images) | |
| templated_prompts = [ | |
| f"<image>\n\nQuestion: {prompt}\n\nAnswer:" for prompt in prompts | |
| ] | |
| prompt_embs = [ | |
| self.input_embeds(prompt, image_embed.unsqueeze(0), tokenizer)[0] | |
| for prompt, image_embed in zip(templated_prompts, image_embeds) | |
| ] | |
| bos_emb = prompt_embs[0][0] | |
| max_len = max([p.shape[0] for p in prompt_embs]) | |
| inputs_embeds = torch.cat( | |
| [ | |
| torch.cat([bos_emb.repeat(max_len - p.shape[0], 1), p]).unsqueeze(0) | |
| for p in prompt_embs | |
| ], | |
| dim=0, | |
| ) | |
| attention_mask = torch.cat( | |
| [ | |
| torch.cat( | |
| [ | |
| torch.zeros( | |
| 1, | |
| max_len - p.shape[0], | |
| device=self.device, | |
| dtype=torch.long, | |
| ), | |
| torch.ones(1, p.shape[0], device=self.device, dtype=torch.long), | |
| ], | |
| dim=1, | |
| ) | |
| for p in prompt_embs | |
| ], | |
| dim=0, | |
| ) | |
| generate_config = { | |
| "eos_token_id": tokenizer.eos_token_id, | |
| "bos_token_id": tokenizer.bos_token_id, | |
| "pad_token_id": tokenizer.bos_token_id, | |
| "max_new_tokens": 512, | |
| **kwargs, | |
| } | |
| with torch.no_grad(): | |
| output_ids = self.text_model.generate( | |
| inputs_embeds=inputs_embeds, | |
| attention_mask=attention_mask, | |
| **generate_config, | |
| ) | |
| return [ | |
| x.strip() | |
| for x in tokenizer.batch_decode(output_ids, skip_special_tokens=True) | |
| ] | |