From a75cdad9084504b76c6970cfff294b7eab30a980 Mon Sep 17 00:00:00 2001 From: ModelHub XC Date: Fri, 10 Apr 2026 17:49:55 +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: openalchemy/MachFund Source: Original Platform --- .gitattributes | 39 +++++++++++ README.md | 121 +++++++++++++++++++++++++++++++++++ chat_template.jinja | 54 ++++++++++++++++ config.json | 69 ++++++++++++++++++++ generation_config.json | 14 ++++ gguf/mach-fund-1-Q4_K_M.gguf | 3 + gguf/mach-fund-1-Q8_0.gguf | 3 + gguf/mach-fund-1-f16.gguf | 3 + model.safetensors | 3 + model_card.json | 20 ++++++ tokenizer.json | 3 + tokenizer_config.json | 29 +++++++++ 12 files changed, 361 insertions(+) create mode 100644 .gitattributes create mode 100644 README.md create mode 100644 chat_template.jinja create mode 100644 config.json create mode 100644 generation_config.json create mode 100644 gguf/mach-fund-1-Q4_K_M.gguf create mode 100644 gguf/mach-fund-1-Q8_0.gguf create mode 100644 gguf/mach-fund-1-f16.gguf create mode 100644 model.safetensors create mode 100644 model_card.json create mode 100644 tokenizer.json create mode 100644 tokenizer_config.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..69d8b08 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,39 @@ +*.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 +gguf/mach-fund-1-f16.gguf filter=lfs diff=lfs merge=lfs -text +gguf/mach-fund-1-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text +gguf/mach-fund-1-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md new file mode 100644 index 0000000..5ad846c --- /dev/null +++ b/README.md @@ -0,0 +1,121 @@ +--- +license: mit +language: +- zh +base_model: +- Qwen/Qwen2.5-3B-Instruct +pipeline_tag: text-generation +library_name: transformers +tags: +- finance +- chinese +- qlora +- private-equity +- fund-analysis +- distillation +metrics: +- loss +--- + +# MachFund-1 + +A specialized Chinese private equity fund analysis model, fine-tuned from [Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct) using QLoRA knowledge distillation. + +## Overview + +MachFund-1 is trained to analyze Chinese private equity funds across multiple dimensions: performance analysis, risk assessment, strategy evaluation, manager background, fund comparisons, and investment advice. The model demonstrates a **68.75% improvement** over the base model on domain-specific tasks. + +## Training Details + +| Parameter | Value | +|---|---| +| Base Model | Qwen2.5-3B-Instruct | +| Method | QLoRA (4-bit NF4 quantization) | +| LoRA Rank / Alpha | 32 / 64 | +| Training Samples | 6,976 (eval: 769) | +| Effective Batch Size | 16 (2 x 8 grad accumulation) | +| Learning Rate | 2e-4 (cosine schedule) | +| Epochs | 2 | +| Max Sequence Length | 6,144 tokens | +| Final Training Loss | 0.9269 | +| Training Time | 141 min on NVIDIA A100 80GB | +| Total Steps | 872 | + +### Knowledge Distillation Pipeline + +1. **Teacher Model**: Gemini 2.5 Pro generates ~50 Q&A pairs per fund across 8 categories for 178 Chinese private equity funds +2. **Quality Scoring**: Gemini 2.5 Flash scores each pair on 5 dimensions (accuracy, completeness, professionalism, data usage, coherence) with a threshold of 15/25 +3. **Student Training**: QLoRA fine-tuning on 6,976 high-quality filtered samples + +### Question Categories + +- Fund overview and basic information +- Performance analysis and benchmarking +- Risk assessment and drawdown analysis +- Strategy analysis and market positioning +- Manager background and track record +- Fund comparisons (peer and category) +- Investment advice and suitability +- Structured data extraction + +## Evaluation + +| Gate | Metric | Result | +|---|---|---| +| Training Lift | Base vs Fine-tuned Score | **PASS** (4.8 to 8.1, +68.75%, threshold: 30%) | +| Speed (FP16) | Tokens/sec on RTX 5080 | 30.1 tok/s (threshold: 50) | + +## Available Formats + +| Format | File | Size | Use Case | +|---|---|---|---| +| SafeTensors (FP16) | `model.safetensors` | 6.17 GB | Full precision inference | +| GGUF Q8_0 | `gguf/mach-fund-1-Q8_0.gguf` | 3.29 GB | High-quality quantized inference | +| GGUF Q4_K_M | `gguf/mach-fund-1-Q4_K_M.gguf` | 1.93 GB | Efficient inference, recommended | +| GGUF F16 | `gguf/mach-fund-1-f16.gguf` | 6.18 GB | Full precision GGUF | + +## Usage + +### Transformers + +```python +from transformers import AutoModelForCausalLM, AutoTokenizer + +model = AutoModelForCausalLM.from_pretrained("openalchemy/MachFund", torch_dtype="auto", device_map="auto") +tokenizer = AutoTokenizer.from_pretrained("openalchemy/MachFund") + +messages = [ + {"role": "system", "content": "You are a professional private equity fund analyst."}, + {"role": "user", "content": "Analyze the performance of this fund"} +] + +text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) +inputs = tokenizer(text, return_tensors="pt").to(model.device) +outputs = model.generate(**inputs, max_new_tokens=1024) +print(tokenizer.decode(outputs[0], skip_special_tokens=True)) +``` + +### llama.cpp (GGUF) + +```bash +./llama-cli -m mach-fund-1-Q4_K_M.gguf -p "Analyze the risk profile of this fund" -n 512 +``` + +### Ollama + +```bash +echo 'FROM ./mach-fund-1-Q4_K_M.gguf' > Modelfile +ollama create machfund -f Modelfile +ollama run machfund "What is the Sharpe ratio of this fund?" +``` + +## Limitations + +- Trained specifically on Chinese private equity fund data; may not generalize to other financial domains +- Training data reflects fund information available up to early 2026 +- Should not be used as the sole basis for investment decisions +- Speed on consumer GPUs (RTX 5080) is below the 50 tok/s target at FP16; use GGUF Q4_K_M for faster inference + +## License + +MIT diff --git a/chat_template.jinja b/chat_template.jinja new file mode 100644 index 0000000..9840d40 --- /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..8d27bac --- /dev/null +++ b/config.json @@ -0,0 +1,69 @@ +{ + "architectures": [ + "Qwen2ForCausalLM" + ], + "attention_dropout": 0.0, + "bos_token_id": 151643, + "dtype": "float16", + "eos_token_id": 151645, + "hidden_act": "silu", + "hidden_size": 2048, + "initializer_range": 0.02, + "intermediate_size": 11008, + "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", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention" + ], + "max_position_embeddings": 32768, + "max_window_layers": 70, + "model_type": "qwen2", + "num_attention_heads": 16, + "num_hidden_layers": 36, + "num_key_value_heads": 2, + "pad_token_id": null, + "rms_norm_eps": 1e-06, + "rope_parameters": { + "rope_theta": 1000000.0, + "rope_type": "default" + }, + "sliding_window": null, + "tie_word_embeddings": true, + "transformers_version": "5.3.0", + "use_cache": true, + "use_sliding_window": false, + "vocab_size": 151936 +} diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..daedcce --- /dev/null +++ b/generation_config.json @@ -0,0 +1,14 @@ +{ + "bos_token_id": 151643, + "do_sample": true, + "eos_token_id": [ + 151645, + 151643 + ], + "pad_token_id": 151643, + "repetition_penalty": 1.05, + "temperature": 0.7, + "top_k": 20, + "top_p": 0.8, + "transformers_version": "5.3.0" +} diff --git a/gguf/mach-fund-1-Q4_K_M.gguf b/gguf/mach-fund-1-Q4_K_M.gguf new file mode 100644 index 0000000..47442ef --- /dev/null +++ b/gguf/mach-fund-1-Q4_K_M.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb6d7493e09a3392637078730d7544bdf065427c83fc6508beb85eb12b66918b +size 1929902432 diff --git a/gguf/mach-fund-1-Q8_0.gguf b/gguf/mach-fund-1-Q8_0.gguf new file mode 100644 index 0000000..e7072f8 --- /dev/null +++ b/gguf/mach-fund-1-Q8_0.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c2deb07df26324602b345e1affc94ccb8e63307b7830bae93a27d0910edb768 +size 3285475680 diff --git a/gguf/mach-fund-1-f16.gguf b/gguf/mach-fund-1-f16.gguf new file mode 100644 index 0000000..3ffdf5c --- /dev/null +++ b/gguf/mach-fund-1-f16.gguf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15ce0abf098face70048c5b4889d794d9ca043254d37fa35de4affd4f5ac764b +size 6178316640 diff --git a/model.safetensors b/model.safetensors new file mode 100644 index 0000000..b8d997d --- /dev/null +++ b/model.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91386f73bb2ef4a8a5bce56c8ddaa6f45f3a991bf453ded73d71d21eec753653 +size 6171926680 diff --git a/model_card.json b/model_card.json new file mode 100644 index 0000000..65dc3d3 --- /dev/null +++ b/model_card.json @@ -0,0 +1,20 @@ +{ + "model_name": "mach-fund-1", + "base_model": "Qwen/Qwen2.5-3B-Instruct", + "training": { + "train_samples": 6976, + "eval_samples": 769, + "epochs": 2, + "lora_rank": 32, + "batch_size": 2, + "grad_accum": 8, + "max_seq_len": 6144, + "total_steps": 872, + "train_loss": 0.9269, + "train_time_min": 141.0, + "gpu": "NVIDIA A100 80GB PCIe", + "completed_at": "2026-03-21 06:58:25" + }, + "merged_at": "2026-03-21 16:13:47", + "description": "Private equity fund analysis model, distilled from Gemini 2.5 Pro" +} \ No newline at end of file diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..34510ff --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3fd169731d2cbde95e10bf356d66d5997fd885dd8dbb6fb4684da3f23b2585d8 +size 11421892 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..a8f5ccb --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,29 @@ +{ + "add_prefix_space": false, + "backend": "tokenizers", + "bos_token": null, + "clean_up_tokenization_spaces": false, + "eos_token": "<|im_end|>", + "errors": "replace", + "extra_special_tokens": [ + "<|im_start|>", + "<|im_end|>", + "<|object_ref_start|>", + "<|object_ref_end|>", + "<|box_start|>", + "<|box_end|>", + "<|quad_start|>", + "<|quad_end|>", + "<|vision_start|>", + "<|vision_end|>", + "<|vision_pad|>", + "<|image_pad|>", + "<|video_pad|>" + ], + "is_local": true, + "model_max_length": 131072, + "pad_token": "<|endoftext|>", + "split_special_tokens": false, + "tokenizer_class": "Qwen2Tokenizer", + "unk_token": null +}