This is an efficient Mixture of Experts (MoE) enhancement of the GPT-NeoX-125M architecture. By adding sparse expert routing, this model achieves better performance with significantly lower computational costs compared to traditional dense models.
1import torch
2from transformers import AutoTokenizer, GPTNeoXForCausalLM
34# Load tokenizer (from Pythia for better template support)5tokenizer = AutoTokenizer.from_pretrained("EleutherAI/pythia-160m")67# Load base model8base_model = GPTNeoXForCausalLM.from_pretrained("Kiy-K/moe-gpt-neox-125m-v1.1")910# For full MoE functionality, you'll need the MoEGPTNeoX wrapper11# (See architecture code in repository)1213# Basic generation example (with base model)14text ="def fibonacci(n):"15inputs = tokenizer(text, return_tensors="pt")1617with torch.no_grad():18 outputs = base_model.generate(19**inputs,20 max_length=100,21 temperature=0.7,22 top_p=0.9,23 do_sample=True24)2526print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Loading MoE Layers
python
1from safetensors.torch import load_file
23# Load MoE weights4moe_weights = load_file("moe_layers.safetensors")56# Apply to your MoEGPTNeoX wrapper7# (Full implementation in training script)
Generation Parameters
Recommended settings:
python
1# For creative tasks (code, stories)2generation_config ={3"temperature":0.7,4"top_p":0.9,5"top_k":50,6"repetition_penalty":1.17}89# For factual tasks (Q&A, documentation)10generation_config ={11"temperature":0.3,12"top_p":0.85,13"top_k":40,14"repetition_penalty":1.015}
1# Use float16 for faster inference2model = model.half().to("cuda")34# Enable torch.compile (PyTorch 2.0+)5model = torch.compile(model)67# Use gradient checkpointing for fine-tuning8model.gradient_checkpointing_enable()
🔄 Updates & Versions
v1.5 (Current)
Enhanced training with 21K diverse samples
Improved load balancing
Safetensors format for all weights
Better documentation
v1.1 (Base)
Initial MoE architecture
8 experts, top-2 routing
Basic training setup
📝 Citation
If you use this model in your research or projects, please cite:
bibtex
1@misc{moe_gpt_neox_125m_v15,
2 author = {Kiy-K},
3 title = {MoE GPT-NeoX 125M v1.5: Efficient Mixture of Experts Language Model},
4 year = {2025},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/Kiy-K/moe-gpt-neox-125m-v1.5}
7}
🤝 Contributing & Support
Issues
Found a bug or have a suggestion? Please open an issue on the repository!