Text Generation
Transformers
Safetensors
English
ivme_conversate
ivme
language-model
transformer
rope
swiglu
muon
from-scratch
tiny
small
decoder-only
custom_code
Instructions to use IvmeLabs/Ivme-Conversate-v3-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use IvmeLabs/Ivme-Conversate-v3-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="IvmeLabs/Ivme-Conversate-v3-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("IvmeLabs/Ivme-Conversate-v3-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use IvmeLabs/Ivme-Conversate-v3-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "IvmeLabs/Ivme-Conversate-v3-Base" # 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-Conversate-v3-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/IvmeLabs/Ivme-Conversate-v3-Base
- SGLang
How to use IvmeLabs/Ivme-Conversate-v3-Base 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-Conversate-v3-Base" \ --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-Conversate-v3-Base", "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-Conversate-v3-Base" \ --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-Conversate-v3-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use IvmeLabs/Ivme-Conversate-v3-Base with Docker Model Runner:
docker model run hf.co/IvmeLabs/Ivme-Conversate-v3-Base
Upload modeling_ivme_conversate.py with huggingface_hub
Browse files- modeling_ivme_conversate.py +23 -0
modeling_ivme_conversate.py
CHANGED
|
@@ -180,6 +180,17 @@ class IvmeConversateModel(PreTrainedModel):
|
|
| 180 |
nn.init.normal_(module.weight, mean=0.0, std=0.02)
|
| 181 |
|
| 182 |
def forward(self, input_ids, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
x = self.tok_embed(input_ids)
|
| 184 |
cos, sin = precompute_rope(self._head_dim, self._context_len,
|
| 185 |
theta=self._rope_theta, device=x.device)
|
|
@@ -231,6 +242,18 @@ class IvmeConversateForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 231 |
# attention_mask accepted for interface compatibility but not
|
| 232 |
# used - this model is trained/used causal-only with no padding
|
| 233 |
# within a sequence (see ShardedTokenDataset / infer scripts).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
hidden = self.model(input_ids)
|
| 235 |
logits = self.lm_head(hidden)
|
| 236 |
|
|
|
|
| 180 |
nn.init.normal_(module.weight, mean=0.0, std=0.02)
|
| 181 |
|
| 182 |
def forward(self, input_ids, **kwargs):
|
| 183 |
+
# Defensive truncation: keep only the most recent context_len
|
| 184 |
+
# tokens. This is a second safety layer beyond exposing
|
| 185 |
+
# max_position_embeddings in the config (see
|
| 186 |
+
# IvmeConversateConfig) - if any caller still manages to pass a
|
| 187 |
+
# longer sequence, truncate cleanly to the trailing window
|
| 188 |
+
# rather than crash inside RoPE with a cryptic tensor-shape
|
| 189 |
+
# mismatch (confirmed reproducible: a 2048-token input against
|
| 190 |
+
# this model's 1024 context previously crashed deep inside
|
| 191 |
+
# apply_rope with no indication of the real cause).
|
| 192 |
+
if input_ids.shape[1] > self._context_len:
|
| 193 |
+
input_ids = input_ids[:, -self._context_len:]
|
| 194 |
x = self.tok_embed(input_ids)
|
| 195 |
cos, sin = precompute_rope(self._head_dim, self._context_len,
|
| 196 |
theta=self._rope_theta, device=x.device)
|
|
|
|
| 242 |
# attention_mask accepted for interface compatibility but not
|
| 243 |
# used - this model is trained/used causal-only with no padding
|
| 244 |
# within a sequence (see ShardedTokenDataset / infer scripts).
|
| 245 |
+
#
|
| 246 |
+
# If input_ids exceeds context_len, self.model() truncates it
|
| 247 |
+
# internally (see IvmeConversateModel.forward). labels must be
|
| 248 |
+
# truncated identically here, BEFORE the loss is computed -
|
| 249 |
+
# otherwise a caller passing both an over-length input_ids and
|
| 250 |
+
# matching labels (e.g. a perplexity/loglikelihood task) would
|
| 251 |
+
# hit a shape mismatch between logits and labels, or worse, a
|
| 252 |
+
# silent misalignment if the shapes happened to coincide.
|
| 253 |
+
context_len = self.config.max_position_embeddings
|
| 254 |
+
if input_ids.shape[1] > context_len and labels is not None:
|
| 255 |
+
labels = labels[:, -context_len:]
|
| 256 |
+
|
| 257 |
hidden = self.model(input_ids)
|
| 258 |
logits = self.lm_head(hidden)
|
| 259 |
|