Text Generation
Transformers
Safetensors
English
ivme
language-model
transformer
rope
swiglu
muon
from-scratch
tiny
small
decoder-only
custom_code
Instructions to use IvmeLabs/Ivme-Conversate-v2-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use IvmeLabs/Ivme-Conversate-v2-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="IvmeLabs/Ivme-Conversate-v2-Base", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("IvmeLabs/Ivme-Conversate-v2-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use IvmeLabs/Ivme-Conversate-v2-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-v2-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-v2-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/IvmeLabs/Ivme-Conversate-v2-Base
- SGLang
How to use IvmeLabs/Ivme-Conversate-v2-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-v2-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-v2-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-v2-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-v2-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use IvmeLabs/Ivme-Conversate-v2-Base with Docker Model Runner:
docker model run hf.co/IvmeLabs/Ivme-Conversate-v2-Base
Delete rope.py
Browse files
rope.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
def precompute_rope_freqs(head_dim: int, max_seq_len: int, theta: float = 10_000.0):
|
| 5 |
-
"""Precompute the rotation angles used by RoPE (Section 4.5).
|
| 6 |
-
|
| 7 |
-
Returns a complex tensor of shape (max_seq_len, head_dim // 2) where each
|
| 8 |
-
entry encodes the rotation to apply at that position/frequency pair.
|
| 9 |
-
"""
|
| 10 |
-
assert head_dim % 2 == 0, "RoPE requires an even head_dim"
|
| 11 |
-
freqs = 1.0 / (theta ** (torch.arange(0, head_dim, 2).float() / head_dim))
|
| 12 |
-
positions = torch.arange(max_seq_len).float()
|
| 13 |
-
angles = torch.outer(positions, freqs) # (seq_len, head_dim/2)
|
| 14 |
-
return torch.polar(torch.ones_like(angles), angles) # complex64
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
def apply_rope(x: torch.Tensor, rope_freqs: torch.Tensor) -> torch.Tensor:
|
| 18 |
-
"""Apply rotary position embedding to a tensor of shape (B, n_heads, T, head_dim).
|
| 19 |
-
|
| 20 |
-
rope_freqs should be pre-sliced to the current sequence length T before
|
| 21 |
-
being passed in, i.e. rope_freqs[:T].
|
| 22 |
-
"""
|
| 23 |
-
B, H, T, D = x.shape
|
| 24 |
-
x_complex = torch.view_as_complex(x.float().reshape(B, H, T, D // 2, 2))
|
| 25 |
-
freqs = rope_freqs.view(1, 1, T, D // 2)
|
| 26 |
-
x_rotated = x_complex * freqs
|
| 27 |
-
out = torch.view_as_real(x_rotated).reshape(B, H, T, D)
|
| 28 |
-
return out.type_as(x)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|