Instructions to use yujiepan/inkling-tiny-random with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yujiepan/inkling-tiny-random with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="yujiepan/inkling-tiny-random") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("yujiepan/inkling-tiny-random") model = AutoModelForMultimodalLM.from_pretrained("yujiepan/inkling-tiny-random", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yujiepan/inkling-tiny-random with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yujiepan/inkling-tiny-random" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yujiepan/inkling-tiny-random", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/yujiepan/inkling-tiny-random
- SGLang
How to use yujiepan/inkling-tiny-random 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 "yujiepan/inkling-tiny-random" \ --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": "yujiepan/inkling-tiny-random", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "yujiepan/inkling-tiny-random" \ --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": "yujiepan/inkling-tiny-random", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use yujiepan/inkling-tiny-random with Docker Model Runner:
docker model run hf.co/yujiepan/inkling-tiny-random
Upload folder using huggingface_hub
Browse files- README.md +14 -3
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -24,7 +24,7 @@ processor = AutoProcessor.from_pretrained(model_id)
|
|
| 24 |
model = AutoModelForMultimodalLM.from_pretrained(
|
| 25 |
model_id,
|
| 26 |
dtype=torch.bfloat16,
|
| 27 |
-
device_map="cuda",
|
| 28 |
)
|
| 29 |
|
| 30 |
# Synthetic multimodal inputs — no network fetch.
|
|
@@ -54,7 +54,7 @@ inputs = processor.apply_chat_template(
|
|
| 54 |
).to(model.device, dtype=model.dtype)
|
| 55 |
input_len = inputs["input_ids"].shape[-1]
|
| 56 |
outputs = model.generate(**inputs, max_new_tokens=16)
|
| 57 |
-
print(processor.decode(outputs[0]
|
| 58 |
```
|
| 59 |
|
| 60 |
### Codes to create this repo:
|
|
@@ -103,7 +103,6 @@ config_json['text_config'].update({
|
|
| 103 |
'dense_intermediate_size': 32,
|
| 104 |
'intermediate_size': 32,
|
| 105 |
'moe_intermediate_size': 32,
|
| 106 |
-
# 'n_routed_experts': 8,
|
| 107 |
})
|
| 108 |
config_json['vision_config'].update({
|
| 109 |
'decoder_dmodel': hidden_size,
|
|
@@ -136,6 +135,14 @@ with torch.no_grad():
|
|
| 136 |
for name, p in sorted(model.named_parameters()):
|
| 137 |
torch.nn.init.normal_(p, 0, 0.2)
|
| 138 |
print(name, p.shape, f'{p.numel() / num_params:.2%}', f'{p.numel() * p.element_size() / 1024**2:.2f}MB')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
model.save_pretrained(save_folder)
|
| 140 |
|
| 141 |
# HF ignores `model.mtp.*` on main load; write them with original checkpoint naming.
|
|
@@ -159,6 +166,10 @@ for i in range(num_mtp_layers):
|
|
| 159 |
state[name] = torch.empty(shape, dtype=torch.bfloat16)
|
| 160 |
torch.nn.init.normal_(state[name], 0, 0.2)
|
| 161 |
print(name, shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
save_file(state, str(path))
|
| 163 |
```
|
| 164 |
|
|
|
|
| 24 |
model = AutoModelForMultimodalLM.from_pretrained(
|
| 25 |
model_id,
|
| 26 |
dtype=torch.bfloat16,
|
| 27 |
+
device_map="cuda" if torch.cuda.is_available() else "cpu",
|
| 28 |
)
|
| 29 |
|
| 30 |
# Synthetic multimodal inputs — no network fetch.
|
|
|
|
| 54 |
).to(model.device, dtype=model.dtype)
|
| 55 |
input_len = inputs["input_ids"].shape[-1]
|
| 56 |
outputs = model.generate(**inputs, max_new_tokens=16)
|
| 57 |
+
print(processor.decode(outputs[0], skip_special_tokens=False))
|
| 58 |
```
|
| 59 |
|
| 60 |
### Codes to create this repo:
|
|
|
|
| 103 |
'dense_intermediate_size': 32,
|
| 104 |
'intermediate_size': 32,
|
| 105 |
'moe_intermediate_size': 32,
|
|
|
|
| 106 |
})
|
| 107 |
config_json['vision_config'].update({
|
| 108 |
'decoder_dmodel': hidden_size,
|
|
|
|
| 135 |
for name, p in sorted(model.named_parameters()):
|
| 136 |
torch.nn.init.normal_(p, 0, 0.2)
|
| 137 |
print(name, p.shape, f'{p.numel() / num_params:.2%}', f'{p.numel() * p.element_size() / 1024**2:.2f}MB')
|
| 138 |
+
# Upstream MoE gate bias / global_scale are F32; sconv stays BF16 in the checkpoint.
|
| 139 |
+
for name, module in model.named_modules():
|
| 140 |
+
if hasattr(module, "e_score_correction_bias"):
|
| 141 |
+
module.e_score_correction_bias = torch.nn.Parameter(
|
| 142 |
+
module.e_score_correction_bias.detach().float()
|
| 143 |
+
)
|
| 144 |
+
if name.endswith(".mlp.gate") and hasattr(module, "global_scale"):
|
| 145 |
+
module.global_scale = torch.nn.Parameter(module.global_scale.detach().float())
|
| 146 |
model.save_pretrained(save_folder)
|
| 147 |
|
| 148 |
# HF ignores `model.mtp.*` on main load; write them with original checkpoint naming.
|
|
|
|
| 166 |
state[name] = torch.empty(shape, dtype=torch.bfloat16)
|
| 167 |
torch.nn.init.normal_(state[name], 0, 0.2)
|
| 168 |
print(name, shape)
|
| 169 |
+
# Keep checkpoint key dtypes aligned even if save_pretrained downcasts.
|
| 170 |
+
for key, tensor in list(state.items()):
|
| 171 |
+
if key.endswith(".mlp.gate.bias") or key.endswith(".mlp.gate.global_scale"):
|
| 172 |
+
state[key] = tensor.float()
|
| 173 |
save_file(state, str(path))
|
| 174 |
```
|
| 175 |
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1b67f75e7f07e189a6dde338347e81a3616b7fed4f3236b0d34c957b69d25887
|
| 3 |
+
size 7337520
|