Text Generation
Transformers
Safetensors
English
forgeplex_m2
language-model
forgeplex
forgeworks
rope
swiglu
gqa
attn-output-gate
refresh-gate
custom_code
Instructions to use ForgeWorks/ForgePlex-M2-9M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ForgeWorks/ForgePlex-M2-9M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ForgeWorks/ForgePlex-M2-9M", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ForgeWorks/ForgePlex-M2-9M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ForgeWorks/ForgePlex-M2-9M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ForgeWorks/ForgePlex-M2-9M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ForgeWorks/ForgePlex-M2-9M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ForgeWorks/ForgePlex-M2-9M
- SGLang
How to use ForgeWorks/ForgePlex-M2-9M 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 "ForgeWorks/ForgePlex-M2-9M" \ --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": "ForgeWorks/ForgePlex-M2-9M", "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 "ForgeWorks/ForgePlex-M2-9M" \ --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": "ForgeWorks/ForgePlex-M2-9M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ForgeWorks/ForgePlex-M2-9M with Docker Model Runner:
docker model run hf.co/ForgeWorks/ForgePlex-M2-9M
Download configuration_forgeplex_m2.py from ForgeWorks/ForgePlex-M2-9M: direct link, hf CLI and curl.
- Browser
- Download file 1.98 kB
-
https://huggingface.co/ForgeWorks/ForgePlex-M2-9M/resolve/main/configuration_forgeplex_m2.py
- Command line
-
hf download hf://ForgeWorks/ForgePlex-M2-9M/configuration_forgeplex_m2.py
-
curl -L -o configuration_forgeplex_m2.py https://huggingface.co/ForgeWorks/ForgePlex-M2-9M/resolve/main/configuration_forgeplex_m2.py
1.98 kB
| """ForgePlex-M2 model configuration for Hugging Face Transformers.""" | |
| from transformers import PretrainedConfig | |
| class ForgePlexM2Config(PretrainedConfig): | |
| model_type = "forgeplex_m2" | |
| def __init__( | |
| self, | |
| vocab_size: int = 4096, | |
| hidden_size: int = 256, | |
| num_hidden_layers: int = 11, | |
| num_attention_heads: int = 8, | |
| num_key_value_heads: int = 2, | |
| head_dim: int = 32, | |
| intermediate_size: int = 707, | |
| max_position_embeddings: int = 1024, | |
| rope_theta: float = 5000.0, | |
| rms_norm_eps: float = 1e-6, | |
| tie_word_embeddings: bool = True, | |
| use_xsa_projection: bool = False, | |
| use_attn_output_gate: bool = True, | |
| use_refresh_gate: bool = True, | |
| inject_layers: list | tuple | None = None, | |
| refresh_kernel: int = 9, | |
| bos_token_id: int = 0, | |
| eos_token_id: int = 0, | |
| pad_token_id: int = 1, | |
| **kwargs, | |
| ): | |
| if inject_layers is None: | |
| inject_layers = [5, 10] | |
| self.vocab_size = vocab_size | |
| self.hidden_size = hidden_size | |
| self.num_hidden_layers = num_hidden_layers | |
| self.num_attention_heads = num_attention_heads | |
| self.num_key_value_heads = num_key_value_heads | |
| self.head_dim = head_dim | |
| self.intermediate_size = intermediate_size | |
| self.max_position_embeddings = max_position_embeddings | |
| self.rope_theta = rope_theta | |
| self.rms_norm_eps = rms_norm_eps | |
| self.use_xsa_projection = use_xsa_projection | |
| self.use_attn_output_gate = use_attn_output_gate | |
| self.use_refresh_gate = use_refresh_gate | |
| self.inject_layers = list(int(i) for i in inject_layers) | |
| self.refresh_kernel = refresh_kernel | |
| super().__init__( | |
| tie_word_embeddings=tie_word_embeddings, | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| pad_token_id=pad_token_id, | |
| **kwargs, | |
| ) | |