Image-Text-to-Text
Transformers
Safetensors
step3p7
text-generation
stepfun
step-3.7
flash
heretic
uncensored
decensored
abliterated
bf16
autoround-ready
awq-ready
exl3-ready
gguf-ready
nvfp4-ready
conversational
custom_code
Instructions to use ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16", trust_remote_code=True) 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)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16", "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/ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16
- SGLang
How to use ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16 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 "ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16" \ --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": "ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16", "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 "ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16" \ --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": "ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16", "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 ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16 with Docker Model Runner:
docker model run hf.co/ibrahimkettaneh/Step-3.7-Flash-uncensored-abliterated-heretic-BF16
Upload configuration_step3p7.py with huggingface_hub
Browse files- configuration_step3p7.py +207 -0
configuration_step3p7.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any, Optional, Sequence, Union
|
| 2 |
+
|
| 3 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 4 |
+
|
| 5 |
+
class StepRoboticsVisionEncoderConfig(PretrainedConfig):
|
| 6 |
+
model_type = "perception_encoder"
|
| 7 |
+
|
| 8 |
+
def __init__(
|
| 9 |
+
self,
|
| 10 |
+
width=1536,
|
| 11 |
+
layers=47,
|
| 12 |
+
heads=16,
|
| 13 |
+
num_channels=3,
|
| 14 |
+
image_size=728,
|
| 15 |
+
mlp_ratio = 8960/1536,
|
| 16 |
+
patch_size=14,
|
| 17 |
+
hidden_act="quick_gelu",
|
| 18 |
+
layer_norm_eps=1e-5,
|
| 19 |
+
ues_cls_token=False,
|
| 20 |
+
use_cls_token: Optional[bool] = None,
|
| 21 |
+
use_ln_pre=True,
|
| 22 |
+
use_ln_post=False,
|
| 23 |
+
use_abs_posemb=True,
|
| 24 |
+
use_rope2d=True,
|
| 25 |
+
ls_init_value=0.1,
|
| 26 |
+
**kwargs,
|
| 27 |
+
):
|
| 28 |
+
self.width = width
|
| 29 |
+
self.layers = layers
|
| 30 |
+
self.heads = heads
|
| 31 |
+
self.num_channels = num_channels
|
| 32 |
+
self.patch_size = patch_size
|
| 33 |
+
self.image_size = image_size
|
| 34 |
+
self.mlp_ratio = mlp_ratio
|
| 35 |
+
self.layer_norm_eps = layer_norm_eps
|
| 36 |
+
self.hidden_act = hidden_act
|
| 37 |
+
if use_cls_token is None:
|
| 38 |
+
use_cls_token = ues_cls_token
|
| 39 |
+
self.ues_cls_token = use_cls_token
|
| 40 |
+
self.use_cls_token = use_cls_token
|
| 41 |
+
self.use_ln_pre = use_ln_pre
|
| 42 |
+
self.ls_init_value = ls_init_value
|
| 43 |
+
self.use_ln_post = use_ln_post
|
| 44 |
+
self.use_abs_posemb = use_abs_posemb
|
| 45 |
+
self.use_rope2d = use_rope2d
|
| 46 |
+
super().__init__(**kwargs)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class Step3p7TextConfig(PretrainedConfig):
|
| 50 |
+
model_type = "step3p5"
|
| 51 |
+
architectures = ["Step3p5ForCausalLM"]
|
| 52 |
+
|
| 53 |
+
def __init__(
|
| 54 |
+
self,
|
| 55 |
+
hidden_size: int = 4096,
|
| 56 |
+
intermediate_size: int = 11264,
|
| 57 |
+
num_attention_heads: int = 64,
|
| 58 |
+
num_attention_groups: int = 8,
|
| 59 |
+
num_hidden_layers: int = 45,
|
| 60 |
+
max_seq_len: int = 128000,
|
| 61 |
+
vocab_size: int = 128815,
|
| 62 |
+
rms_norm_eps: float = 1e-5,
|
| 63 |
+
moe_intermediate_size: int = 1280,
|
| 64 |
+
moe_num_experts: int = 288,
|
| 65 |
+
moe_top_k: int = 8,
|
| 66 |
+
rope_theta: float = 10000,
|
| 67 |
+
rope_scaling: Optional[dict[str, Any]] = None,
|
| 68 |
+
max_position_embeddings: int = 128000,
|
| 69 |
+
share_expert_dims: int = 1280,
|
| 70 |
+
share_expert_dim: Optional[int] = None,
|
| 71 |
+
head_dim: int = 128,
|
| 72 |
+
norm_expert_weight: bool = True,
|
| 73 |
+
layer_types: list[str] = None,
|
| 74 |
+
sliding_window: Optional[int] = None,
|
| 75 |
+
pad_token_id: int = 1,
|
| 76 |
+
attention_dropout: float = 0.0,
|
| 77 |
+
use_head_wise_attn_gate: bool = False,
|
| 78 |
+
use_moe_router_bias: bool = False,
|
| 79 |
+
moe_router_activation: str = "softmax",
|
| 80 |
+
moe_router_scaling_factor: float = 1.0,
|
| 81 |
+
need_fp32_gate: bool = False,
|
| 82 |
+
attention_other_setting: Optional[dict[str, Any]] = None,
|
| 83 |
+
swiglu_limits: Optional[list[Optional[float]]] = None,
|
| 84 |
+
swiglu_limits_shared: Optional[list[Optional[float]]] = None,
|
| 85 |
+
use_rope_layers: Optional[list[bool]] = None,
|
| 86 |
+
yarn_only_types: Optional[list[str]] = None,
|
| 87 |
+
moe_layers_enum: tuple[int] = (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
| 88 |
+
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
| 89 |
+
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
|
| 90 |
+
35, 36, 37, 38, 39, 40, 41, 42, 43, 44),
|
| 91 |
+
**kwargs,
|
| 92 |
+
) -> None:
|
| 93 |
+
torch_dtype = kwargs.get("torch_dtype")
|
| 94 |
+
trim_layer_types = _normalize_per_layer_values(layer_types,
|
| 95 |
+
num_hidden_layers)
|
| 96 |
+
if isinstance(rope_scaling, dict):
|
| 97 |
+
rope_scaling = dict(rope_scaling)
|
| 98 |
+
if share_expert_dim is None:
|
| 99 |
+
share_expert_dim = share_expert_dims
|
| 100 |
+
self.hidden_size = hidden_size
|
| 101 |
+
self.intermediate_size = intermediate_size
|
| 102 |
+
self.num_attention_heads = num_attention_heads
|
| 103 |
+
self.num_attention_groups = num_attention_groups
|
| 104 |
+
self.num_hidden_layers = num_hidden_layers
|
| 105 |
+
self.max_seq_len = max_seq_len
|
| 106 |
+
self.vocab_size = vocab_size
|
| 107 |
+
self.rms_norm_eps = rms_norm_eps
|
| 108 |
+
self.moe_intermediate_size = moe_intermediate_size
|
| 109 |
+
self.moe_num_experts = moe_num_experts
|
| 110 |
+
self.moe_top_k = moe_top_k
|
| 111 |
+
self.rope_theta = rope_theta
|
| 112 |
+
self.rope_scaling = rope_scaling
|
| 113 |
+
self.max_position_embeddings = max_position_embeddings
|
| 114 |
+
self.share_expert_dim = share_expert_dim
|
| 115 |
+
self.head_dim = head_dim
|
| 116 |
+
self.norm_expert_weight = norm_expert_weight
|
| 117 |
+
self.moe_layers_enum = moe_layers_enum
|
| 118 |
+
self.layer_types = trim_layer_types
|
| 119 |
+
self.sliding_window = sliding_window
|
| 120 |
+
self.pad_token_id = pad_token_id
|
| 121 |
+
self.attention_dropout = attention_dropout
|
| 122 |
+
self.use_head_wise_attn_gate = use_head_wise_attn_gate
|
| 123 |
+
self.use_moe_router_bias = use_moe_router_bias
|
| 124 |
+
self.moe_router_activation = moe_router_activation
|
| 125 |
+
self.moe_router_scaling_factor = moe_router_scaling_factor
|
| 126 |
+
self.need_fp32_gate = need_fp32_gate
|
| 127 |
+
self.attention_other_setting = attention_other_setting
|
| 128 |
+
self.swiglu_limits = swiglu_limits
|
| 129 |
+
self.swiglu_limits_shared = swiglu_limits_shared
|
| 130 |
+
self.use_rope_layers = use_rope_layers
|
| 131 |
+
self.yarn_only_types = yarn_only_types
|
| 132 |
+
super().__init__(**kwargs)
|
| 133 |
+
if torch_dtype is not None:
|
| 134 |
+
self.torch_dtype = torch_dtype
|
| 135 |
+
self.layer_types = layer_types
|
| 136 |
+
|
| 137 |
+
def to_dict(self):
|
| 138 |
+
output = super().to_dict()
|
| 139 |
+
torch_dtype = getattr(self, "torch_dtype", None)
|
| 140 |
+
if torch_dtype is not None:
|
| 141 |
+
output["torch_dtype"] = torch_dtype
|
| 142 |
+
return output
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def _normalize_per_layer_values(
|
| 146 |
+
values: Optional[Sequence[Any]],
|
| 147 |
+
num_hidden_layers: int,
|
| 148 |
+
) -> Optional[list[Any]]:
|
| 149 |
+
if values is None:
|
| 150 |
+
return None
|
| 151 |
+
normalized = list(values)
|
| 152 |
+
if not normalized:
|
| 153 |
+
return normalized
|
| 154 |
+
if len(normalized) < num_hidden_layers:
|
| 155 |
+
normalized.extend([normalized[-1]] *
|
| 156 |
+
(num_hidden_layers - len(normalized)))
|
| 157 |
+
# Some checkpoints keep MTP/spec layer entries after the decoder layers.
|
| 158 |
+
# This config only builds num_hidden_layers decoder layers, and HF strict
|
| 159 |
+
# validation requires per-layer fields to match that decoder count.
|
| 160 |
+
return normalized[:num_hidden_layers]
|
| 161 |
+
|
| 162 |
+
class Step3p7Config(PretrainedConfig):
|
| 163 |
+
# This loader is a compatibility shim for original Step VL checkpoints
|
| 164 |
+
# whose top-level config model_type is `step3p7`.
|
| 165 |
+
model_type = "step3p7"
|
| 166 |
+
|
| 167 |
+
def __init__(
|
| 168 |
+
self,
|
| 169 |
+
vision_config: Optional[Union[dict, StepRoboticsVisionEncoderConfig]] = None,
|
| 170 |
+
text_config: Optional[Union[dict, Step3p7TextConfig]] = None,
|
| 171 |
+
understand_projector_stride: int = 2,
|
| 172 |
+
projector_bias: bool = False,
|
| 173 |
+
image_token_id: int = 151679,
|
| 174 |
+
**kwargs,
|
| 175 |
+
) -> None:
|
| 176 |
+
shared_rope_scaling = kwargs.get("rope_scaling")
|
| 177 |
+
if isinstance(shared_rope_scaling, dict):
|
| 178 |
+
shared_rope_scaling = dict(shared_rope_scaling)
|
| 179 |
+
|
| 180 |
+
if vision_config is None:
|
| 181 |
+
vision_config = StepRoboticsVisionEncoderConfig()
|
| 182 |
+
elif isinstance(vision_config, dict):
|
| 183 |
+
vision_config = StepRoboticsVisionEncoderConfig(**vision_config)
|
| 184 |
+
self.vision_config = vision_config
|
| 185 |
+
|
| 186 |
+
if text_config is None:
|
| 187 |
+
text_config = Step3p7TextConfig(rope_scaling=shared_rope_scaling)
|
| 188 |
+
elif isinstance(text_config, dict):
|
| 189 |
+
text_config = dict(text_config)
|
| 190 |
+
if shared_rope_scaling is not None and "rope_scaling" not in text_config:
|
| 191 |
+
text_config["rope_scaling"] = shared_rope_scaling
|
| 192 |
+
text_config = Step3p7TextConfig(**text_config)
|
| 193 |
+
elif shared_rope_scaling is not None and text_config.rope_scaling is None:
|
| 194 |
+
text_config.rope_scaling = dict(shared_rope_scaling)
|
| 195 |
+
self.text_config = text_config
|
| 196 |
+
|
| 197 |
+
rope_scaling = kwargs.get("rope_scaling")
|
| 198 |
+
if isinstance(rope_scaling, dict):
|
| 199 |
+
kwargs["rope_scaling"] = dict(rope_scaling)
|
| 200 |
+
|
| 201 |
+
self.understand_projector_stride = understand_projector_stride
|
| 202 |
+
self.projector_bias = projector_bias
|
| 203 |
+
self.hidden_size = text_config.hidden_size
|
| 204 |
+
self.max_position_embeddings = text_config.max_position_embeddings
|
| 205 |
+
self.image_token_id = image_token_id
|
| 206 |
+
# Help Auto classes find the correct implementation when saving/loading.
|
| 207 |
+
super().__init__(**kwargs)
|