Text Generation
Transformers
Safetensors
English
philolm
philosophy
base-model
trained-from-scratch
small-language-model
n-gram-embedding
muon
webassembly
custom_code
Instructions to use gustavecortal/PhiloLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gustavecortal/PhiloLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="gustavecortal/PhiloLM", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("gustavecortal/PhiloLM", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use gustavecortal/PhiloLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "gustavecortal/PhiloLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gustavecortal/PhiloLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/gustavecortal/PhiloLM
- SGLang
How to use gustavecortal/PhiloLM 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 "gustavecortal/PhiloLM" \ --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": "gustavecortal/PhiloLM", "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 "gustavecortal/PhiloLM" \ --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": "gustavecortal/PhiloLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use gustavecortal/PhiloLM with Docker Model Runner:
docker model run hf.co/gustavecortal/PhiloLM
Model card: highlights and model overview, parameters counted as for n-gram models
Browse files
README.md
CHANGED
|
@@ -35,18 +35,30 @@ The problem of personal identity is the problem of how we can be both identical
|
|
| 35 |
other selves.
|
| 36 |
```
|
| 37 |
|
| 38 |
-
##
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
## Training
|
| 52 |
|
|
|
|
| 35 |
other selves.
|
| 36 |
```
|
| 37 |
|
| 38 |
+
## Highlights
|
| 39 |
+
|
| 40 |
+
- **N-gram embedding**: a hashed table of 245,760 bigram rows adds what the previous token says about the current one, before every block. It holds 31M parameters that are read, not multiplied, so they cost almost no compute.
|
| 41 |
+
- **Hybrid attention**: three local blocks (a window of 256 tokens) for each global block, which uses grouped-query attention with 3 key-value heads.
|
| 42 |
+
- **Training recipe**: Muon for hidden matrices and AdamW for the rest, four passes with each document read at most four times, and the final weights blended with their moving average.
|
| 43 |
+
- **Runs in the browser**: an 8-bit WebAssembly engine on up to four threads, at 0.2% bits per byte above float32.
|
| 44 |
+
|
| 45 |
+
## Model overview
|
| 46 |
+
|
| 47 |
+
- Type: causal language model (base, not instruction-tuned)
|
| 48 |
+
- Training stage: pre-training
|
| 49 |
+
- Number of parameters: 80M (61M non-embedding), plus 31M n-gram embedding
|
| 50 |
+
- Hidden dimension: 576
|
| 51 |
+
- Token embedding: 32,768, tied with the output layer
|
| 52 |
+
- N-gram embedding: 245,760 rows of 128 values (bigrams, with a fixed ±1 sign pattern), added to the first 128 hidden dimensions before every block
|
| 53 |
+
- Number of layers: 16
|
| 54 |
+
- Hidden layout: 4 × (3 × (local attention → SwiGLU) → 1 × (global attention → SwiGLU))
|
| 55 |
+
- Local attention: 9 heads of 64 dimensions, a window of 256 tokens
|
| 56 |
+
- Global attention: 9 query heads and 3 key-value heads of 64 dimensions. The 32 key dimensions without rotary embedding come from the previous token
|
| 57 |
+
- Rotary position embedding dimension: 32 of 64 (base 10,000)
|
| 58 |
+
- Attention: QK-norm and a sigmoid gate on each head's output
|
| 59 |
+
- SwiGLU intermediate dimension: 1,512
|
| 60 |
+
- Context length: 4,096 tokens. Documents are separated by the end-of-text token, and each attends only to itself
|
| 61 |
+
- Tokenizer: byte-level BPE trained on the training text
|
| 62 |
|
| 63 |
## Training
|
| 64 |
|