Instructions to use trl-internal-testing/tiny-Inkling2ForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-Inkling2ForConditionalGeneration with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="trl-internal-testing/tiny-Inkling2ForConditionalGeneration") 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("trl-internal-testing/tiny-Inkling2ForConditionalGeneration") model = AutoModelForMultimodalLM.from_pretrained("trl-internal-testing/tiny-Inkling2ForConditionalGeneration", 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 trl-internal-testing/tiny-Inkling2ForConditionalGeneration with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trl-internal-testing/tiny-Inkling2ForConditionalGeneration" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-Inkling2ForConditionalGeneration", "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/trl-internal-testing/tiny-Inkling2ForConditionalGeneration
- SGLang
How to use trl-internal-testing/tiny-Inkling2ForConditionalGeneration 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 "trl-internal-testing/tiny-Inkling2ForConditionalGeneration" \ --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": "trl-internal-testing/tiny-Inkling2ForConditionalGeneration", "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 "trl-internal-testing/tiny-Inkling2ForConditionalGeneration" \ --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": "trl-internal-testing/tiny-Inkling2ForConditionalGeneration", "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 trl-internal-testing/tiny-Inkling2ForConditionalGeneration with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-Inkling2ForConditionalGeneration
Upload Inkling2ForConditionalGeneration
#1
by qgallouedec HF Staff - opened
- chat_template.jinja +7 -0
- config.json +15 -1
- generation_config.json +2 -5
- hf_quant_config.json +141 -0
- model.safetensors +2 -2
chat_template.jinja
CHANGED
|
@@ -66,6 +66,7 @@
|
|
| 66 |
{%- set header.text = header.text ~ message.name -%}
|
| 67 |
{%- endif -%}
|
| 68 |
{%- set rtok = header.text -%}
|
|
|
|
| 69 |
|
| 70 |
{%- if message.role == "assistant" and message.reasoning_content is defined and message.reasoning_content -%}
|
| 71 |
{{- rtok ~ "<|content_thinking|>" ~ message.reasoning_content ~ "<|end_message|>" -}}
|
|
@@ -123,6 +124,12 @@
|
|
| 123 |
{%- if message.role == "assistant" -%}
|
| 124 |
{{- "<|content_model_end_sampling|>" -}}
|
| 125 |
{%- endif -%}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
{%- endfor -%}
|
| 127 |
|
| 128 |
{%- if not state.effort_emitted -%}
|
|
|
|
| 66 |
{%- set header.text = header.text ~ message.name -%}
|
| 67 |
{%- endif -%}
|
| 68 |
{%- set rtok = header.text -%}
|
| 69 |
+
{%- set rendered -%}
|
| 70 |
|
| 71 |
{%- if message.role == "assistant" and message.reasoning_content is defined and message.reasoning_content -%}
|
| 72 |
{{- rtok ~ "<|content_thinking|>" ~ message.reasoning_content ~ "<|end_message|>" -}}
|
|
|
|
| 124 |
{%- if message.role == "assistant" -%}
|
| 125 |
{{- "<|content_model_end_sampling|>" -}}
|
| 126 |
{%- endif -%}
|
| 127 |
+
{%- endset -%}
|
| 128 |
+
{%- if message.role == "assistant" -%}
|
| 129 |
+
{%- generation -%}{{- rendered -}}{%- endgeneration -%}
|
| 130 |
+
{%- else -%}
|
| 131 |
+
{{- rendered -}}
|
| 132 |
+
{%- endif -%}
|
| 133 |
{%- endfor -%}
|
| 134 |
|
| 135 |
{%- if not state.effort_emitted -%}
|
config.json
CHANGED
|
@@ -40,6 +40,20 @@
|
|
| 40 |
],
|
| 41 |
"torch_dtype": "bfloat16"
|
| 42 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
"text_config": {
|
| 44 |
"attention_dropout": 0.0,
|
| 45 |
"attn_res_normalize_values": true,
|
|
@@ -106,7 +120,7 @@
|
|
| 106 |
"mlp_gate_softcap": 4.0,
|
| 107 |
"mlp_up_softcap": 25.0,
|
| 108 |
"model_type": "inkling2_text",
|
| 109 |
-
"moe_intermediate_size":
|
| 110 |
"n_layers_per_attn_res_block": 2,
|
| 111 |
"n_routed_experts": 8,
|
| 112 |
"n_shared_experts": 0,
|
|
|
|
| 40 |
],
|
| 41 |
"torch_dtype": "bfloat16"
|
| 42 |
},
|
| 43 |
+
"quantization_config": {
|
| 44 |
+
"activation_scheme": "dynamic",
|
| 45 |
+
"modules_to_not_convert": [
|
| 46 |
+
"model.llm.unembed",
|
| 47 |
+
"model.visual",
|
| 48 |
+
"model.llm.layers.*.attn.*"
|
| 49 |
+
],
|
| 50 |
+
"quant_method": "fp8",
|
| 51 |
+
"scale_fmt": "ue8m0",
|
| 52 |
+
"weight_block_size": [
|
| 53 |
+
1,
|
| 54 |
+
32
|
| 55 |
+
]
|
| 56 |
+
},
|
| 57 |
"text_config": {
|
| 58 |
"attention_dropout": 0.0,
|
| 59 |
"attn_res_normalize_values": true,
|
|
|
|
| 120 |
"mlp_gate_softcap": 4.0,
|
| 121 |
"mlp_up_softcap": 25.0,
|
| 122 |
"model_type": "inkling2_text",
|
| 123 |
+
"moe_intermediate_size": 32,
|
| 124 |
"n_layers_per_attn_res_block": 2,
|
| 125 |
"n_routed_experts": 8,
|
| 126 |
"n_shared_experts": 0,
|
generation_config.json
CHANGED
|
@@ -1,8 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"_from_model_config": true,
|
| 3 |
"eos_token_id": 200006,
|
| 4 |
-
"
|
| 5 |
-
"
|
| 6 |
-
"transformers_version": "5.23.0",
|
| 7 |
-
"use_cache": true
|
| 8 |
}
|
|
|
|
| 1 |
{
|
|
|
|
| 2 |
"eos_token_id": 200006,
|
| 3 |
+
"pad_token_id": 199999,
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+
"output_dtype": "float32",
|
| 7 |
+
"required_activation_quantization": null,
|
| 8 |
+
"tensors": [
|
| 9 |
+
"model.llm.attn_res.attn_queries.0",
|
| 10 |
+
"model.llm.attn_res.mlp_queries.0",
|
| 11 |
+
"model.llm.attn_res.mlp_queries.1",
|
| 12 |
+
"model.llm.attn_res.output_query",
|
| 13 |
+
"model.llm.layers.0.mlp.gate.bias",
|
| 14 |
+
"model.llm.layers.1.mlp.gate.bias"
|
| 15 |
+
],
|
| 16 |
+
"weight_block_shape": [],
|
| 17 |
+
"weight_transform": "cast"
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"compute_dtype": "bfloat16",
|
| 21 |
+
"output_dtype": "bfloat16",
|
| 22 |
+
"required_activation_quantization": null,
|
| 23 |
+
"tensors": [
|
| 24 |
+
"model.llm.embed.weight",
|
| 25 |
+
"model.llm.embed_norm.weight",
|
| 26 |
+
"model.llm.layers.0.attn.attn_sink_proj.weight",
|
| 27 |
+
"model.llm.layers.0.attn.gate_attn.weight",
|
| 28 |
+
"model.llm.layers.0.attn.k_sconv.weight",
|
| 29 |
+
"model.llm.layers.0.attn.q_l2_clip.scale",
|
| 30 |
+
"model.llm.layers.0.attn.rel_l2_clip.scale",
|
| 31 |
+
"model.llm.layers.0.attn.rel_logits_proj.proj",
|
| 32 |
+
"model.llm.layers.0.attn.v_sconv.weight",
|
| 33 |
+
"model.llm.layers.0.attn.wk_dv.weight",
|
| 34 |
+
"model.llm.layers.0.attn.wo_ud.weight",
|
| 35 |
+
"model.llm.layers.0.attn.wq_du.weight",
|
| 36 |
+
"model.llm.layers.0.attn.wr_du.weight",
|
| 37 |
+
"model.llm.layers.0.attn.wv_dv.weight",
|
| 38 |
+
"model.llm.layers.0.attn_norm.weight",
|
| 39 |
+
"model.llm.layers.0.attn_sconv.weight",
|
| 40 |
+
"model.llm.layers.0.mlp.gate.weight",
|
| 41 |
+
"model.llm.layers.0.mlp_norm.weight",
|
| 42 |
+
"model.llm.layers.0.mlp_sconv.weight",
|
| 43 |
+
"model.llm.layers.1.attn.attn_sink_proj.weight",
|
| 44 |
+
"model.llm.layers.1.attn.gate_attn.weight",
|
| 45 |
+
"model.llm.layers.1.attn.q_l2_clip.scale",
|
| 46 |
+
"model.llm.layers.1.attn.rel_l2_clip.scale",
|
| 47 |
+
"model.llm.layers.1.attn.rel_logits_proj.proj",
|
| 48 |
+
"model.llm.layers.1.attn.wk_dv.weight",
|
| 49 |
+
"model.llm.layers.1.attn.wo_ud.weight",
|
| 50 |
+
"model.llm.layers.1.attn.wq_du.weight",
|
| 51 |
+
"model.llm.layers.1.attn.wr_du.weight",
|
| 52 |
+
"model.llm.layers.1.attn.wv_dv.weight",
|
| 53 |
+
"model.llm.layers.1.attn_sconv.weight",
|
| 54 |
+
"model.llm.layers.1.mlp.gate.weight",
|
| 55 |
+
"model.llm.layers.1.mlp_norm.weight",
|
| 56 |
+
"model.llm.layers.1.mlp_sconv.weight",
|
| 57 |
+
"model.llm.norm.weight",
|
| 58 |
+
"model.visual.backbone.embeddings.class_embedding",
|
| 59 |
+
"model.visual.backbone.embeddings.cls_position_embedding",
|
| 60 |
+
"model.visual.backbone.embeddings.patch_embedding.weight",
|
| 61 |
+
"model.visual.backbone.embeddings.position_embedding",
|
| 62 |
+
"model.visual.backbone.layers.0.ln_1.bias",
|
| 63 |
+
"model.visual.backbone.layers.0.ln_1.weight",
|
| 64 |
+
"model.visual.backbone.layers.0.ln_2.bias",
|
| 65 |
+
"model.visual.backbone.layers.0.ln_2.weight",
|
| 66 |
+
"model.visual.backbone.layers.0.ls_1.gamma",
|
| 67 |
+
"model.visual.backbone.layers.0.ls_2.gamma",
|
| 68 |
+
"model.visual.backbone.layers.0.mlp.c_fc.bias",
|
| 69 |
+
"model.visual.backbone.layers.0.mlp.c_fc.weight",
|
| 70 |
+
"model.visual.backbone.layers.0.mlp.c_proj.bias",
|
| 71 |
+
"model.visual.backbone.layers.0.mlp.c_proj.weight",
|
| 72 |
+
"model.visual.backbone.layers.0.self_attn.k_proj.bias",
|
| 73 |
+
"model.visual.backbone.layers.0.self_attn.k_proj.weight",
|
| 74 |
+
"model.visual.backbone.layers.0.self_attn.out_proj.bias",
|
| 75 |
+
"model.visual.backbone.layers.0.self_attn.out_proj.weight",
|
| 76 |
+
"model.visual.backbone.layers.0.self_attn.q_proj.bias",
|
| 77 |
+
"model.visual.backbone.layers.0.self_attn.q_proj.weight",
|
| 78 |
+
"model.visual.backbone.layers.0.self_attn.v_proj.bias",
|
| 79 |
+
"model.visual.backbone.layers.0.self_attn.v_proj.weight",
|
| 80 |
+
"model.visual.backbone.layers.1.ln_1.bias",
|
| 81 |
+
"model.visual.backbone.layers.1.ln_1.weight",
|
| 82 |
+
"model.visual.backbone.layers.1.ln_2.bias",
|
| 83 |
+
"model.visual.backbone.layers.1.ln_2.weight",
|
| 84 |
+
"model.visual.backbone.layers.1.ls_1.gamma",
|
| 85 |
+
"model.visual.backbone.layers.1.ls_2.gamma",
|
| 86 |
+
"model.visual.backbone.layers.1.mlp.c_fc.bias",
|
| 87 |
+
"model.visual.backbone.layers.1.mlp.c_fc.weight",
|
| 88 |
+
"model.visual.backbone.layers.1.mlp.c_proj.bias",
|
| 89 |
+
"model.visual.backbone.layers.1.mlp.c_proj.weight",
|
| 90 |
+
"model.visual.backbone.layers.1.self_attn.k_proj.bias",
|
| 91 |
+
"model.visual.backbone.layers.1.self_attn.k_proj.weight",
|
| 92 |
+
"model.visual.backbone.layers.1.self_attn.out_proj.bias",
|
| 93 |
+
"model.visual.backbone.layers.1.self_attn.out_proj.weight",
|
| 94 |
+
"model.visual.backbone.layers.1.self_attn.q_proj.bias",
|
| 95 |
+
"model.visual.backbone.layers.1.self_attn.q_proj.weight",
|
| 96 |
+
"model.visual.backbone.layers.1.self_attn.v_proj.bias",
|
| 97 |
+
"model.visual.backbone.layers.1.self_attn.v_proj.weight",
|
| 98 |
+
"model.visual.backbone.ln_pre.bias",
|
| 99 |
+
"model.visual.backbone.ln_pre.weight",
|
| 100 |
+
"model.visual.proj_in.weight",
|
| 101 |
+
"model.visual.proj_out.weight"
|
| 102 |
+
],
|
| 103 |
+
"weight_block_shape": [],
|
| 104 |
+
"weight_transform": "cast"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"compute_dtype": "mxfp8",
|
| 108 |
+
"output_dtype": "float8_e4m3fn",
|
| 109 |
+
"required_activation_quantization": {
|
| 110 |
+
"block_size": 32,
|
| 111 |
+
"format": "mxfp8_e4m3",
|
| 112 |
+
"rounding": "nearest",
|
| 113 |
+
"scale_dtype": "ue8m0"
|
| 114 |
+
},
|
| 115 |
+
"tensors": [
|
| 116 |
+
"model.llm.layers.0.mlp.experts.w13_weight",
|
| 117 |
+
"model.llm.layers.0.mlp.experts.w2_weight",
|
| 118 |
+
"model.llm.layers.1.mlp.experts.w13_weight",
|
| 119 |
+
"model.llm.layers.1.mlp.experts.w2_weight"
|
| 120 |
+
],
|
| 121 |
+
"weight_block_shape": [
|
| 122 |
+
32,
|
| 123 |
+
32
|
| 124 |
+
],
|
| 125 |
+
"weight_transform": "mxfp8_nearest"
|
| 126 |
+
},
|
| 127 |
+
{
|
| 128 |
+
"compute_dtype": "bfloat16",
|
| 129 |
+
"fwd_output_dtype": "float32",
|
| 130 |
+
"output_dtype": "bfloat16",
|
| 131 |
+
"required_activation_quantization": null,
|
| 132 |
+
"tensors": [
|
| 133 |
+
"model.llm.unembed.weight"
|
| 134 |
+
],
|
| 135 |
+
"weight_block_shape": [],
|
| 136 |
+
"weight_transform": "cast"
|
| 137 |
+
}
|
| 138 |
+
]
|
| 139 |
+
},
|
| 140 |
+
"quant_method": "inkling2"
|
| 141 |
+
}
|
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:11363fe85d5df2a3b543e946d37c4d24982d345dd5c7ed4fdfc2f5b2346ecf30
|
| 3 |
+
size 27063136
|