From 70125581a98fcbd38b998e7f3d6564125c2f3698 Mon Sep 17 00:00:00 2001 From: ModelHub XC Date: Thu, 7 May 2026 10:33:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=EF=BC=8C=E7=94=B1ModelHub=20XC=E7=A4=BE=E5=8C=BA=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Model: Ayansk11/FinSenti-Qwen3-1.7B Source: Original Platform --- .gitattributes | 36 +++++++ README.md | 227 ++++++++++++++++++++++++++++++++++++++++++ chat_template.jinja | 97 ++++++++++++++++++ config.json | 64 ++++++++++++ model.safetensors | 3 + tokenizer.json | 3 + tokenizer_config.json | 16 +++ 7 files changed, 446 insertions(+) create mode 100644 .gitattributes create mode 100644 README.md create mode 100644 chat_template.jinja create mode 100644 config.json create mode 100644 model.safetensors create mode 100644 tokenizer.json create mode 100644 tokenizer_config.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..52373fe --- /dev/null +++ b/.gitattributes @@ -0,0 +1,36 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +tokenizer.json filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md new file mode 100644 index 0000000..a2adcda --- /dev/null +++ b/README.md @@ -0,0 +1,227 @@ +--- +license: apache-2.0 +language: + - en +base_model: Qwen/Qwen3-1.7B +datasets: + - Ayansk11/FinSenti-Dataset +pipeline_tag: text-generation +library_name: transformers +tags: + - finance + - financial-sentiment + - sentiment-analysis + - chain-of-thought + - reasoning + - grpo + - sft + - lora + - finsenti +--- +# FinSenti-Qwen3-1.7B + +FinSenti-Qwen3-1.7B is a 1.7B-parameter model fine-tuned to +read short financial text (headlines, earnings snippets, market commentary) +and explain its read of them before settling on positive, negative, or +neutral. It's a useful middle size: small enough to load on a 6 GB laptop GPU, big enough that the reasoning stays coherent on tricky headlines. + +The model is part of the [FinSenti +collection](https://huggingface.co/collections/Ayansk11/finsenti), a +scaling study of small models trained on the same data with the same recipe. + +## What it's good at + +- Classifying short financial text (1-3 sentences) into positive / negative + / neutral +- Producing a short reasoning chain you can read or log +- Following a strict `......` output + format that's easy to parse downstream + +It was trained on news-style headlines and earnings snippets in English, so +that's where it shines. Outside that domain you'll see the format hold up +but the labels get noisier. + +## How it was trained + +Two-stage recipe, same across the whole FinSenti family: + +1. **SFT** on the SFT train slice from the [FinSenti + dataset](https://huggingface.co/datasets/Ayansk11/FinSenti-Dataset) + (~15.2K balanced training samples, drawn from a + 50.8K-sample pool with held-out val/test splits, chain-of-thought + targets generated by a teacher model and filtered for label agreement). + This stage took about 0.8 hours on a single A100 80GB + for this model. +2. **GRPO** with four reward functions (sentiment correctness, format + compliance, reasoning quality, output consistency), each weighted equally + for a maximum reward of 4.0. The training budget was 3000 + steps with early stopping; the best checkpoint landed near step + ~300 with a mean reward of approximately + **3.71 / 4.0** on the validation slice. + +Trainer stack: Unsloth + TRL, using Unsloth's pre-quantized mirror +[`unsloth/Qwen3-1.7B`](https://huggingface.co/unsloth/Qwen3-1.7B) as the +loading shortcut for the upstream +[`Qwen/Qwen3-1.7B`](https://huggingface.co/Qwen/Qwen3-1.7B) +weights. LoRA adapters (r=32, alpha=64) were +trained on the attention and MLP projection layers, then merged into the +base weights before export, so this repo is a self-contained model and +doesn't need PEFT to load. + +## Quick start + +Standard `transformers` usage: + +```python +from transformers import AutoModelForCausalLM, AutoTokenizer +import torch + +model_id = "Ayansk11/FinSenti-Qwen3-1.7B" +tok = AutoTokenizer.from_pretrained(model_id) +model = AutoModelForCausalLM.from_pretrained( + model_id, torch_dtype=torch.bfloat16, device_map="auto" +) + +system = ( + "You are a financial sentiment analyst. For each headline you receive, " + "write a short reasoning chain inside ... tags, " + "then give a single label inside ... tags. The label " + "must be exactly one of: positive, negative, neutral." +) +user = "Apple beats Q4 estimates as iPhone sales jump 12% year over year." + +messages = [ + {"role": "system", "content": system}, + {"role": "user", "content": user}, +] +prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) + +inputs = tok(prompt, return_tensors="pt").to(model.device) +out = model.generate(**inputs, max_new_tokens=256, do_sample=False) +print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)) +``` + +Expected output (your reasoning text will vary; the label should match): + +``` + +Beating estimates is a positive earnings surprise. A 12% YoY iPhone sales jump in the company's biggest product line points to demand strength. Both signals push the read positive. + +positive +``` + +## Prompt format + +The model expects the system prompt above, verbatim is best. The user turn +is the headline or short snippet you want classified. Output is two XML-ish +blocks in this order: `...` then +`...`. The `` content is one of `positive`, +`negative`, or `neutral` (lowercase, no punctuation). + +If you want labels only and don't care about the reasoning, you can stop +generation as soon as you see `` to save tokens. + +## Performance notes + +The training reward (max 4.0) hit **3.71** on the +held-out validation slice. That breaks down across the four reward +functions roughly as: + +- Sentiment correctness: dominant contributor; the model gets the label + right on the validation split most of the time +- Format compliance: near-saturated by the end of GRPO; the model almost + always produces well-formed `` and `` tags +- Reasoning quality: judged on length and presence of finance-relevant + signal words; this one's the noisiest of the four +- Consistency: rewards stable labels across paraphrases of the same headline + +Numbers on standard finance benchmarks (FPB, FiQA, Twitter Financial News) +are forthcoming and will be added once the eval pipeline lands. + +## Hardware + +bf16 weights are about 3.4 GB. You want ~4 GB of VRAM for batch=1 inference. CPU works but is slower; the Q4_K_M GGUF is the right pick if you don't have a GPU. + +## Limitations + +A few things this model isn't built for: + +- **Long documents.** Training context was capped at 2048 + tokens. Anything much longer than a few paragraphs is out of distribution. +- **Multi-asset reasoning.** It classifies the sentiment of a single piece + of text. It won't aggregate across multiple headlines or weigh sources. +- **Numerical reasoning.** It can read "beats by 12%" and call that + positive, but it isn't doing math. Don't ask it to forecast. +- **Languages other than English.** Training data was English only. +- **Background knowledge.** If the headline needs you to know what a + company does, the model only has whatever was in its base pretraining. + It can't look anything up. +- **Three labels, hard cutoffs.** The output space is positive / negative / + neutral. If you need a 5-class scale or a continuous score, you'll need + to retrain or post-process. + +## Training details + +| | | +|---|---| +| Upstream base model | [Qwen/Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B) | +| Loading mirror | [unsloth/Qwen3-1.7B](https://huggingface.co/unsloth/Qwen3-1.7B) (Unsloth's pre-quantized copy) | +| Dataset | [Ayansk11/FinSenti-Dataset](https://huggingface.co/datasets/Ayansk11/FinSenti-Dataset) (~15.2K train per stage, 50.8K total across splits) | +| SFT length | ~0.8 hours on A100 80GB | +| GRPO budget | 3000 steps with early stopping (best near step ~300) | +| Best GRPO reward | ~3.71 / 4.0 | +| Adapter | LoRA (r=32, alpha=64) on q/k/v/o/gate/up/down projections | +| Sequence length | 2048 | +| Optimizer | AdamW (8-bit), cosine LR schedule | +| Hardware | NVIDIA A100 80GB (Indiana University BigRed200 cluster) | +| Frameworks | Unsloth + TRL | + +## Related FinSenti models + +Other sizes and bases trained with the same recipe: + +- **Qwen3**: [Qwen3-0.6B](https://huggingface.co/Ayansk11/FinSenti-Qwen3-0.6B), [Qwen3-4B](https://huggingface.co/Ayansk11/FinSenti-Qwen3-4B), [Qwen3-8B](https://huggingface.co/Ayansk11/FinSenti-Qwen3-8B) +- **Qwen3.5**: [Qwen3.5-0.8B](https://huggingface.co/Ayansk11/FinSenti-Qwen3.5-0.8B), [Qwen3.5-2B](https://huggingface.co/Ayansk11/FinSenti-Qwen3.5-2B), [Qwen3.5-4B](https://huggingface.co/Ayansk11/FinSenti-Qwen3.5-4B), [Qwen3.5-9B](https://huggingface.co/Ayansk11/FinSenti-Qwen3.5-9B) +- **DeepSeek**: [DeepSeek-R1-1.5B](https://huggingface.co/Ayansk11/FinSenti-DeepSeek-R1-1.5B) +- **MobileLLM**: [MobileLLM-R1-950M](https://huggingface.co/Ayansk11/FinSenti-MobileLLM-R1-950M) +- **Tiny-LLM**: [Tiny-LLM-10M](https://huggingface.co/Ayansk11/FinSenti-Tiny-LLM-10M) +- **Llama-3**: [Llama-3.2-1B](https://huggingface.co/Ayansk11/FinSenti-Llama-3.2-1B) +- **SmolLM**: [SmolLM-1.7B](https://huggingface.co/Ayansk11/FinSenti-SmolLM-1.7B) + +There's a GGUF build of this same model at +[Ayansk11/FinSenti-Qwen3-1.7B-GGUF](https://huggingface.co/Ayansk11/FinSenti-Qwen3-1.7B-GGUF) for Ollama and +llama.cpp, and the dataset itself is at +[Ayansk11/FinSenti-Dataset](https://huggingface.co/datasets/Ayansk11/FinSenti-Dataset). + +If you're picking a size, a rough guide: + +- **Need it on a phone or browser?** Look at the smallest model in the + group (Qwen3-0.6B) or its GGUF. +- **Laptop with no GPU?** Any model up to ~2B as Q4_K_M GGUF works. +- **Single 8-12 GB GPU?** The 1.5B-4B sizes are the sweet spot. +- **Server or workstation?** The 8B / 9B variants give the best reasoning + but need the memory. + +## Citation + +If you use this model in research, please cite: + +```bibtex +@misc{shaikh2026finsenti, + title = {FinSenti: Small Language Models for Financial Sentiment with Chain-of-Thought Reasoning}, + author = {Shaikh, Ayan}, + year = {2026}, + url = {https://huggingface.co/collections/Ayansk11/finsenti}, + note = {Indiana University} +} +``` + +## License + +Apache 2.0, same as the base model. + +## Acknowledgements + +Trained on the Indiana University BigRed200 cluster. +Thanks to the Unsloth and TRL teams for the trainer stack, and to the +Qwen / DeepSeek teams for the base models. diff --git a/chat_template.jinja b/chat_template.jinja new file mode 100644 index 0000000..ba89998 --- /dev/null +++ b/chat_template.jinja @@ -0,0 +1,97 @@ +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0].role == 'system' %} + {{- messages[0].content + '\n\n' }} + {%- endif %} + {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0].role == 'system' %} + {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} +{%- for forward_message in messages %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- set message = messages[index] %} + {%- set tool_start = '' %} + {%- set tool_start_length = tool_start|length %} + {%- set start_of_message = message.content[:tool_start_length] %} + {%- set tool_end = '' %} + {%- set tool_end_length = tool_end|length %} + {%- set start_pos = (message.content|length) - tool_end_length %} + {%- if start_pos < 0 %} + {%- set start_pos = 0 %} + {%- endif %} + {%- set end_of_message = message.content[start_pos:] %} + {%- if ns.multi_step_tool and message.role == "user" and not(start_of_message == tool_start and end_of_message == tool_end) %} + {%- set ns.multi_step_tool = false %} + {%- set ns.last_query_index = index %} + {%- endif %} +{%- endfor %} +{%- for message in messages %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) %} + {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {%- set content = message.content %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is defined and message.reasoning_content is not none %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in message.content %} + {%- set content = (message.content.split('')|last).lstrip('\n') %} + {%- set reasoning_content = (message.content.split('')|first).rstrip('\n') %} + {%- set reasoning_content = (reasoning_content.split('')|last).lstrip('\n') %} + {%- endif %} + {%- endif %} + {%- if loop.index0 > ns.last_query_index %} + {%- if loop.last or (not loop.last and reasoning_content) %} + {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- if message.tool_calls %} + {%- for tool_call in message.tool_calls %} + {%- if (loop.first and content) or (not loop.first) %} + {{- '\n' }} + {%- endif %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {%- if tool_call.arguments is string %} + {{- tool_call.arguments }} + {%- else %} + {{- tool_call.arguments | tojson }} + {%- endif %} + {{- '}\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- message.content }} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is false %} + {{- '\n\n\n\n' }} + {%- endif %} +{%- endif %} \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..be05be5 --- /dev/null +++ b/config.json @@ -0,0 +1,64 @@ +{ + "architectures": [ + "Qwen3ForCausalLM" + ], + "attention_bias": false, + "attention_dropout": 0.0, + "bos_token_id": null, + "torch_dtype": "bfloat16", + "eos_token_id": 151645, + "head_dim": 128, + "hidden_act": "silu", + "hidden_size": 2048, + "initializer_range": 0.02, + "intermediate_size": 6144, + "layer_types": [ + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention" + ], + "max_position_embeddings": 40960, + "max_window_layers": 28, + "model_type": "qwen3", + "num_attention_heads": 16, + "num_hidden_layers": 28, + "num_key_value_heads": 8, + "pad_token_id": 151669, + "rms_norm_eps": 1e-06, + "rope_parameters": { + "rope_theta": 1000000, + "rope_type": "default" + }, + "sliding_window": null, + "tie_word_embeddings": true, + "unsloth_fixed": true, + "unsloth_version": "2026.3.4", + "use_cache": true, + "use_sliding_window": false, + "vocab_size": 151936 +} \ No newline at end of file diff --git a/model.safetensors b/model.safetensors new file mode 100644 index 0000000..87ebe45 --- /dev/null +++ b/model.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc59454f79ac7b38f10b45984e48f639b0f9b410d9712e712a658f3e8c6f5d73 +size 3441185608 diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..7edcf72 --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7430e9138b76e93fb6f93462394d236b411111aef53cb421ba97d2691040cca +size 11423114 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..308aa1a --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,16 @@ +{ + "add_prefix_space": false, + "backend": "tokenizers", + "bos_token": null, + "clean_up_tokenization_spaces": false, + "eos_token": "<|im_end|>", + "errors": "replace", + "is_local": false, + "model_max_length": 40960, + "pad_token": "<|PAD_TOKEN|>", + "padding_side": "right", + "split_special_tokens": false, + "tokenizer_class": "Qwen2Tokenizer", + "unk_token": null, + "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within XML tags:\\n\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n\\n\\nFor each function call, return a json object with function name and arguments within XML tags:\\n\\n{\\\"name\\\": , \\\"arguments\\\": }\\n<|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for forward_message in messages %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- set message = messages[index] %}\n {%- set tool_start = '' %}\n {%- set tool_start_length = tool_start|length %}\n {%- set start_of_message = message.content[:tool_start_length] %}\n {%- set tool_end = '' %}\n {%- set tool_end_length = tool_end|length %}\n {%- set start_pos = (message.content|length) - tool_end_length %}\n {%- if start_pos < 0 %}\n {%- set start_pos = 0 %}\n {%- endif %}\n {%- set end_of_message = message.content[start_pos:] %}\n {%- if ns.multi_step_tool and message.role == \"user\" and not(start_of_message == tool_start and end_of_message == tool_end) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set content = message.content %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is defined and message.reasoning_content is not none %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- if '' in message.content %}\n {%- set content = (message.content.split('')|last).lstrip('\\n') %}\n {%- set reasoning_content = (message.content.split('')|first).rstrip('\\n') %}\n {%- set reasoning_content = (reasoning_content.split('')|last).lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- if loop.index0 > ns.last_query_index %}\n {%- if loop.last or (not loop.last and reasoning_content) %}\n {{- '<|im_start|>' + message.role + '\\n\\n' + reasoning_content.strip('\\n') + '\\n\\n\\n' + content.lstrip('\\n') }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls %}\n {%- for tool_call in message.tool_calls %}\n {%- if (loop.first and content) or (not loop.first) %}\n {{- '\\n' }}\n {%- endif %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {%- if tool_call.arguments is string %}\n {{- tool_call.arguments }}\n {%- else %}\n {{- tool_call.arguments | tojson }}\n {%- endif %}\n {{- '}\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n\\n' }}\n {{- message.content }}\n {{- '\\n' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '\\n\\n\\n\\n' }}\n {%- endif %}\n{%- endif %}" +} \ No newline at end of file