Text Generation
Transformers
Safetensors
French
ptit_slm
ptit-slm
from-scratch
post-norm
custom_code
experimental
Instructions to use MisterAI/Ptit_SLM_Poc03 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MisterAI/Ptit_SLM_Poc03 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MisterAI/Ptit_SLM_Poc03", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MisterAI/Ptit_SLM_Poc03", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MisterAI/Ptit_SLM_Poc03 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MisterAI/Ptit_SLM_Poc03" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MisterAI/Ptit_SLM_Poc03", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MisterAI/Ptit_SLM_Poc03
- SGLang
How to use MisterAI/Ptit_SLM_Poc03 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 "MisterAI/Ptit_SLM_Poc03" \ --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": "MisterAI/Ptit_SLM_Poc03", "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 "MisterAI/Ptit_SLM_Poc03" \ --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": "MisterAI/Ptit_SLM_Poc03", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MisterAI/Ptit_SLM_Poc03 with Docker Model Runner:
docker model run hf.co/MisterAI/Ptit_SLM_Poc03
|
Download README.md from MisterAI/Ptit_SLM_Poc03: direct link, hf CLI and curl.
- Browser
- Download file 14.3 kB
-
https://huggingface.co/MisterAI/Ptit_SLM_Poc03/resolve/main/README.md
- Command line
-
hf download hf://MisterAI/Ptit_SLM_Poc03/README.md
-
curl -L -o README.md https://huggingface.co/MisterAI/Ptit_SLM_Poc03/resolve/main/README.md
14.3 kB
| license: agpl-3.0 | |
| language: | |
| - fr | |
| pipeline_tag: text-generation | |
| library_name: transformers | |
| tags: | |
| - ptit-slm | |
| - from-scratch | |
| - post-norm | |
| - custom_code | |
| - experimental | |
| datasets: | |
| - MisterAI/WM-ORG-XML-DUMP_FR_2026.08 | |
| - HuggingFaceFW/fineweb-2 | |
| - CATIE-AQ/french_books_summaries | |
| - MisterAI/DATAGOUV.FR_JADE_2026.09 | |
| - HuggingFaceFW/finepdfs-edu | |
| - nvidia/OpenCodeInstruct | |
| - rivoluzione-informatica/bash-datasets | |
| - AIffl/french_hh_rlhf | |
| - OpenLLM-France/Luciole-Training-Dataset | |
| - CATIE-AQ/CFP | |
| - CATIE-AQ/NanoSCIDOCS-fr | |
| - CATIE-AQ/NanoSciFact-fr | |
| - CATIE-AQ/NanoHotpotQA-fr | |
| - CATIE-AQ/NanoNFCorpus-fr | |
| - CATIE-AQ/frenchQA | |
| - AIffl/french_orca_dpo_pairs | |
| - AIffl/ultrafrench | |
| # **Ptit_SLM_Poc03** Surnommé **CARLOS_IWEN_PREMIER** | |
| - Nom de code : Ptit_SLM_Poc03 | |
| - Surnommé **CARLOS_IWEN_PREMIER** en hommage aux collègues qui ont soutenu le projet | |
| **Ptit_SLM_Poc03** est un petit modèle de langage (~63 millions de paramètres) en français, entraîné **entièrement Ex-Nihilo**. | |
| ## ⚠️ **POC expérimental.** | |
| Ce modèle est un essai de recherche personnelle : | |
| il écrit un français généralement cohérent, mais il se répète, invente des faits et ne comprend pas vraiment les questions. | |
| Il n'est pas destiné à un usage en production. | |
| - **Auteur** : MisterAI | |
| - **Licence** : AGPLv3 | |
| - **Langue** : français | |
| - **Contexte** : 1024 tokens | |
| ## Architecture | |
| Transformer décodeur **POST-NORM**, écrit à la main (pas un GPT-2, ni un Mistral, ni un Llama) : | |
| ``` | |
| x = embed(ids) + pos_embed(positions) puis dropout | |
| pour chaque bloc : | |
| x = norm1(x + dropout(attention(x))) | |
| x = norm2(x + dropout(ffn(x))) | |
| x = ln_f(x) | |
| logits = head(x) | |
| ``` | |
| | Paramètre | Valeur | | |
| |---|---| | |
| | Paramètres | ~63 M | | |
| | Vocabulaire | 32 768 (BPE personnalisé) | | |
| | Dimension (`d_model`) | 512 | | |
| | Couches | 8 | | |
| | Têtes d'attention | 8 | | |
| | Dimension FFN | 2048 (GELU) | | |
| | Dropout | 0,1 (entraînement) | | |
| | Normalisation | LayerNorm, eps = 1e-5 | | |
| | Positions | **apprises**, 8192 lignes (entraînées surtout à 1024) | | |
| | Attention | `nn.MultiheadAttention`, masque causal, avec biais | | |
| | Tête de sortie | `Linear(512, 32768)` **avec biais**, embeddings non partagés | | |
| | Cache KV | aucun (la génération recalcule tout le contexte à chaque token) | | |
| | Poids | `model.safetensors`, float32 (~241 Mo) | | |
| ### Pourquoi pas un format standard (GPT-2, Mistral, GGUF) ? | |
| - Le post-norm et la tête de sortie avec biais ne rentrent pas dans l'architecture GPT-2 (strictement pre-norm). | |
| - Une conversion avec distillation a été tentée : elle a produit du charabia et a été abandonnée. | |
| - Il n'y a donc **pas de version GGUF** de ce modèle. | |
| - Un futur **POC04** suivra les standards (pre-norm, RMSNorm, RoPE, SwiGLU, tête sans biais) pour être convertible. | |
| ## Tokenizer | |
| BPE personnalisé de 32 768 tokens (`tokenizer.json`), sans token spécial ajouté automatiquement. Jetons spéciaux : | |
| | ID | Token | Rôle | | |
| |---|---|---| | |
| | 0 | `[UNK]` | inconnu | | |
| | 1 | `[CLS]` | début de séquence | | |
| | 2 | `[SEP]` | fin de séquence | | |
| | 3 | `[PAD]` | remplissage | | |
| | 4 | `[MASK]` | masque | | |
| | 5 à 12 | `[SYSTEM]`, `[USER]`, `[ASSISTANT]`, `[TOOL]`, `[FUNCTION]`, `[RAG]`, `[CODE]`, `[THINK]` | rôles | | |
| Format de conversation attendu par le modèle : | |
| ``` | |
| [CLS][USER] votre message [ASSISTANT] réponse du modèle [SEP] | |
| ``` | |
| Comme aucun token spécial n'est ajouté automatiquement, il faut les écrire soi-même (les scripts fournis le font pour vous). | |
| ## Contenu du dépôt | |
| ``` | |
| . | |
| ├── README.md | |
| ├── HF_Venv_Requirements.txt | |
| ├── config.json | |
| ├── generation_config.json | |
| ├── model.safetensors | |
| ├── tokenizer.json, tokenizer_config.json, special_tokens_map.json | |
| ├── configuration_ptit_slm.py (code pour transformers) | |
| ├── modeling_ptit_slm.py (code pour transformers) | |
| ├── Scripts/ | |
| │ ├── Script_InferenceLocale_Ptit_SLM_Poc03.py | |
| │ └── Script_EntrainementLocal_Ptit_SLM_Poc03.py | |
| └── Jeux_De_Donnees/ | |
| └── Exemple_JeuxDeDonnees.jsonl | |
| ``` | |
| ## Installation | |
| Python 3.11 recommandé. Récupérez le dépôt (les poids sont gérés par Git LFS / Xet) : | |
| ```bash | |
| git lfs install | |
| git clone https://huggingface.co/MisterAI/Ptit_SLM_Poc03 | |
| cd Ptit_SLM_Poc03 | |
| ``` | |
| Créez ensuite l'environnement, au choix avec `uv` ou avec `pip` : | |
| ```bash | |
| # Avec uv | |
| uv venv venvPoc03 --python 3.11 && uv pip install -r HF_Venv_Requirements.txt --python venvPoc03 | |
| # Avec pip | |
| python -m venv venvPoc03 | |
| pip install -r HF_Venv_Requirements.txt | |
| ``` | |
| Activez-le : `source venvPoc03/bin/activate` (Linux, macOS) ou `venvPoc03\Scripts\activate` (Windows). | |
| Le GPU est utilisé automatiquement si CUDA est disponible, sinon le calcul se fait sur CPU. | |
| ## Utilisation | |
| ### Option 1 : scripts fournis (sans `transformers`) | |
| Ces scripts n'ont besoin que de `torch`, `safetensors` et `tokenizers`. Lancez-les **depuis la racine du dépôt** : | |
| ```bash | |
| python -m Scripts.Script_InferenceLocale_Ptit_SLM_Poc03 | |
| ``` | |
| Tapez votre message, le modèle répond. Le contexte s'accumule jusqu'à 1024 tokens ; ensuite tapez `/effacer`. | |
| | Commande | Effet | | |
| |---|---| | |
| | `/effacer` | vide le contexte | | |
| | `/quitter` | quitte le programme | | |
| | `/aide` | rappelle les commandes | | |
| Réglages en tête du script : `TEMPERATURE` (0,4 par défaut, 0 = déterministe), `TOP_K`, `TOP_P`, `PENALITE_REPETITION`, `NOMBRE_TOKENS_MAX_PAR_REPONSE`, `MODE_CONVERSATION` (`False` pour une simple complétion de texte), `DOSSIER_MODELE`. | |
| ### Option 2 : `transformers` | |
| Le dépôt contient le code du modèle : il faut donc `trust_remote_code=True`. Comme `transformers` n'ajoute aucun token spécial, le format de conversation est écrit à la main : | |
| ```python | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| depot = "MisterAI/Ptit_SLM_Poc03" | |
| peripherique = "cuda" if torch.cuda.is_available() else "cpu" | |
| tokenizer = AutoTokenizer.from_pretrained(depot) | |
| modele = AutoModelForCausalLM.from_pretrained(depot, trust_remote_code=True).to(peripherique) | |
| modele.eval() | |
| texte = "[CLS][USER]Bonjour, comment ça va ?[ASSISTANT]" | |
| entree = tokenizer(texte, return_tensors="pt", add_special_tokens=False).to(peripherique) | |
| with torch.no_grad(): | |
| sortie = modele.generate( | |
| **entree, | |
| max_new_tokens=150, | |
| eos_token_id=2, | |
| pad_token_id=3, | |
| repetition_penalty=1.1, | |
| ) | |
| print(tokenizer.decode(sortie[0][entree["input_ids"].shape[1]:], skip_special_tokens=True)) | |
| ``` | |
| Sans cache KV, la génération est plus lente qu'avec un modèle classique, surtout sur CPU. Les réglages par défaut (`temperature` 0,4, `top_k` 40) viennent de `generation_config.json`. | |
| ## Fine-tuning (SFT) | |
| Le script d'entraînement refait un fine-tuning supervisé à partir de ces poids : | |
| ```bash | |
| python -m Scripts.Script_EntrainementLocal_Ptit_SLM_Poc03 | |
| ``` | |
| 1. Placez vos fichiers `.jsonl` (ou `.json` contenant une liste) dans `Jeux_De_Donnees/`. Un exemple par ligne : | |
| ```json | |
| {"instruction": "Quelle est la capitale de la France ?", "reponse": "La capitale de la France est Paris."} | |
| ``` | |
| 2. Balises acceptées par défaut : entrée = `instruction`, `question` ou `prompt` ; sortie = `reponse`, `answer` ou `completion` (la première présente est utilisée). Elles se changent avec `CHAMPS_ENTREE` et `CHAMPS_SORTIE`. Les autres champs sont ignorés. Une ligne sans sortie est ignorée. | |
| 3. Le modèle fine-tuné est écrit dans `Ptit_SLM_Poc03_SFT/` (poids et fichiers de configuration). Pour le tester, mettez `DOSSIER_MODELE = "./Ptit_SLM_Poc03_SFT"` dans le script d'inférence. | |
| Réglages principaux (en tête du script) : `NOMBRE_EPOCHS`, `TAILLE_LOT`, `ETAPES_ACCUMULATION_GRADIENT`, `TAUX_APPRENTISSAGE`, `MODE_CONVERSATION`, `MASQUER_ENTREE` (si `True`, seule la réponse est apprise), `PROPORTION_VALIDATION`. Si vous manquez de mémoire GPU, baissez `TAILLE_LOT` et augmentez `ETAPES_ACCUMULATION_GRADIENT`. | |
| ## Données d'entraînement | |
| Modèle entraîné Ex-Nihilo sur du texte français. Jeux de données utilisés : | |
| **PRE-TRAIN** | |
| - [MisterAI/WM-ORG-XML-DUMP_FR_2026.08](https://huggingface.co/datasets/MisterAI/WM-ORG-XML-DUMP_FR_2026.08) | |
| - Licence : [Creative Commons Attribution-ShareAlike 4.0 International](https://dumps.wikimedia.org/legal.html) | |
| - [HuggingFaceFW/fineweb-2](https://huggingface.co/datasets/HuggingFaceFW/fineweb-2) | |
| - Licence : [Open Data Commons License Attribution](https://opendatacommons.org/licenses/by/) | |
| - [CATIE-AQ/french_books_summaries](https://huggingface.co/datasets/CATIE-AQ/french_books_summaries) | |
| - Licence : [Creative Commons Attribution 4.0 International](https://choosealicense.com/licenses/cc-by-4.0/) | |
| - [MisterAI/DATAGOUV.FR_JADE_2026.09](https://huggingface.co/datasets/MisterAI/DATAGOUV.FR_JADE_2026.09) | |
| - Licence : [Etalab Open License 2.0](https://spdx.org/licenses/etalab-2.0) | |
| - [HuggingFaceFW/finepdfs-edu](https://huggingface.co/datasets/HuggingFaceFW/finepdfs-edu) | |
| - Licence : [Open Data Commons License Attribution](https://opendatacommons.org/licenses/by/) | |
| - [nvidia/OpenCodeInstruct](https://huggingface.co/datasets/nvidia/OpenCodeInstruct) | |
| - Licence : [Creative Commons Attribution 4.0 International](https://choosealicense.com/licenses/cc-by-4.0/) | |
| - [rivoluzione-informatica/bash-datasets/fuzzed_commands_final.jsonl](https://github.com/rivoluzione-informatica/bash-datasets/blob/main/data/fuzzed_commands_final.jsonl) | |
| - Licence : [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/deed.en) | |
| - [OpenLLM-France/Luciole-Training-Dataset](https://huggingface.co/datasets/OpenLLM-France/Luciole-Training-Dataset) | |
| - Licence : [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/deed.en) | |
| - [AIffl/french_hh_rlhf](https://huggingface.co/datasets/AIffl/french_hh_rlhf) | |
| - Licence : [MIT License](https://choosealicense.com/licenses/mit/) | |
| **SFT** | |
| - [OpenLLM-France/Luciole-Training-Dataset](https://huggingface.co/datasets/OpenLLM-France/Luciole-Training-Dataset) | |
| - Licence : [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/deed.en) | |
| - [CATIE-AQ/CFP](https://huggingface.co/datasets/CATIE-AQ/CFP) | |
| - Licence : [Creative Commons Attribution Non Commercial Share Alike 4.0 International](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.en) | |
| - [CATIE-AQ/NanoSCIDOCS-fr](https://huggingface.co/datasets/CATIE-AQ/NanoSCIDOCS-fr) | |
| - Licence : [Creative Commons Attribution 4.0 International](https://choosealicense.com/licenses/cc-by-4.0/) | |
| - [CATIE-AQ/NanoSciFact-fr](https://huggingface.co/datasets/CATIE-AQ/NanoSciFact-fr) | |
| - Licence : [Creative Commons Attribution 4.0 International](https://choosealicense.com/licenses/cc-by-4.0/) | |
| - [CATIE-AQ/NanoHotpotQA-fr](https://huggingface.co/datasets/CATIE-AQ/NanoHotpotQA-fr) | |
| - Licence : [Creative Commons Attribution 4.0 International](https://choosealicense.com/licenses/cc-by-4.0/) | |
| - [CATIE-AQ/NanoNFCorpus-fr](https://huggingface.co/datasets/CATIE-AQ/NanoNFCorpus-fr) | |
| - Licence : [Creative Commons Attribution 4.0 International](https://choosealicense.com/licenses/cc-by-4.0/) | |
| - [CATIE-AQ/frenchQA](https://huggingface.co/datasets/CATIE-AQ/frenchQA) | |
| - Licence : [Creative Commons Attribution 4.0 International](https://choosealicense.com/licenses/cc-by-4.0/) | |
| - [AIffl/french_orca_dpo_pairs](https://huggingface.co/datasets/AIffl/french_orca_dpo_pairs) | |
| - Licence : [Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/) | |
| - [AIffl/ultrafrench](https://huggingface.co/datasets/AIffl/ultrafrench) | |
| - Licence : [Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/) | |
| - [nvidia/OpenCodeInstruct](https://huggingface.co/datasets/nvidia/OpenCodeInstruct) | |
| - Licence : [Creative Commons Attribution 4.0 International](https://choosealicense.com/licenses/cc-by-4.0/) | |
| *NB : Uniqument les parties en Français des JDD Cités ont été utilisées (sauf si inexistant) - Modification du formatage lorsque necessaire pour comptabilité avec mes scripts* | |
| ## Entraînement | |
| - Entraînement complet en 14 phases sur des JDD de 500Mo environs (sans compter les arrets/echecs sur erreurs et run mal configurés perdus) : | |
| - Les premières phases ont été faites à 2048 tokens de contexte, sur CPU i7-2600 12Go Ram; | |
| - Pour 500Mo compter environs 6 Jours... | |
| - le reste à 1024 tokens sur GPU de 4Go de VRam; | |
| - Pour 500Mo compter environ 12 Heures >:) | |
| - Les positions au-delà de 1024 existent dans les poids (8192 lignes) mais ont été très peu entraînées : à éviter. | |
| ## Limites connues | |
| - Texte souvent répétitif et sans fiabilité factuelle : ne pas s'y fier pour des informations réelles. | |
| - Comprend mal les consignes. Un modèle de 63 M de paramètres reste très limité. | |
| - Contexte de 1024 tokens maximum. | |
| - Pas de cache KV : génération lente sur de longs contextes. | |
| - Pas de format GGUF, pas de compatibilité avec llama.cpp ou Ollama. | |
| - Le code `transformers` reproduit l'architecture des scripts, mais l'équivalence exacte des sorties (comparaison des logits) n'a pas encore été vérifiée numériquement. | |
| - Le modèle produit du texte inexact, biaisé et parfois inapproprié. | |
| ## Licence | |
| Le code de ce dépôt et les poids du modèle sont publiés sous licence : | |
| - [GNU Affero General Public License v3.0 (AGPL-3.0)](https://www.gnu.org/licenses/agpl-3.0.html). | |
| Les jeux de données utilisés pour l’entraînement : | |
| - Ne sont pas redistribués avec ce dépôt | |
| - Ils restent soumis à leurs licences respectives | |
| - Leurs sources, licences et attributions sont indiquées dans la Section **Données d'entraînement** | |
| ## Auteur | |
| Conception, Initialisation et Entrainement réalisés par [**MisterAI**](https://huggingface.co/MisterAI) avec L'assistance de : | |
| - devstral-small-4 | |
| - Nemotron-3-ultra550b | |
| - Claude5.5-Sonnet | |
| ### Citation | |
| ```bibtex | |
| @Model{MisterAI_Ptit_SLM_Poc03, | |
| title = {Ptit_SLM_Poc03 - petit modèle de langage (~63 millions de paramètres) en français, entraîné entièrement Ex-Nihilo}, | |
| author = {MisterAI}, | |
| year = {2026}, | |
| publisher = {Hugging Face}, | |
| url = {https://huggingface.co/MisterAI/Ptit_SLM_Poc03}, | |
| note = {Licence : **GNU AGPLv3**} | |
| } | |
| ``` | |
| --- |