Instructions to use moondream/moondream-2b-2025-04-14-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use moondream/moondream-2b-2025-04-14-4bit with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="moondream/moondream-2b-2025-04-14-4bit", filename="moondream2-mmproj-f16.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use moondream/moondream-2b-2025-04-14-4bit with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf moondream/moondream-2b-2025-04-14-4bit:F16 # Run inference directly in the terminal: llama-cli -hf moondream/moondream-2b-2025-04-14-4bit:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf moondream/moondream-2b-2025-04-14-4bit:F16 # Run inference directly in the terminal: llama-cli -hf moondream/moondream-2b-2025-04-14-4bit: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 moondream/moondream-2b-2025-04-14-4bit:F16 # Run inference directly in the terminal: ./llama-cli -hf moondream/moondream-2b-2025-04-14-4bit: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 moondream/moondream-2b-2025-04-14-4bit:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf moondream/moondream-2b-2025-04-14-4bit:F16
Use Docker
docker model run hf.co/moondream/moondream-2b-2025-04-14-4bit:F16
- LM Studio
- Jan
- vLLM
How to use moondream/moondream-2b-2025-04-14-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moondream/moondream-2b-2025-04-14-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moondream/moondream-2b-2025-04-14-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/moondream/moondream-2b-2025-04-14-4bit:F16
- Ollama
How to use moondream/moondream-2b-2025-04-14-4bit with Ollama:
ollama run hf.co/moondream/moondream-2b-2025-04-14-4bit:F16
- Unsloth Studio
How to use moondream/moondream-2b-2025-04-14-4bit 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 moondream/moondream-2b-2025-04-14-4bit 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 moondream/moondream-2b-2025-04-14-4bit to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for moondream/moondream-2b-2025-04-14-4bit to start chatting
- Atomic Chat new
- Docker Model Runner
How to use moondream/moondream-2b-2025-04-14-4bit with Docker Model Runner:
docker model run hf.co/moondream/moondream-2b-2025-04-14-4bit:F16
- Lemonade
How to use moondream/moondream-2b-2025-04-14-4bit with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull moondream/moondream-2b-2025-04-14-4bit:F16
Run and chat with the model
lemonade run user.moondream-2b-2025-04-14-4bit-F16
List all available models
lemonade list
snowclipsed commited on
Commit ·
8cb4b5e
1
Parent(s): e15c30f
remove gsize check, replace with quantized_linear directly
Browse files- moondream.py +6 -10
moondream.py
CHANGED
|
@@ -77,36 +77,32 @@ class MoondreamModel(nn.Module):
|
|
| 77 |
self.vision = build_vision_model(config.vision, dtype)
|
| 78 |
self.text = build_text_model(config.text, dtype)
|
| 79 |
|
| 80 |
-
# Region Model
|
| 81 |
-
linear_cls = (
|
| 82 |
-
QuantizedLinear if config.region.group_size is not None else nn.Linear
|
| 83 |
-
)
|
| 84 |
self.region = nn.ModuleDict(
|
| 85 |
{
|
| 86 |
-
"coord_encoder":
|
| 87 |
config.region.coord_feat_dim, config.region.dim, dtype=dtype
|
| 88 |
),
|
| 89 |
"coord_decoder": nn.ModuleDict(
|
| 90 |
{
|
| 91 |
-
"fc1":
|
| 92 |
config.region.dim, config.region.inner_dim, dtype=dtype
|
| 93 |
),
|
| 94 |
-
"fc2":
|
| 95 |
config.region.inner_dim,
|
| 96 |
config.region.coord_out_dim,
|
| 97 |
dtype=dtype,
|
| 98 |
),
|
| 99 |
}
|
| 100 |
),
|
| 101 |
-
"size_encoder":
|
| 102 |
config.region.size_feat_dim, config.region.dim, dtype=dtype
|
| 103 |
),
|
| 104 |
"size_decoder": nn.ModuleDict(
|
| 105 |
{
|
| 106 |
-
"fc1":
|
| 107 |
config.region.dim, config.region.inner_dim, dtype=dtype
|
| 108 |
),
|
| 109 |
-
"fc2":
|
| 110 |
config.region.inner_dim,
|
| 111 |
config.region.size_out_dim,
|
| 112 |
dtype=dtype,
|
|
|
|
| 77 |
self.vision = build_vision_model(config.vision, dtype)
|
| 78 |
self.text = build_text_model(config.text, dtype)
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
self.region = nn.ModuleDict(
|
| 81 |
{
|
| 82 |
+
"coord_encoder": QuantizedLinear(
|
| 83 |
config.region.coord_feat_dim, config.region.dim, dtype=dtype
|
| 84 |
),
|
| 85 |
"coord_decoder": nn.ModuleDict(
|
| 86 |
{
|
| 87 |
+
"fc1": QuantizedLinear(
|
| 88 |
config.region.dim, config.region.inner_dim, dtype=dtype
|
| 89 |
),
|
| 90 |
+
"fc2": QuantizedLinear(
|
| 91 |
config.region.inner_dim,
|
| 92 |
config.region.coord_out_dim,
|
| 93 |
dtype=dtype,
|
| 94 |
),
|
| 95 |
}
|
| 96 |
),
|
| 97 |
+
"size_encoder": QuantizedLinear(
|
| 98 |
config.region.size_feat_dim, config.region.dim, dtype=dtype
|
| 99 |
),
|
| 100 |
"size_decoder": nn.ModuleDict(
|
| 101 |
{
|
| 102 |
+
"fc1": QuantizedLinear(
|
| 103 |
config.region.dim, config.region.inner_dim, dtype=dtype
|
| 104 |
),
|
| 105 |
+
"fc2": QuantizedLinear(
|
| 106 |
config.region.inner_dim,
|
| 107 |
config.region.size_out_dim,
|
| 108 |
dtype=dtype,
|