Instructions to use jslin09/gemma2-2b-fraud with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jslin09/gemma2-2b-fraud with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jslin09/gemma2-2b-fraud")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jslin09/gemma2-2b-fraud") model = AutoModelForCausalLM.from_pretrained("jslin09/gemma2-2b-fraud") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use jslin09/gemma2-2b-fraud with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jslin09/gemma2-2b-fraud" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jslin09/gemma2-2b-fraud", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/jslin09/gemma2-2b-fraud
- SGLang
How to use jslin09/gemma2-2b-fraud 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 "jslin09/gemma2-2b-fraud" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jslin09/gemma2-2b-fraud", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "jslin09/gemma2-2b-fraud" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jslin09/gemma2-2b-fraud", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use jslin09/gemma2-2b-fraud with Docker Model Runner:
docker model run hf.co/jslin09/gemma2-2b-fraud
判決書「犯罪事實」欄草稿自動生成
本模型是以司法院公開之「詐欺」案件判決書做成之資料集,基於 Google Gemma2:2b 模型進行微調訓練,可以自動生成詐欺及竊盜案件之犯罪事實段落之草稿。資料集之資料範圍從100年1月1日至110年12月31日,所蒐集到的原始資料共有 74823 篇(判決以及裁定),我們只取判決書的「犯罪事實」欄位內容,並把這原始的資料分成三份,用於訓練的資料集有59858篇,約佔原始資料的80%,剩下的20%,則是各分配10%給驗證集(7482篇),10%給測試集(7483篇)。在本網頁進行測試時,請在模型載入完畢並生成第一小句後,持續按下Compute按鈕,就能持續生成文字。或是輸入自己想要測試的資料到文字框中進行測試。或是可以到這裡有更完整的使用體驗。
比較
以下是本模型與經過微調後的BLOOM 560m、Llama 3.2-1b以 ROUGE-L 做評估後的散點圖。

使用範例
如果要在自己的程式中調用本模型,可以參考下列的 Python 程式碼,藉由呼叫 API 的方式來生成刑事判決書「犯罪事實」欄的內容。
點擊後展開
import requests, json from time import sleep from tqdm.auto import tqdm, trangeAPI_URL = "https://api-inference.huggingface.co/models/jslin09/gemma2-2b-fraud" API_TOKEN = 'XXXXXXXXXXXXXXX' # 調用模型的 API token headers = {"Authorization": f"Bearer {API_TOKEN}"}
def query(payload): response = requests.post(API_URL, headers=headers, json=payload) return json.loads(response.content.decode("utf-8"))
prompt = "森上梅前明知其無資力支付酒店消費,亦無付款意願,竟意圖為自己不法之所有," query_dict = { "inputs": prompt, } text_len = 300 t = trange(text_len, desc= '生成例稿', leave=True) for i in t: response = query(query_dict) try: response_text = response[0]['generated_text'] query_dict["inputs"] = response_text t.set_description(f"{i}: {response[0]['generated_text']}") t.refresh() except KeyError: sleep(30) # 如果伺服器太忙無回應,等30秒後再試。 pass print(response[0]['generated_text'])
或是,你要使用 transformers 套件來實作你的程式,將本模型下載至你本地端的電腦中執行,可以參考下列程式碼:
點擊後展開
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("jslin09/gemma2-2b-fraud")
model = AutoModelForCausalLM.from_pretrained("jslin09/gemma2-2b-fraud")
如果是要使用 Ollama 作為本地端驅動模型的工具,可以使用 Ollama 下載放在 Ollama 網站的已量化(Q4_0)版本 直接使用。
致謝
微調本模型所需要的算力,是由評律網提供 NVIDIA H100。特此致謝。
引文訊息
@article{lin2025assisting,
title={Assisting Drafting of Chinese Legal Documents Using Fine-Tuned Pre-trained Large Language Models},
author={Lin, Chun-Hsien and Cheng, Pu-Jen},
journal={The Review of Socionetwork Strategies},
pages={1--28},
year={2025},
publisher={Springer}
}
- Downloads last month
- 13
Model tree for jslin09/gemma2-2b-fraud
Base model
google/gemma-2-2b