Instructions to use VincentMORHET/Healthbot with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use VincentMORHET/Healthbot with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.6-35B-A3B") model = PeftModel.from_pretrained(base_model, "VincentMORHET/Healthbot") - Notebooks
- Google Colab
- Kaggle
Vincent MORHET Claude Opus 5.5 commited on
Commit ·
ba3cb64
1
Parent(s): e5ca826
Adaptateur LoRA HealthBot (v16, point 8) et fiche du modèle
Browse filesCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A8SHcBVeP6PEwcVLCXzjzB
- .gitattributes +1 -0
- README.md +67 -0
- adapter_config.json +79 -0
- adapter_model.safetensors +3 -0
- chat_template.jinja +158 -0
- tokenizer.json +3 -0
- tokenizer_config.json +337 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: Qwen/Qwen3.6-35B-A3B
|
| 3 |
+
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
language:
|
| 6 |
+
- fr
|
| 7 |
+
tags:
|
| 8 |
+
- lora
|
| 9 |
+
- peft
|
| 10 |
+
- rag
|
| 11 |
+
- medical
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# HealthBot : adaptateur LoRA de Qwen3.6-35B-A3B pour un assistant d'information en santé (prototype de recherche)
|
| 15 |
+
|
| 16 |
+
Adaptateur LoRA (rang 32, alpha 64) du modèle [Qwen/Qwen3.6-35B-A3B](https://huggingface.co/Qwen/Qwen3.6-35B-A3B),
|
| 17 |
+
entraîné pour répondre en français à des questions de santé à partir d'extraits de recommandations officielles
|
| 18 |
+
françaises (HAS, ANSM, Assurance Maladie, vaccination-info-service, SFMU), retrouvés par une recherche documentaire,
|
| 19 |
+
et pour indiquer un seul niveau d'orientation.
|
| 20 |
+
|
| 21 |
+
Le code du site et de la chaîne de recherche est sur GitHub :
|
| 22 |
+
[VincentMorhet/HealthBot](https://github.com/VincentMorhet/HealthBot).
|
| 23 |
+
|
| 24 |
+
> **Avertissement.** Prototype de recherche. Ce modèle ne pose pas de diagnostic et ne remplace pas l'avis d'un
|
| 25 |
+
> professionnel de santé. Ce n'est pas un dispositif médical. En cas d'urgence : 15, 112, ou 114 par SMS.
|
| 26 |
+
|
| 27 |
+
## Usage prévu
|
| 28 |
+
|
| 29 |
+
- Avec la recherche documentaire du dépôt GitHub (outil `rechercher_documents`, 6 extraits, 2 par document au plus),
|
| 30 |
+
la consigne système de `configs/policy_agent.md`, température 0 et sans raisonnement (`enable_thinking: false`).
|
| 31 |
+
Le modèle a été entraîné avec cette consigne et ce format : utilisé sans eux, il n'a pas été évalué.
|
| 32 |
+
- Format de réponse : **Orientation**, **Conduite à tenir**, **Points de vigilance ou questions à poser**,
|
| 33 |
+
**Prévention**, **Rappel** ; ou trois titres pour une question d'information.
|
| 34 |
+
- Niveaux d'orientation : « Appeler le 15 immédiatement », « Aller aux urgences sans attendre », « Consulter un
|
| 35 |
+
médecin dans les 24 heures », « Prendre rendez-vous avec son médecin », « Autosoins, avec conseil du pharmacien si
|
| 36 |
+
besoin ».
|
| 37 |
+
|
| 38 |
+
## Entraînement
|
| 39 |
+
|
| 40 |
+
- Données synthétiques : questions et réponses de référence produites par des modèles hébergés sur OVHcloud AI
|
| 41 |
+
Endpoints à partir des documents officiels, filtrées par règles (format, orientation, chiffres et noms soutenus par
|
| 42 |
+
les extraits). Aucune donnée de patient réel.
|
| 43 |
+
- Affinage supervisé sur des parcours de recherche et de réponse, puis plusieurs passes d'optimisation par
|
| 44 |
+
préférences (DPO avec un terme de vraisemblance sur les réponses retenues). Cette version est le point 8 de la
|
| 45 |
+
dernière passe, qui visait des réponses plus concises.
|
| 46 |
+
- QLoRA, modèle de base quantifié en 4 bits, sur un NVIDIA DGX Spark.
|
| 47 |
+
|
| 48 |
+
## Résultats et limites
|
| 49 |
+
|
| 50 |
+
- Sur un jeu de 243 questions écrites sur des documents jamais vus à l'entraînement, ce modèle manque 4 des 77 urgences,
|
| 51 |
+
avec des réponses de 294 mots et 13 secondes en médiane (modèle fusionné, FP8, vLLM sur DGX Spark).
|
| 52 |
+
- Le modèle gradue peu ses orientations : il rend rarement « dans les 24 heures », presque jamais « autosoins », et un
|
| 53 |
+
rendez-vous sur cinq est demandé « rapidement », sans délai précis.
|
| 54 |
+
- Les étiquettes d'orientation des jeux d'évaluation ont été écrites par des modèles, et une partie est discutable.
|
| 55 |
+
Aucune relecture par un clinicien n'a encore été faite.
|
| 56 |
+
|
| 57 |
+
## Utilisation avec vLLM
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
vllm serve Qwen/Qwen3.6-35B-A3B --enable-lora --max-lora-rank 32 \
|
| 61 |
+
--lora-modules healthbot=VincentMORHET/Healthbot \
|
| 62 |
+
--reasoning-parser qwen3 --enable-auto-tool-choice --tool-call-parser qwen3_coder \
|
| 63 |
+
--language-model-only --max-model-len 32768
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
Puis appeler le modèle `healthbot` avec la consigne et l'outil du dépôt GitHub. Le modèle de base est publié par
|
| 67 |
+
Qwen sous licence Apache 2.0.
|
adapter_config.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": {
|
| 6 |
+
"base_model_class": "Qwen3_5MoeForConditionalGeneration",
|
| 7 |
+
"parent_library": "transformers.models.qwen3_5_moe.modeling_qwen3_5_moe",
|
| 8 |
+
"unsloth_fixed": true,
|
| 9 |
+
"unsloth_fused_expert_lora": {
|
| 10 |
+
"lora_A_layout": "grouped_by_expert",
|
| 11 |
+
"lora_B_layout": "rank_major",
|
| 12 |
+
"parameters": {
|
| 13 |
+
"down_proj": {
|
| 14 |
+
"lora_B_layout": "rank_major",
|
| 15 |
+
"num_experts": 256
|
| 16 |
+
},
|
| 17 |
+
"gate_up_proj": {
|
| 18 |
+
"lora_B_layout": "rank_major",
|
| 19 |
+
"num_experts": 256
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
},
|
| 24 |
+
"base_model_name_or_path": "Qwen/Qwen3.6-35B-A3B",
|
| 25 |
+
"bias": "none",
|
| 26 |
+
"corda_config": null,
|
| 27 |
+
"ensure_weight_tying": false,
|
| 28 |
+
"eva_config": null,
|
| 29 |
+
"exclude_modules": null,
|
| 30 |
+
"fan_in_fan_out": false,
|
| 31 |
+
"inference_mode": true,
|
| 32 |
+
"init_lora_weights": true,
|
| 33 |
+
"kasa_config": null,
|
| 34 |
+
"layer_replication": null,
|
| 35 |
+
"layers_pattern": null,
|
| 36 |
+
"layers_to_transform": null,
|
| 37 |
+
"loftq_config": {},
|
| 38 |
+
"lora_B_layout": "rank_major",
|
| 39 |
+
"lora_alpha": 64,
|
| 40 |
+
"lora_bias": false,
|
| 41 |
+
"lora_dropout": 0.0,
|
| 42 |
+
"lora_ga_config": null,
|
| 43 |
+
"megatron_config": null,
|
| 44 |
+
"megatron_core": "megatron.core",
|
| 45 |
+
"modules_to_save": null,
|
| 46 |
+
"monteclora_config": null,
|
| 47 |
+
"peft_type": "LORA",
|
| 48 |
+
"peft_version": "0.21.2",
|
| 49 |
+
"qalora_group_size": 16,
|
| 50 |
+
"r": 32,
|
| 51 |
+
"rank_pattern": {},
|
| 52 |
+
"revision": null,
|
| 53 |
+
"target_modules": "(?:model\\.language_model\\.layers\\.\\d+\\.linear_attn\\.in_proj_a|model\\.language_model\\.layers\\.\\d+\\.linear_attn\\.in_proj_b|model\\.language_model\\.layers\\.\\d+\\.linear_attn\\.in_proj_qkv|model\\.language_model\\.layers\\.\\d+\\.linear_attn\\.in_proj_z|model\\.language_model\\.layers\\.\\d+\\.linear_attn\\.out_proj|model\\.language_model\\.layers\\.\\d+\\.mlp\\.shared_expert\\.down_proj|model\\.language_model\\.layers\\.\\d+\\.mlp\\.shared_expert\\.gate_proj|model\\.language_model\\.layers\\.\\d+\\.mlp\\.shared_expert\\.up_proj|model\\.language_model\\.layers\\.\\d+\\.mlp\\.shared_expert_gate|model\\.language_model\\.layers\\.\\d+\\.self_attn\\.k_proj|model\\.language_model\\.layers\\.\\d+\\.self_attn\\.o_proj|model\\.language_model\\.layers\\.\\d+\\.self_attn\\.q_proj|model\\.language_model\\.layers\\.\\d+\\.self_attn\\.v_proj)",
|
| 54 |
+
"target_parameters": [
|
| 55 |
+
"mlp.experts.gate_up_proj",
|
| 56 |
+
"mlp.experts.down_proj"
|
| 57 |
+
],
|
| 58 |
+
"task_type": "CAUSAL_LM",
|
| 59 |
+
"trainable_token_indices": null,
|
| 60 |
+
"unsloth_fused_expert_lora": {
|
| 61 |
+
"lora_A_layout": "grouped_by_expert",
|
| 62 |
+
"lora_B_layout": "rank_major",
|
| 63 |
+
"parameters": {
|
| 64 |
+
"down_proj": {
|
| 65 |
+
"lora_B_layout": "rank_major",
|
| 66 |
+
"num_experts": 256
|
| 67 |
+
},
|
| 68 |
+
"gate_up_proj": {
|
| 69 |
+
"lora_B_layout": "rank_major",
|
| 70 |
+
"num_experts": 256
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"use_bdlora": null,
|
| 75 |
+
"use_dora": false,
|
| 76 |
+
"use_qalora": false,
|
| 77 |
+
"use_rslora": false,
|
| 78 |
+
"velora_config": null
|
| 79 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set image_count = namespace(value=0) %}
|
| 2 |
+
{%- set video_count = namespace(value=0) %}
|
| 3 |
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 4 |
+
{%- if content is string %}
|
| 5 |
+
{{- content }}
|
| 6 |
+
{%- elif content is iterable and content is not mapping %}
|
| 7 |
+
{%- for item in content %}
|
| 8 |
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
|
| 9 |
+
{%- if is_system_content %}
|
| 10 |
+
{{- raise_exception('System message cannot contain images.') }}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{%- if do_vision_count %}
|
| 13 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- if add_vision_id %}
|
| 16 |
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 19 |
+
{%- elif 'video' in item or item.type == 'video' %}
|
| 20 |
+
{%- if is_system_content %}
|
| 21 |
+
{{- raise_exception('System message cannot contain videos.') }}
|
| 22 |
+
{%- endif %}
|
| 23 |
+
{%- if do_vision_count %}
|
| 24 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 25 |
+
{%- endif %}
|
| 26 |
+
{%- if add_vision_id %}
|
| 27 |
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 30 |
+
{%- elif 'text' in item %}
|
| 31 |
+
{{- item.text }}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{{- raise_exception('Unexpected item type in content.') }}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- endfor %}
|
| 36 |
+
{%- elif content is none or content is undefined %}
|
| 37 |
+
{{- '' }}
|
| 38 |
+
{%- else %}
|
| 39 |
+
{{- raise_exception('Unexpected content type.') }}
|
| 40 |
+
{%- endif %}
|
| 41 |
+
{%- endmacro %}
|
| 42 |
+
{%- if not messages %}
|
| 43 |
+
{{- raise_exception('No messages provided.') }}
|
| 44 |
+
{%- endif %}
|
| 45 |
+
{%- if tools and tools is iterable and tools is not mapping %}
|
| 46 |
+
{{- '<|im_start|>system\n' }}
|
| 47 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 48 |
+
{%- for tool in tools %}
|
| 49 |
+
{{- "\n" }}
|
| 50 |
+
{{- tool | tojson }}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{{- "\n</tools>" }}
|
| 53 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 54 |
+
{%- if messages[0].role == 'system' %}
|
| 55 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 56 |
+
{%- if content %}
|
| 57 |
+
{{- '\n\n' + content }}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endif %}
|
| 60 |
+
{{- '<|im_end|>\n' }}
|
| 61 |
+
{%- else %}
|
| 62 |
+
{%- if messages[0].role == 'system' %}
|
| 63 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 64 |
+
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
{%- endif %}
|
| 67 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 68 |
+
{%- for message in messages[::-1] %}
|
| 69 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 70 |
+
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 71 |
+
{%- set content = render_content(message.content, false)|trim %}
|
| 72 |
+
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 73 |
+
{%- set ns.multi_step_tool = false %}
|
| 74 |
+
{%- set ns.last_query_index = index %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endif %}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- if ns.multi_step_tool %}
|
| 79 |
+
{{- raise_exception('No user query found in messages.') }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{%- for message in messages %}
|
| 82 |
+
{%- set content = render_content(message.content, true)|trim %}
|
| 83 |
+
{%- if message.role == "system" %}
|
| 84 |
+
{%- if not loop.first %}
|
| 85 |
+
{{- raise_exception('System message must be at the beginning.') }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
{%- elif message.role == "user" %}
|
| 88 |
+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 89 |
+
{%- elif message.role == "assistant" %}
|
| 90 |
+
{%- set reasoning_content = '' %}
|
| 91 |
+
{%- if message.reasoning_content is string %}
|
| 92 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- if '</think>' in content %}
|
| 95 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 96 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- set reasoning_content = reasoning_content|trim %}
|
| 100 |
+
{{- '<|im_start|>' + message.role + '\n' }}
|
| 101 |
+
{%- generation %}
|
| 102 |
+
{%- if (preserve_thinking is defined and preserve_thinking is true) or (loop.index0 > ns.last_query_index) %}
|
| 103 |
+
{{- '<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 104 |
+
{%- else %}
|
| 105 |
+
{{- content }}
|
| 106 |
+
{%- endif %}
|
| 107 |
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 108 |
+
{%- for tool_call in message.tool_calls %}
|
| 109 |
+
{%- if tool_call.function is defined %}
|
| 110 |
+
{%- set tool_call = tool_call.function %}
|
| 111 |
+
{%- endif %}
|
| 112 |
+
{%- if loop.first %}
|
| 113 |
+
{%- if content|trim %}
|
| 114 |
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 115 |
+
{%- else %}
|
| 116 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 117 |
+
{%- endif %}
|
| 118 |
+
{%- else %}
|
| 119 |
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 120 |
+
{%- endif %}
|
| 121 |
+
{%- if tool_call.arguments is defined %}
|
| 122 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 123 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 124 |
+
{%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}
|
| 125 |
+
{{- args_value }}
|
| 126 |
+
{{- '\n</parameter>\n' }}
|
| 127 |
+
{%- endfor %}
|
| 128 |
+
{%- endif %}
|
| 129 |
+
{{- '</function>\n</tool_call>' }}
|
| 130 |
+
{%- endfor %}
|
| 131 |
+
{%- endif %}
|
| 132 |
+
{{- '<|im_end|>' }}
|
| 133 |
+
{%- endgeneration %}
|
| 134 |
+
{{- '\n' }}
|
| 135 |
+
{%- elif message.role == "tool" %}
|
| 136 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 137 |
+
{{- '<|im_start|>user' }}
|
| 138 |
+
{%- endif %}
|
| 139 |
+
{{- '\n<tool_response>\n' }}
|
| 140 |
+
{{- content }}
|
| 141 |
+
{{- '\n</tool_response>' }}
|
| 142 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 143 |
+
{{- '<|im_end|>\n' }}
|
| 144 |
+
{%- elif loop.last %}
|
| 145 |
+
{{- '<|im_end|>\n' }}
|
| 146 |
+
{%- endif %}
|
| 147 |
+
{%- else %}
|
| 148 |
+
{{- raise_exception('Unexpected message role.') }}
|
| 149 |
+
{%- endif %}
|
| 150 |
+
{%- endfor %}
|
| 151 |
+
{%- if add_generation_prompt %}
|
| 152 |
+
{{- '<|im_start|>assistant\n' }}
|
| 153 |
+
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 154 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 155 |
+
{%- else %}
|
| 156 |
+
{{- '<think>\n' }}
|
| 157 |
+
{%- endif %}
|
| 158 |
+
{%- endif %}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
|
| 3 |
+
size 19989325
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"image_token": "<|image_pad|>",
|
| 12 |
+
"is_local": false,
|
| 13 |
+
"local_files_only": true,
|
| 14 |
+
"model_max_length": 262144,
|
| 15 |
+
"model_specific_special_tokens": {
|
| 16 |
+
"audio_bos_token": "<|audio_start|>",
|
| 17 |
+
"audio_eos_token": "<|audio_end|>",
|
| 18 |
+
"audio_token": "<|audio_pad|>",
|
| 19 |
+
"image_token": "<|image_pad|>",
|
| 20 |
+
"video_token": "<|video_pad|>",
|
| 21 |
+
"vision_bos_token": "<|vision_start|>",
|
| 22 |
+
"vision_eos_token": "<|vision_end|>"
|
| 23 |
+
},
|
| 24 |
+
"pad_token": "<|endoftext|>",
|
| 25 |
+
"padding_side": "left",
|
| 26 |
+
"pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
| 27 |
+
"response_template": {
|
| 28 |
+
"defaults": {
|
| 29 |
+
"role": "assistant"
|
| 30 |
+
},
|
| 31 |
+
"fields": {
|
| 32 |
+
"content": {
|
| 33 |
+
"close": [
|
| 34 |
+
"<|im_end|>",
|
| 35 |
+
"<|endoftext|>"
|
| 36 |
+
],
|
| 37 |
+
"content": "text",
|
| 38 |
+
"join": "",
|
| 39 |
+
"repeats": true
|
| 40 |
+
},
|
| 41 |
+
"reasoning_content": {
|
| 42 |
+
"close_pattern": "</think>|(?=<tool_call>)",
|
| 43 |
+
"content": "text",
|
| 44 |
+
"open": "<think>"
|
| 45 |
+
},
|
| 46 |
+
"tool_calls": {
|
| 47 |
+
"close_pattern": "</tool_call>|(?=<tool_call>)",
|
| 48 |
+
"content": "xml-inline",
|
| 49 |
+
"content_args": {
|
| 50 |
+
"tag_pattern": "<parameter=(?P<key>[^>\\n]+)>\\n?(?P<value>.*?)\\n?(?:</parameter>|(?=<parameter=)|(?=</function>))"
|
| 51 |
+
},
|
| 52 |
+
"open_pattern": "<tool_call>\\s*<function=(?P<name>[^>\\n]+)>",
|
| 53 |
+
"repeats": true,
|
| 54 |
+
"transform": {
|
| 55 |
+
"function": {
|
| 56 |
+
"arguments": "{content}",
|
| 57 |
+
"name": "{name}"
|
| 58 |
+
},
|
| 59 |
+
"type": "function"
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
},
|
| 63 |
+
"start_anchor": "<|im_start|>assistant\n"
|
| 64 |
+
},
|
| 65 |
+
"split_special_tokens": false,
|
| 66 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 67 |
+
"unk_token": null,
|
| 68 |
+
"video_token": "<|video_pad|>",
|
| 69 |
+
"vision_bos_token": "<|vision_start|>",
|
| 70 |
+
"vision_eos_token": "<|vision_end|>",
|
| 71 |
+
"added_tokens_decoder": {
|
| 72 |
+
"248044": {
|
| 73 |
+
"content": "<|endoftext|>",
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"lstrip": false,
|
| 76 |
+
"rstrip": false,
|
| 77 |
+
"normalized": false,
|
| 78 |
+
"special": true
|
| 79 |
+
},
|
| 80 |
+
"248045": {
|
| 81 |
+
"content": "<|im_start|>",
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"lstrip": false,
|
| 84 |
+
"rstrip": false,
|
| 85 |
+
"normalized": false,
|
| 86 |
+
"special": true
|
| 87 |
+
},
|
| 88 |
+
"248046": {
|
| 89 |
+
"content": "<|im_end|>",
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"lstrip": false,
|
| 92 |
+
"rstrip": false,
|
| 93 |
+
"normalized": false,
|
| 94 |
+
"special": true
|
| 95 |
+
},
|
| 96 |
+
"248047": {
|
| 97 |
+
"content": "<|object_ref_start|>",
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"lstrip": false,
|
| 100 |
+
"rstrip": false,
|
| 101 |
+
"normalized": false,
|
| 102 |
+
"special": true
|
| 103 |
+
},
|
| 104 |
+
"248048": {
|
| 105 |
+
"content": "<|object_ref_end|>",
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"lstrip": false,
|
| 108 |
+
"rstrip": false,
|
| 109 |
+
"normalized": false,
|
| 110 |
+
"special": true
|
| 111 |
+
},
|
| 112 |
+
"248049": {
|
| 113 |
+
"content": "<|box_start|>",
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"lstrip": false,
|
| 116 |
+
"rstrip": false,
|
| 117 |
+
"normalized": false,
|
| 118 |
+
"special": true
|
| 119 |
+
},
|
| 120 |
+
"248050": {
|
| 121 |
+
"content": "<|box_end|>",
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"lstrip": false,
|
| 124 |
+
"rstrip": false,
|
| 125 |
+
"normalized": false,
|
| 126 |
+
"special": true
|
| 127 |
+
},
|
| 128 |
+
"248051": {
|
| 129 |
+
"content": "<|quad_start|>",
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"lstrip": false,
|
| 132 |
+
"rstrip": false,
|
| 133 |
+
"normalized": false,
|
| 134 |
+
"special": true
|
| 135 |
+
},
|
| 136 |
+
"248052": {
|
| 137 |
+
"content": "<|quad_end|>",
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"lstrip": false,
|
| 140 |
+
"rstrip": false,
|
| 141 |
+
"normalized": false,
|
| 142 |
+
"special": true
|
| 143 |
+
},
|
| 144 |
+
"248053": {
|
| 145 |
+
"content": "<|vision_start|>",
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"lstrip": false,
|
| 148 |
+
"rstrip": false,
|
| 149 |
+
"normalized": false,
|
| 150 |
+
"special": true
|
| 151 |
+
},
|
| 152 |
+
"248054": {
|
| 153 |
+
"content": "<|vision_end|>",
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"lstrip": false,
|
| 156 |
+
"rstrip": false,
|
| 157 |
+
"normalized": false,
|
| 158 |
+
"special": true
|
| 159 |
+
},
|
| 160 |
+
"248055": {
|
| 161 |
+
"content": "<|vision_pad|>",
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"lstrip": false,
|
| 164 |
+
"rstrip": false,
|
| 165 |
+
"normalized": false,
|
| 166 |
+
"special": true
|
| 167 |
+
},
|
| 168 |
+
"248056": {
|
| 169 |
+
"content": "<|image_pad|>",
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"lstrip": false,
|
| 172 |
+
"rstrip": false,
|
| 173 |
+
"normalized": false,
|
| 174 |
+
"special": true
|
| 175 |
+
},
|
| 176 |
+
"248057": {
|
| 177 |
+
"content": "<|video_pad|>",
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"lstrip": false,
|
| 180 |
+
"rstrip": false,
|
| 181 |
+
"normalized": false,
|
| 182 |
+
"special": true
|
| 183 |
+
},
|
| 184 |
+
"248058": {
|
| 185 |
+
"content": "<tool_call>",
|
| 186 |
+
"single_word": false,
|
| 187 |
+
"lstrip": false,
|
| 188 |
+
"rstrip": false,
|
| 189 |
+
"normalized": false,
|
| 190 |
+
"special": false
|
| 191 |
+
},
|
| 192 |
+
"248059": {
|
| 193 |
+
"content": "</tool_call>",
|
| 194 |
+
"single_word": false,
|
| 195 |
+
"lstrip": false,
|
| 196 |
+
"rstrip": false,
|
| 197 |
+
"normalized": false,
|
| 198 |
+
"special": false
|
| 199 |
+
},
|
| 200 |
+
"248060": {
|
| 201 |
+
"content": "<|fim_prefix|>",
|
| 202 |
+
"single_word": false,
|
| 203 |
+
"lstrip": false,
|
| 204 |
+
"rstrip": false,
|
| 205 |
+
"normalized": false,
|
| 206 |
+
"special": false
|
| 207 |
+
},
|
| 208 |
+
"248061": {
|
| 209 |
+
"content": "<|fim_middle|>",
|
| 210 |
+
"single_word": false,
|
| 211 |
+
"lstrip": false,
|
| 212 |
+
"rstrip": false,
|
| 213 |
+
"normalized": false,
|
| 214 |
+
"special": false
|
| 215 |
+
},
|
| 216 |
+
"248062": {
|
| 217 |
+
"content": "<|fim_suffix|>",
|
| 218 |
+
"single_word": false,
|
| 219 |
+
"lstrip": false,
|
| 220 |
+
"rstrip": false,
|
| 221 |
+
"normalized": false,
|
| 222 |
+
"special": false
|
| 223 |
+
},
|
| 224 |
+
"248063": {
|
| 225 |
+
"content": "<|fim_pad|>",
|
| 226 |
+
"single_word": false,
|
| 227 |
+
"lstrip": false,
|
| 228 |
+
"rstrip": false,
|
| 229 |
+
"normalized": false,
|
| 230 |
+
"special": false
|
| 231 |
+
},
|
| 232 |
+
"248064": {
|
| 233 |
+
"content": "<|repo_name|>",
|
| 234 |
+
"single_word": false,
|
| 235 |
+
"lstrip": false,
|
| 236 |
+
"rstrip": false,
|
| 237 |
+
"normalized": false,
|
| 238 |
+
"special": false
|
| 239 |
+
},
|
| 240 |
+
"248065": {
|
| 241 |
+
"content": "<|file_sep|>",
|
| 242 |
+
"single_word": false,
|
| 243 |
+
"lstrip": false,
|
| 244 |
+
"rstrip": false,
|
| 245 |
+
"normalized": false,
|
| 246 |
+
"special": false
|
| 247 |
+
},
|
| 248 |
+
"248066": {
|
| 249 |
+
"content": "<tool_response>",
|
| 250 |
+
"single_word": false,
|
| 251 |
+
"lstrip": false,
|
| 252 |
+
"rstrip": false,
|
| 253 |
+
"normalized": false,
|
| 254 |
+
"special": false
|
| 255 |
+
},
|
| 256 |
+
"248067": {
|
| 257 |
+
"content": "</tool_response>",
|
| 258 |
+
"single_word": false,
|
| 259 |
+
"lstrip": false,
|
| 260 |
+
"rstrip": false,
|
| 261 |
+
"normalized": false,
|
| 262 |
+
"special": false
|
| 263 |
+
},
|
| 264 |
+
"248068": {
|
| 265 |
+
"content": "<think>",
|
| 266 |
+
"single_word": false,
|
| 267 |
+
"lstrip": false,
|
| 268 |
+
"rstrip": false,
|
| 269 |
+
"normalized": false,
|
| 270 |
+
"special": false
|
| 271 |
+
},
|
| 272 |
+
"248069": {
|
| 273 |
+
"content": "</think>",
|
| 274 |
+
"single_word": false,
|
| 275 |
+
"lstrip": false,
|
| 276 |
+
"rstrip": false,
|
| 277 |
+
"normalized": false,
|
| 278 |
+
"special": false
|
| 279 |
+
},
|
| 280 |
+
"248070": {
|
| 281 |
+
"content": "<|audio_start|>",
|
| 282 |
+
"single_word": false,
|
| 283 |
+
"lstrip": false,
|
| 284 |
+
"rstrip": false,
|
| 285 |
+
"normalized": false,
|
| 286 |
+
"special": true
|
| 287 |
+
},
|
| 288 |
+
"248071": {
|
| 289 |
+
"content": "<|audio_end|>",
|
| 290 |
+
"single_word": false,
|
| 291 |
+
"lstrip": false,
|
| 292 |
+
"rstrip": false,
|
| 293 |
+
"normalized": false,
|
| 294 |
+
"special": true
|
| 295 |
+
},
|
| 296 |
+
"248072": {
|
| 297 |
+
"content": "<tts_pad>",
|
| 298 |
+
"single_word": false,
|
| 299 |
+
"lstrip": false,
|
| 300 |
+
"rstrip": false,
|
| 301 |
+
"normalized": false,
|
| 302 |
+
"special": true
|
| 303 |
+
},
|
| 304 |
+
"248073": {
|
| 305 |
+
"content": "<tts_text_bos>",
|
| 306 |
+
"single_word": false,
|
| 307 |
+
"lstrip": false,
|
| 308 |
+
"rstrip": false,
|
| 309 |
+
"normalized": false,
|
| 310 |
+
"special": true
|
| 311 |
+
},
|
| 312 |
+
"248074": {
|
| 313 |
+
"content": "<tts_text_eod>",
|
| 314 |
+
"single_word": false,
|
| 315 |
+
"lstrip": false,
|
| 316 |
+
"rstrip": false,
|
| 317 |
+
"normalized": false,
|
| 318 |
+
"special": true
|
| 319 |
+
},
|
| 320 |
+
"248075": {
|
| 321 |
+
"content": "<tts_text_bos_single>",
|
| 322 |
+
"single_word": false,
|
| 323 |
+
"lstrip": false,
|
| 324 |
+
"rstrip": false,
|
| 325 |
+
"normalized": false,
|
| 326 |
+
"special": true
|
| 327 |
+
},
|
| 328 |
+
"248076": {
|
| 329 |
+
"content": "<|audio_pad|>",
|
| 330 |
+
"single_word": false,
|
| 331 |
+
"lstrip": false,
|
| 332 |
+
"rstrip": false,
|
| 333 |
+
"normalized": false,
|
| 334 |
+
"special": true
|
| 335 |
+
}
|
| 336 |
+
}
|
| 337 |
+
}
|