Text Generation
Transformers
Safetensors
Chinese
English
qwen3
financial
chinese
lora
knowledge-extraction
conversational
text-generation-inference
Instructions to use USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B") 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-V2-Qwen3-8B") model = AutoModelForCausalLM.from_pretrained("USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B", 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-V2-Qwen3-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B" # 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-V2-Qwen3-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B
- SGLang
How to use USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B 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-V2-Qwen3-8B" \ --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-V2-Qwen3-8B", "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-V2-Qwen3-8B" \ --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-V2-Qwen3-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B with Docker Model Runner:
docker model run hf.co/USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B
添加模型卡
Browse files
README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- zh
|
| 4 |
+
- en
|
| 5 |
+
license: other
|
| 6 |
+
license_name: project-internal
|
| 7 |
+
license_link: https://huggingface.co/USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B
|
| 8 |
+
library_name: transformers
|
| 9 |
+
pipeline_tag: text-generation
|
| 10 |
+
base_model: Qwen/Qwen3-8B
|
| 11 |
+
tags:
|
| 12 |
+
- financial
|
| 13 |
+
- chinese
|
| 14 |
+
- qwen3
|
| 15 |
+
- lora
|
| 16 |
+
- knowledge-extraction
|
| 17 |
+
datasets:
|
| 18 |
+
- USTC-KnowledgeComputingLab/FinLLM-EvalSets
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# FinLLM-V2-Qwen3-8B
|
| 22 |
+
|
| 23 |
+
金融领域大模型 V2.0。以 Qwen3-8B 为基座做 LoRA 微调后合并权重,同时承担两类任务:金融选择题问答与知识抽取(输出结构化 JSON)。
|
| 24 |
+
|
| 25 |
+
本仓库提供的是**LoRA 已合并的完整权重**,可直接用 `transformers` 加载,不需要 `peft`,也不需要额外适配器。
|
| 26 |
+
|
| 27 |
+
## 模型信息
|
| 28 |
+
|
| 29 |
+
| 项目 | 设定 |
|
| 30 |
+
|---|---|
|
| 31 |
+
| 基座 | Qwen3-8B |
|
| 32 |
+
| 参数量 | 8.19B(16,381,470,720 字节,bf16) |
|
| 33 |
+
| 架构 | Qwen3ForCausalLM(hidden 4096,36 层) |
|
| 34 |
+
| 精度 | bfloat16 |
|
| 35 |
+
| 训练方式 | LoRA(r=16,α=32,作用于 7 个投影层)后合并 |
|
| 36 |
+
| 可训练参数 | 约 0.53% |
|
| 37 |
+
| 训练轮数 | 2 epoch(按验证损失选第 2 轮) |
|
| 38 |
+
| 学习率 | 1e-4 |
|
| 39 |
+
| 序列长度 | 4096 |
|
| 40 |
+
| 批大小 | 单卡 4,梯度累积 4 |
|
| 41 |
+
|
| 42 |
+
训练数据为三类混合:知识抽取指令数据(四元组 JSON)、金融概念选择题、专项补强题。混合的目的是在学习抽取格式的同时不损失选择题能力。
|
| 43 |
+
|
| 44 |
+
## 两个任务
|
| 45 |
+
|
| 46 |
+
### 选择题
|
| 47 |
+
|
| 48 |
+
验证集、5-shot、贪心解码、`max_new_tokens=16`:
|
| 49 |
+
|
| 50 |
+
| 基准 | 题数 | 结果 |
|
| 51 |
+
|---|---|---|
|
| 52 |
+
| C-Eval 金融 4 科 | 186 | 132/186 = 70.97% |
|
| 53 |
+
| FinEval 金融学术知识 | 1,151 | 857/1,151 = 74.46% |
|
| 54 |
+
|
| 55 |
+
C-Eval 4 科明细:大学经济学 65.45%、工商管理 81.82%、注册会计师 71.43%、税务师 69.39%。
|
| 56 |
+
|
| 57 |
+
H100 + torch 2.8 上复测结果与上述完全一致(132/186、857/1,151,逐科零偏差)。
|
| 58 |
+
|
| 59 |
+
### 知识抽取
|
| 60 |
+
|
| 61 |
+
从金融文本中抽取「主体 / 指标 / 时间 / 数值」四元组,输出 JSON。测试集 2,500 条,字段级评测:
|
| 62 |
+
|
| 63 |
+
| 指标 | 结果 |
|
| 64 |
+
|---|---|
|
| 65 |
+
| 精确率 | 7,754/7,987 = 97.08% |
|
| 66 |
+
| 召回率 | 7,754/8,182 = 94.77% |
|
| 67 |
+
| F1 | 95.91% |
|
| 68 |
+
|
| 69 |
+
分字段:主体 82.4%、指标 96.5%、时间 99.2%、数值 96.5%(主体是已知弱项,抽取粒度偏粗)。
|
| 70 |
+
|
| 71 |
+
## 使用方法
|
| 72 |
+
|
| 73 |
+
**必须关闭思考模式。** Qwen3 默认开启 thinking,在本项目的评测口径下会因输出预算被截断而拿不到答案:
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 77 |
+
|
| 78 |
+
model_id = "USTC-KnowledgeComputingLab/FinLLM-V2-Qwen3-8B"
|
| 79 |
+
tok = AutoTokenizer.from_pretrained(model_id)
|
| 80 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="bfloat16", device_map="cuda")
|
| 81 |
+
|
| 82 |
+
msgs = [{"role": "user", "content": "你好"}]
|
| 83 |
+
text = tok.apply_chat_template(msgs, tokenize=False,
|
| 84 |
+
add_generation_prompt=True,
|
| 85 |
+
enable_thinking=False)
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
需要 `transformers >= 4.51`,低于此版本会报架构不识别。
|
| 89 |
+
|
| 90 |
+
## 已知限制
|
| 91 |
+
|
| 92 |
+
- 未做人类偏好对齐
|
| 93 |
+
- 知识抽取偶发不按 JSON 格式输出(实测约 1.7%),直接给出数值字符串,下游解析需要容错
|
| 94 |
+
- 长文本中的同名多主体场景,主体归属可能判错
|
| 95 |
+
- 金融数值、日期可能出错,需回原文核对
|
| 96 |
+
|
| 97 |
+
## 许可证
|
| 98 |
+
|
| 99 |
+
基座 Qwen3-8B 采用 Apache-2.0。本微调权重的使用范围受项目约定与训练语料许可约束:训练与评测涉及 CC BY-NC-SA 4.0 许可的基准数据,**不得用于商业用途**。商业授权请联系项目组。
|
| 100 |
+
|
| 101 |
+
评测所用的 C-Eval、FinEval 数据遵循各自原始许可,引用时请注明原始基准与论文。
|