Text Generation
Transformers
Safetensors
English
mini_llm
mini-llm
from-scratch
small-language-model
conversational
custom_code
Instructions to use GautierP/MiniLLM-40M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GautierP/MiniLLM-40M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="GautierP/MiniLLM-40M", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("GautierP/MiniLLM-40M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use GautierP/MiniLLM-40M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "GautierP/MiniLLM-40M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GautierP/MiniLLM-40M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/GautierP/MiniLLM-40M
- SGLang
How to use GautierP/MiniLLM-40M 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 "GautierP/MiniLLM-40M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GautierP/MiniLLM-40M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "GautierP/MiniLLM-40M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GautierP/MiniLLM-40M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use GautierP/MiniLLM-40M with Docker Model Runner:
docker model run hf.co/GautierP/MiniLLM-40M
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -12,11 +12,11 @@ tags:
|
|
| 12 |
|
| 13 |
A ~40M parameter conversational assistant with a full training pipeline implemented
|
| 14 |
end-to-end in PyTorch — BPE tokenizer, pretraining and supervised fine-tuning, no
|
| 15 |
-
pretrained backbone.
|
| 16 |
-
[Mini-LLM](https://github.com/Mini-llm-lab/Mini-LLM)
|
| 17 |
|
| 18 |
-
This repository hosts
|
| 19 |
-
|
| 20 |
|
| 21 |
## Model details
|
| 22 |
|
|
@@ -24,7 +24,7 @@ was fine-tuned from ([`base/`](base)).
|
|
| 24 |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
| 25 |
| Parameters | 42,476,032 (input embedding shared with the output head) |
|
| 26 |
| Architecture | Transformer decoder: RMSNorm, RoPE, causal attention, SwiGLU |
|
| 27 |
-
| Context length | 1,024 tokens — twice the 512 of the
|
| 28 |
| Vocabulary | 32,768 (BPE) |
|
| 29 |
| Pretraining | ~4.60B tokens (FineWeb-Edu + Wikipedia), 35,096 steps (~115 tokens/param) — base val loss 3.202 |
|
| 30 |
| Fine-tuning | 2 epochs of SFT on Dolly-15k, No Robots, OpenAssistant oasst2, alpaca-cleaned and identity/small-talk examples — val loss 3.058 |
|
|
@@ -32,18 +32,18 @@ was fine-tuned from ([`base/`](base)).
|
|
| 32 |
|
| 33 |
## Base model
|
| 34 |
|
| 35 |
-
The
|
| 36 |
(`mini-llm-base-40M-35096steps.pt`) before SFT: 42,476,032 parameters, 32,768-token
|
| 37 |
BPE vocabulary, ~4.60B tokens (FineWeb-Edu + Wikipedia), 35,096 steps — base val loss
|
| 38 |
-
3.202. It is a raw completion model, not an assistant:
|
| 39 |
template and without the assistant's sampling defaults.
|
| 40 |
|
| 41 |
```python
|
| 42 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 43 |
|
| 44 |
-
repo = "GautierP/MiniLLM-40M"
|
| 45 |
-
tok = AutoTokenizer.from_pretrained(repo,
|
| 46 |
-
model = AutoModelForCausalLM.from_pretrained(repo,
|
| 47 |
|
| 48 |
inputs = tok("The capital of France is", return_tensors="pt")
|
| 49 |
out = model.generate(**inputs, max_new_tokens=64, do_sample=True, temperature=0.8, top_k=50)
|
|
|
|
| 12 |
|
| 13 |
A ~40M parameter conversational assistant with a full training pipeline implemented
|
| 14 |
end-to-end in PyTorch — BPE tokenizer, pretraining and supervised fine-tuning, no
|
| 15 |
+
pretrained backbone. Code, training pipeline and documentation:
|
| 16 |
+
[github.com/Mini-llm-lab/Mini-LLM](https://github.com/Mini-llm-lab/Mini-LLM).
|
| 17 |
|
| 18 |
+
This repository hosts the SFT assistant. The base model it was fine-tuned from is
|
| 19 |
+
published separately: [GautierP/MiniLLM-40M-base](https://huggingface.co/GautierP/MiniLLM-40M-base).
|
| 20 |
|
| 21 |
## Model details
|
| 22 |
|
|
|
|
| 24 |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
| 25 |
| Parameters | 42,476,032 (input embedding shared with the output head) |
|
| 26 |
| Architecture | Transformer decoder: RMSNorm, RoPE, causal attention, SwiGLU |
|
| 27 |
+
| Context length | 1,024 tokens — twice the 512 of the earlier 1.0-generation runs |
|
| 28 |
| Vocabulary | 32,768 (BPE) |
|
| 29 |
| Pretraining | ~4.60B tokens (FineWeb-Edu + Wikipedia), 35,096 steps (~115 tokens/param) — base val loss 3.202 |
|
| 30 |
| Fine-tuning | 2 epochs of SFT on Dolly-15k, No Robots, OpenAssistant oasst2, alpaca-cleaned and identity/small-talk examples — val loss 3.058 |
|
|
|
|
| 32 |
|
| 33 |
## Base model
|
| 34 |
|
| 35 |
+
The base repository contains the pretrained checkpoint
|
| 36 |
(`mini-llm-base-40M-35096steps.pt`) before SFT: 42,476,032 parameters, 32,768-token
|
| 37 |
BPE vocabulary, ~4.60B tokens (FineWeb-Edu + Wikipedia), 35,096 steps — base val loss
|
| 38 |
+
3.202. It is a raw completion model, not an assistant: the base ships without a chat
|
| 39 |
template and without the assistant's sampling defaults.
|
| 40 |
|
| 41 |
```python
|
| 42 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 43 |
|
| 44 |
+
repo = "GautierP/MiniLLM-40M-base"
|
| 45 |
+
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
|
| 46 |
+
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True)
|
| 47 |
|
| 48 |
inputs = tok("The capital of France is", return_tensors="pt")
|
| 49 |
out = model.generate(**inputs, max_new_tokens=64, do_sample=True, temperature=0.8, top_k=50)
|