Instructions to use USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT") model = AutoModelForCausalLM.from_pretrained("USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT
- SGLang
How to use USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT with Docker Model Runner:
docker model run hf.co/USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT
FinLLM-V1-Qwen2.5-7B-SFT
金融领域大模型 V1.0。以 Qwen2.5-7B 为基座做全参数监督微调,用于金融文本理解与知识型问答。
本仓库提供的是已合并的完整权重,可直接用 transformers 加载,不需要额外的 LoRA 适配器。
模型信息
| 项目 | 设定 |
|---|---|
| 基座 | Qwen2.5-7B |
| 参数量 | 7.62B(15,231,233,024 字节,bf16) |
| 架构 | Qwen2ForCausalLM(hidden 3584,28 层) |
| 精度 | bfloat16 |
| 训练方式 | 全参数监督微调(DeepSpeed ZeRO-3) |
| 训练轮数 | 1 epoch |
| 学习率 | 1e-5,cosine 调度,warmup 0.1 |
| 序列长度 | 1024 |
| 批大小 | 单卡 1,梯度累积 16 |
训练数据为金融领域问答语料(上市公司基本面、指标问答、多跳推理),不含评测基准的选择题。
评测结果
在验证集、5-shot、贪心解码、max_new_tokens=16 的统一口径下:
| 基准 | 题数 | 结果 |
|---|---|---|
| C-Eval 金融 4 科 | 186 | 134/186 = 72.04% |
| FinEval 金融学术知识 | 1,151 | 885/1,151 = 76.89% |
C-Eval 4 科明细:大学经济学 60.00%、工商管理 72.73%、注册会计师 85.71%、税务师 71.43%。
同一份权重在 H100 + torch 2.8 上复测为 136/186 = 73.12%、886/1,151 = 76.98%,差异来自跨硬件的浮点累加顺序,同机重复三次结果逐题一致。
逐科参考值见评测数据集仓库中的说明。
使用方法
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "USTC-KnowledgeComputingLab/FinLLM-V1-Qwen2.5-7B-SFT"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="bfloat16", device_map="cuda")
msgs = [{"role": "user", "content": "简述商业银行流动性覆盖率的核心要求。"}]
text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
out = model.generate(**tok(text, return_tensors="pt").to(model.device),
max_new_tokens=256, do_sample=False)
print(tok.decode(out[0][len(tok(text)["input_ids"]):], skip_special_tokens=True))
需要 transformers >= 4.45。
已知限制
- 未做人类偏好对齐,输出不保证符合合规表述要求
- 金融数值与日期可能出错,涉及金额、比例、时点的结论需回原文核对
- 训练语料以中文为主,英文金融文本能力弱于中文
- 本模型未参与知识抽取任务训练,用于结构化抽取任务时不会输出 JSON
许可证
本模型以 CC BY-NC-SA 4.0(署名—非商业性使用—相同方式共享 4.0 国际)发布。
- 署名:使用时请注明模型来源与本项目名称,并附仓库链接
- 非商业:不得用于商业目的。商业授权请联系项目组
- 相同方式共享:基于本模型的衍生作品须以相同许可发布
基座 Qwen2.5-7B 本身采用 Apache-2.0,其许可条款不因本发布而改变。本仓库的微调权重采用 CC BY-NC-SA 4.0,与训练、评测所用基准数据的许可保持一致。
评测所用的 C-Eval、FinEval 数据遵循各自原始许可,引用时请注明原始基准与论文。
- Downloads last month
- 222