Spaces:
Running
Running
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,10 +1,60 @@
|
|
| 1 |
---
|
| 2 |
title: MonarchSLM
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: MonarchSLM
|
| 3 |
+
emoji: "\U0001F451"
|
| 4 |
+
colorFrom: yellow
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
+
license: mit
|
| 10 |
+
tags:
|
| 11 |
+
- julia
|
| 12 |
+
- lux
|
| 13 |
+
- slm
|
| 14 |
+
- philosophy
|
| 15 |
+
- openai-compatible
|
| 16 |
+
- bpe
|
| 17 |
+
- monarch-mixer
|
| 18 |
+
- rmsnorm
|
| 19 |
+
- swiglu
|
| 20 |
---
|
| 21 |
|
| 22 |
+
# MonarchSLM
|
| 23 |
+
|
| 24 |
+
A Monarch Mixer decoder-only model (sub-quadratic sequence mixing, RMSNorm, SwiGLU) trained on classical philosophy texts, implemented in Julia with Lux.jl. Serves an OpenAI-compatible API with streaming support.
|
| 25 |
+
|
| 26 |
+
## Endpoints
|
| 27 |
+
|
| 28 |
+
- `GET /` β Health check and model info
|
| 29 |
+
- `GET /v1/models` β List available models
|
| 30 |
+
- `POST /v1/chat/completions` β Generate text (supports streaming, top-k, top-p)
|
| 31 |
+
|
| 32 |
+
## Usage
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
# Non-streaming
|
| 36 |
+
curl -X POST https://your-space.hf.space/v1/chat/completions \
|
| 37 |
+
-H "Content-Type: application/json" \
|
| 38 |
+
-d '{"messages": [{"role": "user", "content": "the nature of"}], "max_tokens": 200}'
|
| 39 |
+
|
| 40 |
+
# Streaming
|
| 41 |
+
curl -X POST https://your-space.hf.space/v1/chat/completions \
|
| 42 |
+
-H "Content-Type: application/json" \
|
| 43 |
+
-d '{"messages": [{"role": "user", "content": "the nature of"}], "stream": true, "temperature": 0.7, "top_k": 40}'
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
## Architecture
|
| 47 |
+
|
| 48 |
+
- **Model**: ~5M params, 256d embed, 8 layers, 8 Monarch heads
|
| 49 |
+
- **Sequence mixing**: Multi-head Monarch Matrix (sub-quadratic) + Causal Depthwise Conv + Learned Gate
|
| 50 |
+
- **Tokenizer**: BPE (2000 tokens)
|
| 51 |
+
- **Framework**: Lux.jl (explicit parameter/state management)
|
| 52 |
+
- **Normalization**: RMSNorm (pre-norm)
|
| 53 |
+
- **Feed-forward**: SwiGLU activation
|
| 54 |
+
- **Weight tying**: Shared embedding/output projection
|
| 55 |
+
- **Inference**: CPU-only, no Lux dependency at runtime (pure NNlib)
|
| 56 |
+
|
| 57 |
+
## Environment Variables
|
| 58 |
+
|
| 59 |
+
- `HF_REPO` β HuggingFace model repo (default: `LisaMegaWatts/MonarchSLM`)
|
| 60 |
+
- `PORT` β Server port (default: `7860`)
|