Instructions to use Maxtimer97/LlamaBase2Hymba_raw with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Maxtimer97/LlamaBase2Hymba_raw with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Maxtimer97/LlamaBase2Hymba_raw", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Maxtimer97/LlamaBase2Hymba_raw", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Maxtimer97/LlamaBase2Hymba_raw with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Maxtimer97/LlamaBase2Hymba_raw" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Maxtimer97/LlamaBase2Hymba_raw", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Maxtimer97/LlamaBase2Hymba_raw
- SGLang
How to use Maxtimer97/LlamaBase2Hymba_raw 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 "Maxtimer97/LlamaBase2Hymba_raw" \ --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": "Maxtimer97/LlamaBase2Hymba_raw", "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 "Maxtimer97/LlamaBase2Hymba_raw" \ --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": "Maxtimer97/LlamaBase2Hymba_raw", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Maxtimer97/LlamaBase2Hymba_raw with Docker Model Runner:
docker model run hf.co/Maxtimer97/LlamaBase2Hymba_raw
File size: 4,521 Bytes
0aeaccb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | import math
from transformers.configuration_utils import PretrainedConfig
class HymbaConfig(PretrainedConfig):
model_type = "hymba"
keys_to_ignore_at_inference = ["past_key_values"]
def __init__(
self,
vocab_size=65536,
tie_word_embeddings=False,
hidden_size=4096,
intermediate_size=14336,
num_hidden_layers=32,
num_attention_heads=32,
num_key_value_heads=8,
hidden_act="silu",
initializer_range=0.02,
rms_norm_eps=1e-6,
attn_only_wo_proj=False,
use_cache=True,
calc_logits_for_entire_prompt=False,
output_router_logits=False,
router_aux_loss_coef=0.001,
pad_token_id=0,
bos_token_id=1,
eos_token_id=2,
sliding_window=None,
max_position_embeddings=262144,
orig_max_position_embeddings=None,
attention_dropout=0.0,
num_experts_per_tok=2,
num_experts=16,
use_mamba_kernels=True,
mamba_d_state=16,
mamba_d_conv=4,
mamba_expand=2,
mamba_dt_rank="auto",
mamba_conv_bias=True,
mamba_proj_bias=False,
mamba_inner_layernorms=True,
kv_reuse_every_i_layer=-1,
kv_reuse_group=None,
kv_weight_reuse=False,
global_attn_idx=None,
num_mamba=1,
pure_attn=False,
repeat_x_before_conv=True,
attn_implementation_new='sdpa',
rope_type=None,
attn_factor=0.5,
**kwargs,
):
self.vocab_size = vocab_size
self.tie_word_embeddings = tie_word_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.sliding_window = sliding_window
self.max_position_embeddings = max_position_embeddings
self.orig_max_position_embeddings = orig_max_position_embeddings
self.attention_dropout = attention_dropout
self.attn_only_wo_proj = attn_only_wo_proj
if num_key_value_heads is None:
num_key_value_heads = num_attention_heads
self.num_key_value_heads = num_key_value_heads
self.hidden_act = hidden_act
self.initializer_range = initializer_range
self.rms_norm_eps = rms_norm_eps
self.use_cache = use_cache
self.calc_logits_for_entire_prompt = calc_logits_for_entire_prompt
self.output_router_logits = output_router_logits
self.router_aux_loss_coef = router_aux_loss_coef
self.num_experts_per_tok = num_experts_per_tok
self.num_experts = num_experts
self.use_mamba_kernels = use_mamba_kernels
self.mamba_d_state = mamba_d_state
self.mamba_d_conv = mamba_d_conv
self.mamba_expand = mamba_expand
self.mamba_dt_rank = math.ceil(self.hidden_size / 16) if mamba_dt_rank == "auto" else mamba_dt_rank
self.mamba_conv_bias = mamba_conv_bias
self.mamba_proj_bias = mamba_proj_bias
self.mamba_inner_layernorms = mamba_inner_layernorms
self.attn_hidden_size = kwargs.pop("attn_hidden_size", -1)
self.attn_factor = attn_factor
self.kq_head_dim = kwargs.pop("kq_head_dim", -1)
self.v_head_dim = kwargs.pop("v_head_dim", -1)
self.kq_norm = kwargs.pop("kq_norm", None)
self.rope = kwargs.pop("rope", False)
self.rope_theta = kwargs.pop("rope_theta", 10000.0)
self.num_memory_tokens = kwargs.pop("num_memory_tokens", 0)
self.memory_tokens_interspersed_every = kwargs.pop("memory_tokens_interspersed_every", 0)
self.kv_reuse_every_i_layer = kv_reuse_every_i_layer
self.kv_reuse_group = kv_reuse_group
self.kv_weight_reuse = kv_weight_reuse
self.global_attn_idx = global_attn_idx
self.num_mamba = num_mamba
self.attn_implementation_new = attn_implementation_new
self.rope_type = rope_type
self.pure_attn = pure_attn
self.repeat_x_before_conv = repeat_x_before_conv
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,
)
|