RichardErkhov
commited on
Commit
•
399e5b7
1
Parent(s):
45b6e3d
uploaded readme
Browse files
README.md
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Quantization made by Richard Erkhov.
|
2 |
+
|
3 |
+
[Github](https://github.com/RichardErkhov)
|
4 |
+
|
5 |
+
[Discord](https://discord.gg/pvy7H8DZMG)
|
6 |
+
|
7 |
+
[Request more models](https://github.com/RichardErkhov/quant_request)
|
8 |
+
|
9 |
+
|
10 |
+
bloom-560m-finetuned-fraud - bnb 8bits
|
11 |
+
- Model creator: https://huggingface.co/jslin09/
|
12 |
+
- Original model: https://huggingface.co/jslin09/bloom-560m-finetuned-fraud/
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
Original model description:
|
18 |
+
---
|
19 |
+
license: bigscience-bloom-rail-1.0
|
20 |
+
datasets:
|
21 |
+
- jslin09/Fraud_Case_Verdicts
|
22 |
+
language:
|
23 |
+
- zh
|
24 |
+
metrics:
|
25 |
+
- accuracy
|
26 |
+
pipeline_tag: text-generation
|
27 |
+
text-generation:
|
28 |
+
parameters:
|
29 |
+
max_length: 400
|
30 |
+
max_new_tokens: 400
|
31 |
+
do_sample: true
|
32 |
+
temperature: 0.75
|
33 |
+
top_k: 50
|
34 |
+
top_p: 0.9
|
35 |
+
tags:
|
36 |
+
- legal
|
37 |
+
widget:
|
38 |
+
- text: 王大明意圖為自己不法所有,基於竊盜之犯意,
|
39 |
+
example_title: 生成竊盜罪之犯罪事實
|
40 |
+
- text: 騙人布意圖為自己不法所有,基於詐欺取財之犯意,
|
41 |
+
example_title: 生成詐欺罪之犯罪事實
|
42 |
+
- text: 梅友乾明知其無資力支付酒店消費,亦無付款意願,竟意圖為自己不法之所有,
|
43 |
+
example_title: 生成吃霸王餐之詐欺犯罪事實
|
44 |
+
- text: 闕很大明知金融帳戶之存摺、提款卡及密碼係供自己使用之重要理財工具,
|
45 |
+
example_title: 生成賣帳戶幫助詐欺犯罪事實
|
46 |
+
- text: 通訊王明知近來盛行以虛設、租賃、借用或買賣行動電話人頭門號之方式,供詐騙集團作為詐欺他人交付財物等不法用途,
|
47 |
+
example_title: 生成賣電話SIM卡之幫助詐欺犯罪事實
|
48 |
+
- text: 趙甲王基於行使偽造特種文書及詐欺取財之犯意,
|
49 |
+
example_title: 偽造特種文書(契約、車牌等)詐財
|
50 |
+
---
|
51 |
+
|
52 |
+
# 判決書「犯罪事實」欄草稿自動生成
|
53 |
+
本模型是以司法院公開之「詐欺」案件判決書做成之資料集,基於 [BLOOM 560m](https://huggingface.co/bigscience/bloom-560m) 模型進行微調訓練,可以自動生成詐欺及竊盜案件之犯罪事實段落之草稿。資料集之資料範圍從100年1月1日至110年12月31日,所蒐集到的原始資料共有 74823 篇(判決以及裁定),我們只取判決書的「犯罪事實」欄位內容,並把這原始的資料分成三份,用於訓練的資料集有59858篇,約佔原始資料的80%,剩下的20%,則是各分配10%給驗證集(7482篇),10%給測試集(7483篇)。在本網頁進行測試時,請在模型載入完畢並生成第一小句後,持續按下Compute按鈕,就能持續生成文字。或是輸入自己想要測試的資料到文字框中進行測試。或是可以到[這裡](https://huggingface.co/spaces/jslin09/legal_document_drafting)有更完整的使用體驗。
|
54 |
+
|
55 |
+
# 使用範例
|
56 |
+
如果要在自己的程式中調用本模型,可以參考下列的 Python 程式碼,藉由呼叫 API 的方式來生成刑事判決書「犯罪事實」欄的內容。
|
57 |
+
<details>
|
58 |
+
<summary> 點擊後展開 </summary>
|
59 |
+
<pre>
|
60 |
+
<code>
|
61 |
+
import requests, json
|
62 |
+
from time import sleep
|
63 |
+
from tqdm.auto import tqdm, trange
|
64 |
+
|
65 |
+
API_URL = "https://api-inference.huggingface.co/models/jslin09/bloom-560m-finetuned-fraud"
|
66 |
+
API_TOKEN = 'XXXXXXXXXXXXXXX' # 調用模型的 API token
|
67 |
+
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
68 |
+
|
69 |
+
def query(payload):
|
70 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
71 |
+
return json.loads(response.content.decode("utf-8"))
|
72 |
+
|
73 |
+
prompt = "森上梅前明知其無資力支付酒店消費,亦無付款意願,竟意圖為自己不法之所有,"
|
74 |
+
query_dict = {
|
75 |
+
"inputs": prompt,
|
76 |
+
}
|
77 |
+
text_len = 300
|
78 |
+
t = trange(text_len, desc= '生成例稿', leave=True)
|
79 |
+
for i in t:
|
80 |
+
response = query(query_dict)
|
81 |
+
try:
|
82 |
+
response_text = response[0]['generated_text']
|
83 |
+
query_dict["inputs"] = response_text
|
84 |
+
t.set_description(f"{i}: {response[0]['generated_text']}")
|
85 |
+
t.refresh()
|
86 |
+
except KeyError:
|
87 |
+
sleep(30) # 如果伺服器太忙無回應,等30秒後再試。
|
88 |
+
pass
|
89 |
+
print(response[0]['generated_text'])
|
90 |
+
</code>
|
91 |
+
</pre>
|
92 |
+
</details>
|
93 |
+
|
94 |
+
或是,你要使用 transformers 套件來實作你的程式,將本模型下載至你本地端的電腦中執行,可以參考下列程式碼:
|
95 |
+
<details>
|
96 |
+
<summary> 點擊後展開 </summary>
|
97 |
+
<pre>
|
98 |
+
<code>
|
99 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
100 |
+
|
101 |
+
tokenizer = AutoTokenizer.from_pretrained("jslin09/bloom-560m-finetuned-fraud")
|
102 |
+
model = AutoModelForCausalLM.from_pretrained("jslin09/bloom-560m-finetuned-fraud")
|
103 |
+
</code>
|
104 |
+
</pre>
|
105 |
+
</details>
|
106 |
+
|
107 |
+
# 本模型進行各項指標進行評估的結果如下 [Open LLM Leaderboard Evaluation Results](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
|
108 |
+
詳細的結果在 [這裡](https://huggingface.co/datasets/open-llm-leaderboard/details_jslin09__bloom-560m-finetuned-fraud)。
|
109 |
+
本模型只使用範圍相當小的資料集進行微調,就任務目標來說,已經是完美解決,但就廣泛的通用性來說,其實是不完美的。總的來說,如果應用場景是需要把模型建置在本地端、不能���到外部網路、提示字資料也不能外送的情境下,本模型的建置過程及結果提供了一個可行性的示範。
|
110 |
+
|
111 |
+
| Metric | Value |
|
112 |
+
|-----------------------|---------------------------|
|
113 |
+
| Avg. | 18.37 |
|
114 |
+
| ARC (25-shot) | 26.96 |
|
115 |
+
| HellaSwag (10-shot) | 28.87 |
|
116 |
+
| MMLU (5-shot) | 24.03 |
|
117 |
+
| TruthfulQA (0-shot) | 0.0 |
|
118 |
+
| Winogrande (5-shot) | 48.38 |
|
119 |
+
| GSM8K (5-shot) | 0.0 |
|
120 |
+
| DROP (3-shot) | 0.33 |
|
121 |
+
|
122 |
+
# 引文訊息
|
123 |
+
|
124 |
+
```
|
125 |
+
@misc{lin2024legal,
|
126 |
+
title={Legal Documents Drafting with Fine-Tuned Pre-Trained Large Language Model},
|
127 |
+
author={Chun-Hsien Lin and Pu-Jen Cheng},
|
128 |
+
year={2024},
|
129 |
+
eprint={2406.04202},
|
130 |
+
archivePrefix={arXiv},
|
131 |
+
primaryClass={cs.CL}
|
132 |
+
url = {https://arxiv.org/abs/2406.04202}
|
133 |
+
}
|
134 |
+
```
|
135 |
+
|