Text Generation
Transformers
Safetensors
French
qwen3
continued-pretraining
knowledge-injection
anti-hallucination
refusal
safety
mon-espace-sante
conversational
text-generation-inference
Instructions to use fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination") model = AutoModelForCausalLM.from_pretrained("fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination
- SGLang
How to use fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination 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 "fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination" \ --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": "fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination", "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 "fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination" \ --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": "fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination with Docker Model Runner:
docker model run hf.co/fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination
Update internal links to L40S- prefixed repos
Browse files
README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
- fr
|
| 5 |
-
base_model: fenyo/Qwen3-8B-MonEspaceSante-CPT
|
| 6 |
pipeline_tag: text-generation
|
| 7 |
library_name: transformers
|
| 8 |
tags:
|
|
@@ -13,16 +13,16 @@ tags:
|
|
| 13 |
- safety
|
| 14 |
- mon-espace-sante
|
| 15 |
datasets:
|
| 16 |
-
- fenyo/MonEspaceSante-CPT-corpus
|
| 17 |
-
- fenyo/MonEspaceSante-SFT-dataset
|
| 18 |
-
- fenyo/MonEspaceSante-refusals
|
| 19 |
-
- fenyo/MonEspaceSante-eval-suite
|
| 20 |
---
|
| 21 |
|
| 22 |
# Qwen3-8B — Mon Espace Santé (CPT + SFT, **anti-hallucination**)
|
| 23 |
|
| 24 |
Variante **sûre pour un service public de santé** du modèle
|
| 25 |
-
[fenyo/Qwen3-8B-MonEspaceSante-CPT-SFT](https://huggingface.co/fenyo/Qwen3-8B-MonEspaceSante-CPT-SFT).
|
| 26 |
Elle **conserve la connaissance factuelle** (injectée par continued pre-training synthétique) **et apprend
|
| 27 |
à refuser** les questions hors-périmètre au lieu d'inventer.
|
| 28 |
|
|
@@ -36,7 +36,7 @@ Elle **conserve la connaissance factuelle** (injectée par continued pre-trainin
|
|
| 36 |
|
| 37 |
## 1. Comment on est passé du modèle précédent à celui-ci
|
| 38 |
|
| 39 |
-
Le modèle précédent ([…-CPT-SFT](https://huggingface.co/fenyo/Qwen3-8B-MonEspaceSante-CPT-SFT)) était
|
| 40 |
excellent en **factuel** (86,9 % closed-book) mais **hallucinait** sur les questions hors-périmètre : il
|
| 41 |
n'avait vu **que des positives** au SFT → il avait appris « réponds toujours » (refus correct ≈ 12,8 %).
|
| 42 |
|
|
@@ -44,9 +44,9 @@ n'avait vu **que des positives** au SFT → il avait appris « réponds toujours
|
|
| 44 |
(cf. Gekhman et al., arXiv:2405.05904). Il manquait donc des **exemples de refus** dans le SFT.
|
| 45 |
|
| 46 |
**La modification (une seule).** On repart du **même checkpoint CPT**
|
| 47 |
-
([fenyo/Qwen3-8B-MonEspaceSante-CPT](https://huggingface.co/fenyo/Qwen3-8B-MonEspaceSante-CPT), inchangé)
|
| 48 |
et on **ré-entraîne uniquement le SFT** en ajoutant aux 2 771 paires positives un jeu de **588 exemples
|
| 49 |
-
de refus** ([dataset](https://huggingface.co/datasets/fenyo/MonEspaceSante-refusals)) : des questions
|
| 50 |
hors-périmètre associées à une réponse « je ne dispose pas de cette information », **sans rien inventer**,
|
| 51 |
orientant vers les canaux officiels. Mélange final : **2 771 positives + 588 refus (≈ 18 %)**.
|
| 52 |
|
|
@@ -94,13 +94,13 @@ python gen_refusals.py --total 700 --max-batches 16 # → refusals.json
|
|
| 94 |
|
| 95 |
# ② SFT augmenté : 2771 positives + 588 refus, depuis le MÊME checkpoint CPT
|
| 96 |
python build_sft_aug.py --n 588 --out sft_ref588.jsonl
|
| 97 |
-
python sft_train.py --base fenyo/Qwen3-8B-MonEspaceSante-CPT --data sft_ref588.jsonl \
|
| 98 |
--tag 6M_ref588 --epochs 3 --lr 1e-5 --bs 1 --grad-accum 16 --max-len 2048 --optim paged_adamw_8bit
|
| 99 |
```
|
| 100 |
|
| 101 |
Hyperparamètres SFT identiques au modèle précédent (full FT, bf16, ChatML, **loss masquée sur le prompt**,
|
| 102 |
3 époques, LR 1e-5 cosine). Pour la génération du corpus CPT et les paramètres complets, voir le
|
| 103 |
-
[model card du modèle précédent](https://huggingface.co/fenyo/Qwen3-8B-MonEspaceSante-CPT-SFT).
|
| 104 |
Matériel : 1× NVIDIA L40S 48 Go.
|
| 105 |
|
| 106 |
---
|
|
@@ -110,7 +110,7 @@ Matériel : 1× NVIDIA L40S 48 Go.
|
|
| 110 |
```python
|
| 111 |
import torch
|
| 112 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 113 |
-
mid = "fenyo/Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination"
|
| 114 |
tok = AutoTokenizer.from_pretrained(mid)
|
| 115 |
model = AutoModelForCausalLM.from_pretrained(mid, dtype=torch.bfloat16).cuda().eval()
|
| 116 |
eos = [tok.eos_token_id, tok.convert_tokens_to_ids("<|im_end|>")] # terminaison ChatML
|
|
@@ -135,9 +135,9 @@ Entraîné **sans system prompt** (questions utilisateur seules).
|
|
| 135 |
- Domaine étroit (FAQ Mon espace santé). Hors périmètre, comportement de Qwen3-8B-Base.
|
| 136 |
|
| 137 |
## Modèles & datasets liés
|
| 138 |
-
- Base CPT : [fenyo/Qwen3-8B-MonEspaceSante-CPT](https://huggingface.co/fenyo/Qwen3-8B-MonEspaceSante-CPT)
|
| 139 |
-
- Modèle précédent (factuel max) : [fenyo/Qwen3-8B-MonEspaceSante-CPT-SFT](https://huggingface.co/fenyo/Qwen3-8B-MonEspaceSante-CPT-SFT)
|
| 140 |
-
- Datasets : [CPT-corpus](https://huggingface.co/datasets/fenyo/MonEspaceSante-CPT-corpus) ·
|
| 141 |
-
[SFT-dataset](https://huggingface.co/datasets/fenyo/MonEspaceSante-SFT-dataset) ·
|
| 142 |
-
[refusals](https://huggingface.co/datasets/fenyo/MonEspaceSante-refusals) ·
|
| 143 |
-
[eval-suite](https://huggingface.co/datasets/fenyo/MonEspaceSante-eval-suite)
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
- fr
|
| 5 |
+
base_model: fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT
|
| 6 |
pipeline_tag: text-generation
|
| 7 |
library_name: transformers
|
| 8 |
tags:
|
|
|
|
| 13 |
- safety
|
| 14 |
- mon-espace-sante
|
| 15 |
datasets:
|
| 16 |
+
- fenyo/L40S-MonEspaceSante-CPT-corpus
|
| 17 |
+
- fenyo/L40S-MonEspaceSante-SFT-dataset
|
| 18 |
+
- fenyo/L40S-MonEspaceSante-refusals
|
| 19 |
+
- fenyo/L40S-MonEspaceSante-eval-suite
|
| 20 |
---
|
| 21 |
|
| 22 |
# Qwen3-8B — Mon Espace Santé (CPT + SFT, **anti-hallucination**)
|
| 23 |
|
| 24 |
Variante **sûre pour un service public de santé** du modèle
|
| 25 |
+
[fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT](https://huggingface.co/fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT).
|
| 26 |
Elle **conserve la connaissance factuelle** (injectée par continued pre-training synthétique) **et apprend
|
| 27 |
à refuser** les questions hors-périmètre au lieu d'inventer.
|
| 28 |
|
|
|
|
| 36 |
|
| 37 |
## 1. Comment on est passé du modèle précédent à celui-ci
|
| 38 |
|
| 39 |
+
Le modèle précédent ([…-CPT-SFT](https://huggingface.co/fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT)) était
|
| 40 |
excellent en **factuel** (86,9 % closed-book) mais **hallucinait** sur les questions hors-périmètre : il
|
| 41 |
n'avait vu **que des positives** au SFT → il avait appris « réponds toujours » (refus correct ≈ 12,8 %).
|
| 42 |
|
|
|
|
| 44 |
(cf. Gekhman et al., arXiv:2405.05904). Il manquait donc des **exemples de refus** dans le SFT.
|
| 45 |
|
| 46 |
**La modification (une seule).** On repart du **même checkpoint CPT**
|
| 47 |
+
([fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT](https://huggingface.co/fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT), inchangé)
|
| 48 |
et on **ré-entraîne uniquement le SFT** en ajoutant aux 2 771 paires positives un jeu de **588 exemples
|
| 49 |
+
de refus** ([dataset](https://huggingface.co/datasets/fenyo/L40S-MonEspaceSante-refusals)) : des questions
|
| 50 |
hors-périmètre associées à une réponse « je ne dispose pas de cette information », **sans rien inventer**,
|
| 51 |
orientant vers les canaux officiels. Mélange final : **2 771 positives + 588 refus (≈ 18 %)**.
|
| 52 |
|
|
|
|
| 94 |
|
| 95 |
# ② SFT augmenté : 2771 positives + 588 refus, depuis le MÊME checkpoint CPT
|
| 96 |
python build_sft_aug.py --n 588 --out sft_ref588.jsonl
|
| 97 |
+
python sft_train.py --base fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT --data sft_ref588.jsonl \
|
| 98 |
--tag 6M_ref588 --epochs 3 --lr 1e-5 --bs 1 --grad-accum 16 --max-len 2048 --optim paged_adamw_8bit
|
| 99 |
```
|
| 100 |
|
| 101 |
Hyperparamètres SFT identiques au modèle précédent (full FT, bf16, ChatML, **loss masquée sur le prompt**,
|
| 102 |
3 époques, LR 1e-5 cosine). Pour la génération du corpus CPT et les paramètres complets, voir le
|
| 103 |
+
[model card du modèle précédent](https://huggingface.co/fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT).
|
| 104 |
Matériel : 1× NVIDIA L40S 48 Go.
|
| 105 |
|
| 106 |
---
|
|
|
|
| 110 |
```python
|
| 111 |
import torch
|
| 112 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 113 |
+
mid = "fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT-anti-hallucination"
|
| 114 |
tok = AutoTokenizer.from_pretrained(mid)
|
| 115 |
model = AutoModelForCausalLM.from_pretrained(mid, dtype=torch.bfloat16).cuda().eval()
|
| 116 |
eos = [tok.eos_token_id, tok.convert_tokens_to_ids("<|im_end|>")] # terminaison ChatML
|
|
|
|
| 135 |
- Domaine étroit (FAQ Mon espace santé). Hors périmètre, comportement de Qwen3-8B-Base.
|
| 136 |
|
| 137 |
## Modèles & datasets liés
|
| 138 |
+
- Base CPT : [fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT](https://huggingface.co/fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT)
|
| 139 |
+
- Modèle précédent (factuel max) : [fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT](https://huggingface.co/fenyo/L40S-Qwen3-8B-MonEspaceSante-CPT-SFT)
|
| 140 |
+
- Datasets : [CPT-corpus](https://huggingface.co/datasets/fenyo/L40S-MonEspaceSante-CPT-corpus) ·
|
| 141 |
+
[SFT-dataset](https://huggingface.co/datasets/fenyo/L40S-MonEspaceSante-SFT-dataset) ·
|
| 142 |
+
[refusals](https://huggingface.co/datasets/fenyo/L40S-MonEspaceSante-refusals) ·
|
| 143 |
+
[eval-suite](https://huggingface.co/datasets/fenyo/L40S-MonEspaceSante-eval-suite)
|