Instructions to use OptGear/Opt.Gear-1B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OptGear/Opt.Gear-1B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OptGear/Opt.Gear-1B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("OptGear/Opt.Gear-1B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OptGear/Opt.Gear-1B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OptGear/Opt.Gear-1B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OptGear/Opt.Gear-1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OptGear/Opt.Gear-1B
- SGLang
How to use OptGear/Opt.Gear-1B 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 "OptGear/Opt.Gear-1B" \ --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": "OptGear/Opt.Gear-1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "OptGear/Opt.Gear-1B" \ --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": "OptGear/Opt.Gear-1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use OptGear/Opt.Gear-1B with Docker Model Runner:
docker model run hf.co/OptGear/Opt.Gear-1B
| # coding=utf-8 | |
| # Copyright 2025 OptAI Inc. HuggingFace Inc. team. All rights reserved. | |
| # | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| from transformers.configuration_utils import PretrainedConfig, layer_type_validation | |
| from transformers.modeling_rope_utils import rope_config_validation | |
| from transformers.utils import logging | |
| class GearConfig(PretrainedConfig): | |
| model_type = "gear" | |
| keys_to_ignore_at_inference = ["past_key_values"] | |
| base_model_tp_plan = { | |
| "layers.*.self_attn.q_proj": "colwise", | |
| "layers.*.self_attn.k_proj": "colwise", | |
| "layers.*.self_attn.v_proj": "colwise", | |
| "layers.*.self_attn.o_proj": "rowwise", | |
| "layers.*.mlp.gate_proj": "colwise", | |
| "layers.*.mlp.up_proj": "colwise", | |
| "layers.*.mlp.down_proj": "rowwise", | |
| } | |
| base_model_pp_plan = { | |
| "embed_tokens": (["input_ids"], ["inputs_embeds"]), | |
| "layers": (["hidden_states", "attention_mask"], ["hidden_states"]), | |
| "norm": (["hidden_states"], ["hidden_states"]), | |
| } | |
| def __init__( | |
| self, | |
| vocab_size=125_184, | |
| hidden_size=1152, | |
| intermediate_size=6912, | |
| num_hidden_layers=26, | |
| num_attention_heads=4, | |
| num_key_value_heads=1, | |
| head_dim=256, | |
| hidden_activation="gelu_pytorch_tanh", | |
| max_position_embeddings=131_072, | |
| initializer_range=0.02, | |
| rms_norm_eps=1e-6, | |
| use_cache=True, | |
| pad_token_id=125032, | |
| eos_token_id=125031, | |
| bos_token_id=125030, | |
| tie_word_embeddings=True, | |
| rope_theta=1_000_000.0, | |
| attention_bias=False, | |
| attention_dropout=0.0, | |
| query_pre_attn_scalar=256, | |
| sliding_window=512, | |
| layer_types=None, | |
| final_logit_softcapping=None, | |
| attn_logit_softcapping=None, | |
| rope_scaling=None, | |
| rope_local_base_freq=10_000.0, | |
| use_bidirectional_attention=False, | |
| conv_L_cache=3, | |
| **kwargs, | |
| ): | |
| super().__init__( | |
| pad_token_id=pad_token_id, | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| tie_word_embeddings=tie_word_embeddings, | |
| **kwargs, | |
| ) | |
| self.vocab_size = vocab_size | |
| self.max_position_embeddings = max_position_embeddings | |
| self.hidden_size = hidden_size | |
| self.intermediate_size = intermediate_size | |
| self.num_hidden_layers = num_hidden_layers | |
| self.num_attention_heads = num_attention_heads | |
| self.head_dim = head_dim | |
| self.num_key_value_heads = num_key_value_heads | |
| self.initializer_range = initializer_range | |
| self.rms_norm_eps = rms_norm_eps | |
| self.use_cache = use_cache | |
| self.rope_theta = rope_theta | |
| self.attention_bias = attention_bias | |
| self.attention_dropout = attention_dropout | |
| self.hidden_activation = hidden_activation | |
| self.query_pre_attn_scalar = query_pre_attn_scalar | |
| self.sliding_window = sliding_window | |
| self.final_logit_softcapping = final_logit_softcapping | |
| self.attn_logit_softcapping = attn_logit_softcapping | |
| self.layer_types = layer_types | |
| self.use_bidirectional_attention = use_bidirectional_attention | |
| if use_bidirectional_attention: | |
| self.sliding_window = (self.sliding_window // 2) + 1 # due to fa we set exclusive bounds | |
| self.rope_local_base_freq = rope_local_base_freq | |
| self.rope_scaling = rope_scaling | |
| rope_config_validation(self) | |
| # BC -> the pattern used to be a simple int, and it's still present in configs on the Hub | |
| self._sliding_window_pattern = kwargs.get("sliding_window_pattern", 6) | |
| self.conv_L_cache = conv_L_cache | |
| __all__ = ["GearConfig"] |