tcjszy commited on
Commit
ad00767
·
verified ·
1 Parent(s): 67cd613

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +54 -13
README.md CHANGED
@@ -1,21 +1,62 @@
1
  ---
2
- base_model: unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit
3
- tags:
4
- - text-generation-inference
5
- - transformers
6
- - unsloth
7
- - qwen2
8
- license: apache-2.0
9
  language:
 
10
  - en
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
- # Uploaded finetuned model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- - **Developed by:** tcjszy
16
- - **License:** apache-2.0
17
- - **Finetuned from model :** unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit
18
 
19
- This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
 
 
 
 
 
 
 
 
20
 
21
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
1
  ---
 
 
 
 
 
 
 
2
  language:
3
+ - zh
4
  - en
5
+ license: apache-2.0
6
+ base_model: Qwen/Qwen2.5-Coder-7B-Instruct
7
+ tags:
8
+ - text-to-sql
9
+ - mysql
10
+ - elasticsearch
11
+ - es-dsl
12
+ - patent
13
+ - chinese
14
+ - agent
15
+ - qwen2.5-coder
16
+ - unsloth
17
+ - lora
18
+ datasets:
19
+ - tcjszy/cn-patent-text2sql-es-dataset
20
+ pipeline_tag: text-generation
21
  ---
22
 
23
+ # PatentSQL-Qwen2.5-Coder-7B — 中文专利 MySQL + Elasticsearch 双引擎查数专精模型
24
+
25
+ 面向企业级专利数据检索与统计场景的私有化部署 7B 专精小模型,基于 `Qwen/Qwen2.5-Coder-7B-Instruct` 使用 **Unsloth + QLoRA + Response-Only Loss Masking** 微调而成。
26
+
27
+ ## 核心特性
28
+ 1. **双引擎支持**:同时支持 **MySQL 8.0 Text-to-SQL**(多表 JOIN、枚举黑话解码、窗口函数、授权率/有效率计算)与 **Elasticsearch 8.x Query DSL**(`multi_match` 权重全文搜索、`bool` 排除、`terms`/`date_histogram` 分面聚合)。
29
+ 2. **可解释 `<think>` 推理链**:先输出中文业务口径拆解与字段定位思路,再输出标准可执行 SQL/JSON 代码块。
30
+ 3. **内置报错自修复(Self-Correction)能力**:训练集中专门注入了 MySQL 报错修复样本,适配 Agent 的 `try-catch` 自动重试流水线。
31
+ 4. **保留跨库泛化能力**:混入非专利通用中文业务库训练,在未见过的新库 DDL 上依然稳定可用。
32
+ 5. **私有化低成本部署**:同步提供 [GGUF 量化版](https://huggingface.co/tcjszy/PatentSQL-Qwen2.5-Coder-7B-GGUF),消费级单卡或个人电脑通过 Ollama 即可运行。
33
+
34
+ ## 快速开始
35
+
36
+ ### 1) Ollama 一行命令运行(推荐)
37
+ ```bash
38
+ ollama run hf.co/tcjszy/PatentSQL-Qwen2.5-Coder-7B-GGUF:Q4_K_M
39
+ ```
40
+
41
+ ### 2) Transformers Python 推理
42
+ ```python
43
+ from transformers import AutoModelForCausalLM, AutoTokenizer
44
+ import torch
45
 
46
+ model_id = "tcjszy/PatentSQL-Qwen2.5-Coder-7B"
47
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
48
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
49
 
50
+ messages = [
51
+ {"role": "system", "content": "你是一位精通 MySQL 8.0 与中国专利业务的数据查询专家..."},
52
+ {"role": "user", "content": "统计广东省目前有多少件有效发明专利"},
53
+ ]
54
+ text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
55
+ inputs = tokenizer([text], return_tensors="pt").to(model.device)
56
+ out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
57
+ print(tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
58
+ ```
59
 
60
+ ## 训练与评测数据
61
+ - 开源数据集:[tcjszy/cn-patent-text2sql-es-dataset](https://huggingface.co/datasets/tcjszy/cn-patent-text2sql-es-dataset)
62
+ - 评测对比表(Base vs SFT vs SFT + Agent Self-Correction):将在第 5 步全量自动化评测后补充更新。