Instructions to use Crystalcareai/GemMoE-Medium-v0.4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Crystalcareai/GemMoE-Medium-v0.4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Crystalcareai/GemMoE-Medium-v0.4", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Crystalcareai/GemMoE-Medium-v0.4", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Crystalcareai/GemMoE-Medium-v0.4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Crystalcareai/GemMoE-Medium-v0.4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Crystalcareai/GemMoE-Medium-v0.4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Crystalcareai/GemMoE-Medium-v0.4
- SGLang
How to use Crystalcareai/GemMoE-Medium-v0.4 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 "Crystalcareai/GemMoE-Medium-v0.4" \ --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": "Crystalcareai/GemMoE-Medium-v0.4", "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 "Crystalcareai/GemMoE-Medium-v0.4" \ --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": "Crystalcareai/GemMoE-Medium-v0.4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Crystalcareai/GemMoE-Medium-v0.4 with Docker Model Runner:
docker model run hf.co/Crystalcareai/GemMoE-Medium-v0.4
Update modeling_gemmoe.py
Browse files- modeling_gemmoe.py +0 -12
modeling_gemmoe.py
CHANGED
|
@@ -743,22 +743,12 @@ class GemmoeDecoderLayer(nn.Module):
|
|
| 743 |
output_attentions=output_attentions,
|
| 744 |
use_cache=use_cache,
|
| 745 |
)
|
| 746 |
-
|
| 747 |
-
# Check if the tensor sizes match before adding residual
|
| 748 |
-
if hidden_states.size() != residual.size():
|
| 749 |
-
hidden_states = hidden_states[:, -residual.size(1):, :]
|
| 750 |
-
|
| 751 |
hidden_states = residual + hidden_states
|
| 752 |
|
| 753 |
# Fully Connected
|
| 754 |
residual = hidden_states
|
| 755 |
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 756 |
hidden_states, router_logits = self.block_sparse_moe(hidden_states)
|
| 757 |
-
|
| 758 |
-
# Check if the tensor sizes match before adding residual
|
| 759 |
-
if hidden_states.size() != residual.size():
|
| 760 |
-
hidden_states = hidden_states[:, -residual.size(1):, :]
|
| 761 |
-
|
| 762 |
hidden_states = residual + hidden_states
|
| 763 |
|
| 764 |
outputs = (hidden_states,)
|
|
@@ -775,8 +765,6 @@ class GemmoeDecoderLayer(nn.Module):
|
|
| 775 |
return outputs
|
| 776 |
|
| 777 |
|
| 778 |
-
|
| 779 |
-
|
| 780 |
GEMMOE_START_DOCSTRING = r"""
|
| 781 |
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
| 782 |
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
|
|
|
|
| 743 |
output_attentions=output_attentions,
|
| 744 |
use_cache=use_cache,
|
| 745 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 746 |
hidden_states = residual + hidden_states
|
| 747 |
|
| 748 |
# Fully Connected
|
| 749 |
residual = hidden_states
|
| 750 |
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 751 |
hidden_states, router_logits = self.block_sparse_moe(hidden_states)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 752 |
hidden_states = residual + hidden_states
|
| 753 |
|
| 754 |
outputs = (hidden_states,)
|
|
|
|
| 765 |
return outputs
|
| 766 |
|
| 767 |
|
|
|
|
|
|
|
| 768 |
GEMMOE_START_DOCSTRING = r"""
|
| 769 |
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
| 770 |
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
|