From 23c99c3afaeebb9a2356aec9accb8b4ba4d12ce5 Mon Sep 17 00:00:00 2001 From: ModelHub XC Date: Wed, 22 Apr 2026 13:19:58 +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: Shahansha/Manthan-1.5B Source: Original Platform --- .gitattributes | 38 ++++++ Modelfile | 57 +++++++++ Qwen2.5-1.5B-Instruct.Q4_K_M.gguf | 3 + Qwen2.5-1.5B-Instruct.Q8_0.gguf | 3 + README.md | 188 ++++++++++++++++++++++++++++++ adapter_config.json | 50 ++++++++ adapter_model.safetensors | 3 + chat_template.jinja | 54 +++++++++ config.json | 62 ++++++++++ generation_config.json | 14 +++ model.safetensors | 3 + tokenizer.json | 3 + tokenizer_config.json | 16 +++ training_args.bin | 3 + 14 files changed, 497 insertions(+) create mode 100644 .gitattributes create mode 100644 Modelfile create mode 100644 Qwen2.5-1.5B-Instruct.Q4_K_M.gguf create mode 100644 Qwen2.5-1.5B-Instruct.Q8_0.gguf create mode 100644 README.md create mode 100644 adapter_config.json create mode 100644 adapter_model.safetensors create mode 100644 chat_template.jinja create mode 100644 config.json create mode 100644 generation_config.json create mode 100644 model.safetensors create mode 100644 tokenizer.json create mode 100644 tokenizer_config.json create mode 100644 training_args.bin diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..46ca74b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,38 @@ +*.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 +Qwen2.5-1.5B-Instruct.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text +Qwen2.5-1.5B-Instruct.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text diff --git a/Modelfile b/Modelfile new file mode 100644 index 0000000..f231511 --- /dev/null +++ b/Modelfile @@ -0,0 +1,57 @@ + +FROM Qwen2.5-1.5B-Instruct.Q8_0.gguf +TEMPLATE """{{- if .Messages }} +{{- if or .System .Tools }}<|im_start|>system +{{- if .System }} +{{ .System }} +{{- end }} +{{- if .Tools }} + +# Tools + +You may call one or more functions to assist with the user query. + +You are provided with function signatures within XML tags: + +{{- range .Tools }} +{"type": "function", "function": {{ .Function }}} +{{- end }} + + +For each function call, return a json object with function name and arguments within XML tags: + +{"name": , "arguments": } + +{{- end }}<|im_end|> +{{ end }} +{{- range $i, $_ := .Messages }} +{{- $last := eq (len (slice $.Messages $i)) 1 -}} +{{- if eq .Role "user" }}<|im_start|>user +{{ .Content }}<|im_end|> +{{ else if eq .Role "assistant" }}<|im_start|>assistant +{{ if .Content }}{{ .Content }} +{{- else if .ToolCalls }} +{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}} +{{ end }} +{{- end }}{{ if not $last }}<|im_end|> +{{ end }} +{{- else if eq .Role "tool" }}<|im_start|>user + +{{ .Content }} +<|im_end|> +{{ end }} +{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant +{{ end }} +{{- end }} +{{- else }} +{{- if .System }}<|im_start|>system +{{ .System }}<|im_end|> +{{ end }}{{ if .Prompt }}<|im_start|>user +{{ .Prompt }}<|im_end|> +{{ end }}<|im_start|>assistant +{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}""" +PARAMETER stop "<|im_end|>" +PARAMETER stop "<|endoftext|>" +PARAMETER temperature 1.5 +PARAMETER min_p 0.1 +SYSTEM """You are Qwen, created by Alibaba Cloud. You are a helpful assistant.""" \ No newline at end of file diff --git a/Qwen2.5-1.5B-Instruct.Q4_K_M.gguf b/Qwen2.5-1.5B-Instruct.Q4_K_M.gguf new file mode 100644 index 0000000..2b14a27 --- /dev/null +++ b/Qwen2.5-1.5B-Instruct.Q4_K_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5fbdf4c6440ff2e9ef5a2794d48125043935622b8f60f27c84d8c83f9a62d06c +size 986048000 diff --git a/Qwen2.5-1.5B-Instruct.Q8_0.gguf b/Qwen2.5-1.5B-Instruct.Q8_0.gguf new file mode 100644 index 0000000..a28ddfb --- /dev/null +++ b/Qwen2.5-1.5B-Instruct.Q8_0.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fcad84dc4cf2404ae91a65067e241915864b8dcd5a35dd876216b276de54695d +size 1646572544 diff --git a/README.md b/README.md new file mode 100644 index 0000000..546b453 --- /dev/null +++ b/README.md @@ -0,0 +1,188 @@ +--- +language: +- en +license: apache-2.0 +base_model: Qwen/Qwen2.5-1.5B-Instruct +base_model_relation: finetune +library_name: transformers +pipeline_tag: text-generation +tags: +- genesis-agi +- manthan +- qwen2 +- tool-calling +- agent +- reasoning +- grpo +- qlora +- chatml +- smolagents +datasets: +- Shahansha/manthan-tool-reasoning-v1 +- glaiveai/glaive-function-calling-v2 +- NousResearch/hermes-function-calling-v1 +metrics: +- accuracy +- pass@1 +model-index: +- + name: Manthan-1.5B + results: + - + task: + type: text-generation + name: Tool-Augmented Generation + dataset: + name: GSM8K + type: gsm8k + metrics: + - + name: Tool-Augmented Accuracy + type: accuracy + value: 65.0 + - + task: + type: text-generation + name: Code Generation + dataset: + name: MBPP + type: mbpp + metrics: + - + name: pass@1 + type: pass@1 + value: 50.0 +--- + +# Genesis Manthan - 1.5B + +Genesis Manthan is a small language model fine-tuned to reason through tool interaction instead of verbal chain-of-thought. It is built on top of Qwen2.5-1.5B-Instruct and tuned for tool-first responses, agent workflows, and smolagents-style execution loops. + +## Model Summary + +- Base model: `Qwen/Qwen2.5-1.5B-Instruct` +- Published model: `Shahansha/Manthan-1.5B` +- Training recipe: QLoRA SFT -> GRPO with tool-execution rewards -> budget forcing at inference time +- Primary behavior: emit structured tool calls before final answers +- Intended ecosystem: Hugging Face Transformers, Gradio Spaces, smolagents, local agent runners + +## Why this model exists + +Most small open models still answer by generating verbose text, even when the task would be better solved through an external tool. Manthan is designed around a different behavior: call a tool, observe the result, and then answer. The target is not hidden verbal reasoning. The target is reliable action traces that small models can actually execute. + +spaces: + - Shahansha/Manthan-Demo + +## Benchmark Snapshot + +| Benchmark | Metric | Reported Result | +|---|---:|---:| +| GSM8K | Tool-augmented accuracy | 65.0 | +| MBPP | pass@1 | 50.0 | + +*Reported benchmark numbers are early project metrics and should be independently reproduced before strong claims are made. + +## Quickstart + +```python +from transformers import AutoModelForCausalLM, AutoTokenizer +import torch + +model_id = "Shahansha/Manthan-1.5B" +tokenizer = AutoTokenizer.from_pretrained(model_id) +model = AutoModelForCausalLM.from_pretrained( + model_id, + dtype=torch.float16, + device_map="auto", +) +model.generation_config.max_length = None + +messages = [ + { + "role": "system", + "content": ( + "You are Genesis Manthan, an AI agent that solves problems by calling tools. " + "Never reason verbally - always reason through tool execution." + ), + }, + {"role": "user", "content": "What is 144 + 256?"}, +] + +prompt = tokenizer.apply_chat_template( + messages, + tokenize=False, + add_generation_prompt=True, +) +inputs = tokenizer(prompt, return_tensors="pt").to(model.device) +outputs = model.generate( + **inputs, + max_new_tokens=256, + do_sample=True, + temperature=0.2, +) + +print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)) +``` + +Expected behavior: the completion should include a `` block before the final answer. + +## Prompting Guidance + +This model performs best when the system prompt explicitly instructs it to solve problems by calling tools. If you omit that instruction, it may drift back toward plain-text assistant behavior. + +Recommended system message: + +```text +You are Genesis Manthan, an AI agent that solves problems by calling tools. Never reason verbally - always reason through tool execution. +``` + +## Training Details + +- Base checkpoint: `Qwen/Qwen2.5-1.5B-Instruct` +- Fine-tuning method: QLoRA SFT +- Reinforcement learning: GRPO with composable rewards for tool execution, answer correctness, and format compliance +- Data format: ChatML with custom tool roles and structured `` blocks +- Primary training data: `Shahansha/manthan-tool-reasoning-v1` plus function-calling traces derived from Glaive and Hermes datasets + +## Intended Use + +- Agentic math and reasoning tasks where external execution is available +- Tool-augmented code and debugging workflows +- Research experiments around small-model tool use +- Gradio demos and Hugging Face Spaces showcasing action-first reasoning + +## Limitations + +- This is a research model, not a general factual authority +- Reported benchmark numbers are early project metrics and should be independently reproduced before strong claims are made +- The model relies heavily on the surrounding prompt and tool scaffolding +- Small models can still emit malformed tool calls or conclude too early without budget forcing or downstream validation + +## Safety and Responsible Use + +- Do not treat tool-call output as inherently safe to execute without sandboxing +- Validate JSON arguments and restrict available tools in production +- Review outputs carefully in coding, shell, or data-execution environments +- This model was not trained for high-stakes legal, medical, or safety-critical decisions + +## Project Links + +- Model: https://huggingface.co/Shahansha/Manthan-1.5B +- Dataset: https://huggingface.co/datasets/Shahansha/manthan-tool-reasoning-v1 +- Code: https://github.com/shaik-shahansha/manthan +- Deployment guide: https://github.com/shaik-shahansha/manthan/blob/main/docs/HUGGINGFACE_DEPLOY.md +- Author: https://shahansha.com +- Org: https://genesisagi.in + +## Citation + +```bibtex +@misc{shaik2026manthan, + title={Genesis Manthan-1.5B: Tool-Mediated Reasoning for Small Language Models}, + author={Shahansha Shaik}, + year={2026}, + url={https://huggingface.co/Shahansha/Manthan-1.5B} +} +``` + +--- \ No newline at end of file diff --git a/adapter_config.json b/adapter_config.json new file mode 100644 index 0000000..b2985c6 --- /dev/null +++ b/adapter_config.json @@ -0,0 +1,50 @@ +{ + "alora_invocation_tokens": null, + "alpha_pattern": {}, + "arrow_config": null, + "auto_mapping": { + "base_model_class": "Qwen2ForCausalLM", + "parent_library": "transformers.models.qwen2.modeling_qwen2", + "unsloth_fixed": true + }, + "base_model_name_or_path": "unsloth/Qwen2.5-1.5B-Instruct-bnb-4bit", + "bias": "none", + "corda_config": null, + "ensure_weight_tying": false, + "eva_config": null, + "exclude_modules": null, + "fan_in_fan_out": false, + "inference_mode": true, + "init_lora_weights": true, + "layer_replication": null, + "layers_pattern": null, + "layers_to_transform": null, + "loftq_config": {}, + "lora_alpha": 16, + "lora_bias": false, + "lora_dropout": 0.0, + "megatron_config": null, + "megatron_core": "megatron.core", + "modules_to_save": null, + "peft_type": "LORA", + "peft_version": "0.18.1", + "qalora_group_size": 16, + "r": 16, + "rank_pattern": {}, + "revision": null, + "target_modules": [ + "v_proj", + "k_proj", + "down_proj", + "gate_proj", + "q_proj", + "o_proj", + "up_proj" + ], + "target_parameters": null, + "task_type": "CAUSAL_LM", + "trainable_token_indices": null, + "use_dora": false, + "use_qalora": false, + "use_rslora": false +} \ No newline at end of file diff --git a/adapter_model.safetensors b/adapter_model.safetensors new file mode 100644 index 0000000..82f4557 --- /dev/null +++ b/adapter_model.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b1e5740a20d4169c5a3f10aa6d90ffc4228085d7633c494c06d55f349e19ef2 +size 73911112 diff --git a/chat_template.jinja b/chat_template.jinja new file mode 100644 index 0000000..bdf7919 --- /dev/null +++ b/chat_template.jinja @@ -0,0 +1,54 @@ +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0]['role'] == 'system' %} + {{- messages[0]['content'] }} + {%- else %} + {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }} + {%- endif %} + {{- "\n\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" }} + {%- 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' }} + {%- else %} + {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- for message in messages %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %} + {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {{- '<|im_start|>' + message.role }} + {%- if message.content %} + {{- '\n' + message.content }} + {%- endif %} + {%- for tool_call in message.tool_calls %} + {%- if tool_call.function is defined %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {{- tool_call.arguments | tojson }} + {{- '}\n' }} + {%- endfor %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if (loop.index0 == 0) 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' }} +{%- endif %} diff --git a/config.json b/config.json new file mode 100644 index 0000000..9042e3c --- /dev/null +++ b/config.json @@ -0,0 +1,62 @@ +{ + "architectures": [ + "Qwen2ForCausalLM" + ], + "attention_dropout": 0.0, + "bos_token_id": null, + "torch_dtype": "float16", + "eos_token_id": 151645, + "hidden_act": "silu", + "hidden_size": 1536, + "initializer_range": 0.02, + "intermediate_size": 8960, + "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": 32768, + "max_window_layers": 21, + "model_type": "qwen2", + "num_attention_heads": 12, + "num_hidden_layers": 28, + "num_key_value_heads": 2, + "pad_token_id": 151654, + "rms_norm_eps": 1e-06, + "rope_parameters": { + "rope_theta": 1000000.0, + "rope_type": "default" + }, + "sliding_window": null, + "tie_word_embeddings": true, + "unsloth_fixed": true, + "unsloth_version": "2026.4.4", + "use_cache": false, + "use_sliding_window": false, + "vocab_size": 151936 +} \ No newline at end of file diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..82ca381 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,14 @@ +{ + "do_sample": true, + "eos_token_id": [ + 151645, + 151643 + ], + "max_length": 32768, + "pad_token_id": 151654, + "repetition_penalty": 1.1, + "temperature": 0.7, + "top_k": 20, + "top_p": 0.8, + "transformers_version": "5.5.0" +} diff --git a/model.safetensors b/model.safetensors new file mode 100644 index 0000000..5cc6664 --- /dev/null +++ b/model.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f82b8d498f2c6ddcc2cf02429d5dfe1c9666e62720b30edee3ad90b5653baace +size 3087467144 diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..5340d81 --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd5948af71b4f56cf697f7580814c7ce8b80595ef985544efcacf716126a2e31 +size 11422356 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..59da754 --- /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": 32768, + "pad_token": "<|PAD_TOKEN|>", + "padding_side": "left", + "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 {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\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 {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) 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{%- endif %}\n" +} \ No newline at end of file diff --git a/training_args.bin b/training_args.bin new file mode 100644 index 0000000..2f3c998 --- /dev/null +++ b/training_args.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abbf42c330406a916ff5046127fb1d84fcc066dcaea8401b2b2782cd6941c04a +size 6737