Instructions to use RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf", filename="gemma2-2b-fraud.IQ4_NL.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M # Run inference directly in the terminal: llama-cli -hf RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M # Run inference directly in the terminal: llama-cli -hf RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M
Use Docker
docker model run hf.co/RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf with Ollama:
ollama run hf.co/RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M
- Unsloth Studio new
How to use RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf to start chatting
- Docker Model Runner
How to use RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf with Docker Model Runner:
docker model run hf.co/RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M
- Lemonade
How to use RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull RichardErkhov/jslin09_-_gemma2-2b-fraud-gguf:Q4_K_M
Run and chat with the model
lemonade run user.jslin09_-_gemma2-2b-fraud-gguf-Q4_K_M
List all available models
lemonade list
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Quantization made by Richard Erkhov.
gemma2-2b-fraud - GGUF
- Model creator: https://huggingface.co/jslin09/
- Original model: https://huggingface.co/jslin09/gemma2-2b-fraud/
| Name | Quant method | Size |
|---|---|---|
| gemma2-2b-fraud.Q2_K.gguf | Q2_K | 1.15GB |
| gemma2-2b-fraud.Q3_K_S.gguf | Q3_K_S | 1.27GB |
| gemma2-2b-fraud.Q3_K.gguf | Q3_K | 1.36GB |
| gemma2-2b-fraud.Q3_K_M.gguf | Q3_K_M | 1.36GB |
| gemma2-2b-fraud.Q3_K_L.gguf | Q3_K_L | 1.44GB |
| gemma2-2b-fraud.IQ4_XS.gguf | IQ4_XS | 1.47GB |
| gemma2-2b-fraud.Q4_0.gguf | Q4_0 | 1.52GB |
| gemma2-2b-fraud.IQ4_NL.gguf | IQ4_NL | 1.53GB |
| gemma2-2b-fraud.Q4_K_S.gguf | Q4_K_S | 1.53GB |
| gemma2-2b-fraud.Q4_K.gguf | Q4_K | 1.59GB |
| gemma2-2b-fraud.Q4_K_M.gguf | Q4_K_M | 1.59GB |
| gemma2-2b-fraud.Q4_1.gguf | Q4_1 | 1.64GB |
| gemma2-2b-fraud.Q5_0.gguf | Q5_0 | 1.75GB |
| gemma2-2b-fraud.Q5_K_S.gguf | Q5_K_S | 1.75GB |
| gemma2-2b-fraud.Q5_K.gguf | Q5_K | 1.79GB |
| gemma2-2b-fraud.Q5_K_M.gguf | Q5_K_M | 1.79GB |
| gemma2-2b-fraud.Q5_1.gguf | Q5_1 | 1.87GB |
| gemma2-2b-fraud.Q6_K.gguf | Q6_K | 2.0GB |
| gemma2-2b-fraud.Q8_0.gguf | Q8_0 | 2.59GB |
Original model description:
license: gemma datasets: - jslin09/Fraud_Case_Verdicts language: - zh base_model: - google/gemma-2-2b pipeline_tag: text-generation text-generation: parameters: max_length: 400 max_new_tokens: 400 do_sample: true temperature: 0.75 top_k: 50 top_p: 0.9 tags: - legal widget: - text: 王大明意圖為自己不法所有,基於竊盜之犯意, example_title: 生成竊盜罪之犯罪事實 - text: 騙人布意圖為自己不法所有,基於詐欺取財之犯意, example_title: 生成詐欺罪之犯罪事實 - text: 梅友乾明知其無資力支付酒店消費,亦無付款意願,竟意圖為自己不法之所有, example_title: 生成吃霸王餐之詐欺犯罪事實 - text: 闕很大明知金融帳戶之存摺、提款卡及密碼係供自己使用之重要理財工具, example_title: 生成賣帳戶幫助詐欺犯罪事實 - text: 通訊王明知近來盛行以虛設、租賃、借用或買賣行動電話人頭門號之方式,供詐騙集團作為詐欺他人交付財物等不法用途, example_title: 生成賣電話SIM卡之幫助詐欺犯罪事實 - text: 趙甲王基於行使偽造特種文書及詐欺取財之犯意, example_title: 偽造特種文書(契約、車牌等)詐財 library_name: transformers
判決書「犯罪事實」欄草稿自動生成
本模型是以司法院公開之「詐欺」案件判決書做成之資料集,基於 Google Gemma2:2b 模型進行微調訓練,可以自動生成詐欺及竊盜案件之犯罪事實段落之草稿。資料集之資料範圍從100年1月1日至110年12月31日,所蒐集到的原始資料共有 74823 篇(判決以及裁定),我們只取判決書的「犯罪事實」欄位內容,並把這原始的資料分成三份,用於訓練的資料集有59858篇,約佔原始資料的80%,剩下的20%,則是各分配10%給驗證集(7482篇),10%給測試集(7483篇)。在本網頁進行測試時,請在模型載入完畢並生成第一小句後,持續按下Compute按鈕,就能持續生成文字。或是輸入自己想要測試的資料到文字框中進行測試。或是可以到這裡有更完整的使用體驗。
使用範例
如果要在自己的程式中調用本模型,可以參考下列的 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")
致謝
微調本模型所需要的算力,是由評律網提供 NVIDIA H100。特此致謝。
引文訊息
@misc{lin2024legal,
title={Legal Documents Drafting with Fine-Tuned Pre-Trained Large Language Model},
author={Chun-Hsien Lin and Pu-Jen Cheng},
year={2024},
eprint={2406.04202},
archivePrefix={arXiv},
primaryClass={cs.CL}
url = {https://arxiv.org/abs/2406.04202}
}
- Downloads last month
- 241
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit