Text Generation
Transformers
Safetensors
code
ivme_coder
language-model
transformer
rope
swiglu
muon
from-scratch
tiny
small
decoder-only
python
custom_code
Instructions to use IvmeLabs/Ivme-Coder-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use IvmeLabs/Ivme-Coder-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="IvmeLabs/Ivme-Coder-v1", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("IvmeLabs/Ivme-Coder-v1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use IvmeLabs/Ivme-Coder-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "IvmeLabs/Ivme-Coder-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "IvmeLabs/Ivme-Coder-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/IvmeLabs/Ivme-Coder-v1
- SGLang
How to use IvmeLabs/Ivme-Coder-v1 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 "IvmeLabs/Ivme-Coder-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "IvmeLabs/Ivme-Coder-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "IvmeLabs/Ivme-Coder-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "IvmeLabs/Ivme-Coder-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use IvmeLabs/Ivme-Coder-v1 with Docker Model Runner:
docker model run hf.co/IvmeLabs/Ivme-Coder-v1
Upload Ivme-Coder-v1 (Otter 1): safetensors + custom modeling code
Browse files- model/model.py +17 -5
- modeling_ivme_coder.py +17 -5
model/model.py
CHANGED
|
@@ -148,10 +148,17 @@ class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 148 |
self.head = nn.Linear(config.d_model, config.vocab_size, bias=False)
|
| 149 |
self.head.weight = self.tok_emb.weight # tied embeddings
|
| 150 |
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
self.post_init()
|
| 157 |
|
|
@@ -179,9 +186,14 @@ class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 179 |
# generate()'s kwarg validation, but intentionally unused: this model only
|
| 180 |
# supports left-padding for batched generation (see model card), and single-
|
| 181 |
# sequence causal generation (the common case) needs no mask at all.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
x = self.tok_emb(input_ids)
|
| 183 |
for block in self.blocks:
|
| 184 |
-
x = block(x,
|
| 185 |
x = self.ln_f(x)
|
| 186 |
logits = self.head(x)
|
| 187 |
loss = None
|
|
|
|
| 148 |
self.head = nn.Linear(config.d_model, config.vocab_size, bias=False)
|
| 149 |
self.head.weight = self.tok_emb.weight # tied embeddings
|
| 150 |
|
| 151 |
+
# NOTE: RoPE cos/sin tables are intentionally NOT stored as a persistent=False
|
| 152 |
+
# buffer here. transformers v5's from_pretrained() has a known bug where
|
| 153 |
+
# persistent=False buffers get overwritten with uninitialized/garbage memory
|
| 154 |
+
# after loading (https://github.com/huggingface/transformers/issues/44534),
|
| 155 |
+
# even though they're computed correctly at __init__ time. That garbage then
|
| 156 |
+
# silently produces huge (but finite) values through the RoPE rotation, which
|
| 157 |
+
# overflow to NaN inside scaled_dot_product_attention. Recomputing the tables
|
| 158 |
+
# fresh on every forward() call sidesteps this entirely - it's cheap (a cos/sin
|
| 159 |
+
# over d_head/2 * context_len elements) relative to the rest of the forward pass.
|
| 160 |
+
self.d_head = config.d_model // config.n_head
|
| 161 |
+
self.rope_theta = config.rope_theta
|
| 162 |
|
| 163 |
self.post_init()
|
| 164 |
|
|
|
|
| 186 |
# generate()'s kwarg validation, but intentionally unused: this model only
|
| 187 |
# supports left-padding for batched generation (see model card), and single-
|
| 188 |
# sequence causal generation (the common case) needs no mask at all.
|
| 189 |
+
# Recompute RoPE tables fresh each call - see note in __init__ for why this
|
| 190 |
+
# isn't cached in a buffer.
|
| 191 |
+
rope_cos, rope_sin = precompute_rope(
|
| 192 |
+
self.d_head, self.context_len, theta=self.rope_theta, device=input_ids.device
|
| 193 |
+
)
|
| 194 |
x = self.tok_emb(input_ids)
|
| 195 |
for block in self.blocks:
|
| 196 |
+
x = block(x, rope_cos, rope_sin)
|
| 197 |
x = self.ln_f(x)
|
| 198 |
logits = self.head(x)
|
| 199 |
loss = None
|
modeling_ivme_coder.py
CHANGED
|
@@ -148,10 +148,17 @@ class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 148 |
self.head = nn.Linear(config.d_model, config.vocab_size, bias=False)
|
| 149 |
self.head.weight = self.tok_emb.weight # tied embeddings
|
| 150 |
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
self.post_init()
|
| 157 |
|
|
@@ -179,9 +186,14 @@ class IvmeCoderV1ForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 179 |
# generate()'s kwarg validation, but intentionally unused: this model only
|
| 180 |
# supports left-padding for batched generation (see model card), and single-
|
| 181 |
# sequence causal generation (the common case) needs no mask at all.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
x = self.tok_emb(input_ids)
|
| 183 |
for block in self.blocks:
|
| 184 |
-
x = block(x,
|
| 185 |
x = self.ln_f(x)
|
| 186 |
logits = self.head(x)
|
| 187 |
loss = None
|
|
|
|
| 148 |
self.head = nn.Linear(config.d_model, config.vocab_size, bias=False)
|
| 149 |
self.head.weight = self.tok_emb.weight # tied embeddings
|
| 150 |
|
| 151 |
+
# NOTE: RoPE cos/sin tables are intentionally NOT stored as a persistent=False
|
| 152 |
+
# buffer here. transformers v5's from_pretrained() has a known bug where
|
| 153 |
+
# persistent=False buffers get overwritten with uninitialized/garbage memory
|
| 154 |
+
# after loading (https://github.com/huggingface/transformers/issues/44534),
|
| 155 |
+
# even though they're computed correctly at __init__ time. That garbage then
|
| 156 |
+
# silently produces huge (but finite) values through the RoPE rotation, which
|
| 157 |
+
# overflow to NaN inside scaled_dot_product_attention. Recomputing the tables
|
| 158 |
+
# fresh on every forward() call sidesteps this entirely - it's cheap (a cos/sin
|
| 159 |
+
# over d_head/2 * context_len elements) relative to the rest of the forward pass.
|
| 160 |
+
self.d_head = config.d_model // config.n_head
|
| 161 |
+
self.rope_theta = config.rope_theta
|
| 162 |
|
| 163 |
self.post_init()
|
| 164 |
|
|
|
|
| 186 |
# generate()'s kwarg validation, but intentionally unused: this model only
|
| 187 |
# supports left-padding for batched generation (see model card), and single-
|
| 188 |
# sequence causal generation (the common case) needs no mask at all.
|
| 189 |
+
# Recompute RoPE tables fresh each call - see note in __init__ for why this
|
| 190 |
+
# isn't cached in a buffer.
|
| 191 |
+
rope_cos, rope_sin = precompute_rope(
|
| 192 |
+
self.d_head, self.context_len, theta=self.rope_theta, device=input_ids.device
|
| 193 |
+
)
|
| 194 |
x = self.tok_emb(input_ids)
|
| 195 |
for block in self.blocks:
|
| 196 |
+
x = block(x, rope_cos, rope_sin)
|
| 197 |
x = self.ln_f(x)
|
| 198 |
logits = self.head(x)
|
| 199 |
loss = None
|