aashish1904's picture
Upload README.md with huggingface_hub
8a4e375 verified
---
base_model: meta-llama/Llama-3.2-3B-Instruct
library_name: sft
datasets:
- lianghsun/tw-emergency-medicine-bench
- lianghsun/tw-legal-nlp
- lianghsun/tw-structured-law-article
- lianghsun/tw-legal-synthetic-qa
- lianghsun/tw-law-article-qa
- lianghsun/tw-judgment-qa
- lianghsun/tw-bar-examination-2020-chat
tags:
- legal
- TW
- Taiwan
- ROC
license: llama3.2
language:
- zh
pipeline_tag: text-generation
---
[![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
# QuantFactory/Llama-3.2-Taiwan-Legal-3B-Instruct-GGUF
This is quantized version of [lianghsun/Llama-3.2-Taiwan-Legal-3B-Instruct](https://huggingface.co/lianghsun/Llama-3.2-Taiwan-Legal-3B-Instruct) created using llama.cpp
# Original Model Card
# Model Card for Model lianghsun/Llama-3.2-Taiwan-Legal-3B-Instruct
![Training Status](https://img.shields.io/badge/training-in%20progress-orange) ![Epoch Progress](https://img.shields.io/badge/epoch-10%25-yellow) ![Welcome Feedback](https://img.shields.io/badge/welcome-feedback-brightgreen)
![image/png](https://cdn-uploads.huggingface.co/production/uploads/618dc56cbc345ca7bf95f3cd/W6-UDg0_cNm4WJVlR9tiD.png)
基於 [meta-llama/Llama-3.2-3B-Instruct](meta-llama/Llama-3.2-3B-Instruct) 模型,透過中華民國台灣法律條文及判決書等相關資料集進行微調。
## Model Details
### Model Description
基於 [meta-llama/Llama-3.2-3B-Instruct](meta-llama/Llama-3.2-3B-Instruct) 模型,此微調過程使用了來自中華民國台灣的法律條文與相關判決書資料集,以提升模型在法律領域的專業知識與應用能力。這些資料集涵蓋了法律條文的結構、判決書的格式,法庭上常見的法律語言與術語,並包含了部分法律資料科學任務的應用,使模型能夠更準確地理解和處理與台灣法律體系相關的問題。經過這些微調,模型將能夠更好地為法律專業人士提供幫助,並在台灣法制框架內提供更精準的回應與建議。
- **Developed by:** [Huang Liang Hsun](https://www.linkedin.com/in/lianghsunhuang)
- **Model type:** LlamaForCausalLM
- **Language(s) (NLP)**: 主要處理繁體中文(zh-tw),針對中華民國台灣的法律用語與判決書進行微調。
- **License**: [llama3.2](https://huggingface.co/meta-llama/Llama-3.2-1B/blob/main/LICENSE.txt)
- **Finetuned from model**: [meta-llama/Llama-3.2-3B-Instruct](meta-llama/Llama-3.2-3B-Instruct)
### Model Sources
- **Repository:** [lianghsun/Llama-3.2-Taiwan-Legal-3B-Instruct](https://huggingface.co/lianghsun/Llama-3.2-Taiwan-Legal-3B-Instruct)
- **Demo:** (WIP)
## Uses
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
### Direct Use
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
此模型可以直接用於理解和生成繁體中文法律文本,適合需要處理台灣法律相關問題的應用場景。模型預設的指令和回應能夠有效提供法律資訊、釐清法律條文、並生成符合法律專業的回應。其直接使用範圍包括但不限於法律資訊查詢、法律文本摘要、和基本的法條對話。
### Downstream Use
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
經過微調後,該模型可用於更具體的法律任務,如自動判決書分析、法律實體識別(NER)、法規編號轉換,以及法律合規審查輔助。此模型可以無縫集成至法律數據科學應用或法律技術(LegalTech)系統中,幫助法律專業人士或企業提升工作效率。
### Out-of-Scope Use
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
該模型並不適用於非法律相關領域的生成任務,且不應用於進行可能涉及誤導或錯誤的法律建議,尤其是在未經專業審查的情況下。避免將模型用於未經授權或非法用途,如生成具爭議性或具偏見的法律建議。
## Bias, Risks, and Limitations
模型在生成法律條文和判決書內容時,可能會生成虛構或不存在的法條或判決書內容,這是模型的內在限制之一。使用者在參考這些資料時,應謹慎檢查生成的內容,並避免將模型輸出視為法律依據。建議在實際應用中,將模型生成的結果與可靠的法律見解和來源進行比對,確保準確性、合法性和適用性。
### Recommendations
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
此模型雖然經過法律文本的微調,但在於法律文本的數量及基礎模型為 SLM,模型能力仍有極限,使用者應注意以下風險與限制:
1. **偏見風險**
模型可能會反映其訓練資料中的潛在偏見。由於法律文本的特定性,模型可能更熟悉某些法規、條文或判決案例,而在其他領域表現較弱。特別是在處理不常見的法律問題或未被訓練過的新法規時,模型的輸出可能會帶有偏見。
2. **技術限制**
雖然模型能夠處理大部分的法律文本,但對於結構極其複雜或語言模棱兩可的法律條文,模型可能無法產生精確的回答。使用者應避免完全依賴模型的輸出,尤其在法律決策過程中,建議進行額外的專業檢查。
3. **法律責任**
模型並非專業法律顧問,因此其生成的回應不應被視為正確的法律建議。使用者應確保在理性且專業背景下進行模型的應用,並避免在關鍵決策中過度依賴模型。
4. **誤用風險**
不當使用模型進行錯誤或誤導性的法律建議,可能對個人或企業造成負面影響。使用者應謹慎應用模型於合規或法律相關任務中,並保持對其輸出的檢視及校正。
為了減少這些風險,建議使用者在應用模型輸出時進行二次檢查,特別是在涉及法律決策的情境中。本模型現階段為提供法律科技領域進行大語言模型研究,並非取代專業法律工作者之專業建議。
## How to Get Started with the Model
### Using vLLM
要使用 [vLLM Docker image](https://docs.vllm.ai/en/latest/serving/deploying_with_docker.html) 來啟動此模型,您可以按照以下操作:
```
docker run --runtime nvidia --gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HUGGING_FACE_HUB_TOKEN=<secret>" \
-p 8000:8000 \
--ipc=host \
vllm/vllm-openai:latest \
--model lianghsun/Llama-3.2-Taiwan-Legal-3B-Instruct
```
## Training Details
### Training Data
- [lianghsun/tw-legal-nlp](https://huggingface.co/datasets/lianghsun/tw-legal-nlp)
- [lianghsun/tw-structured-law-article](https://huggingface.co/datasets/lianghsun/tw-structured-law-article)
- [lianghsun/tw-legal-synthetic-qa](https://huggingface.co/datasets/lianghsun/tw-legal-synthetic-qa)
- [lianghsun/tw-law-article-qa](https://huggingface.co/datasets/lianghsun/tw-law-article-qa)
- [lianghsun/tw-judgment-qa](https://huggingface.co/datasets/lianghsun/tw-judgment-qa)
- [lianghsun/tw-bar-examination-2020-chat](https://huggingface.co/datasets/lianghsun/tw-bar-examination-2020-chat)
- [lianghsun/tw-emergency-medicine-bench](https://huggingface.co/datasets/lianghsun/tw-emergency-medicine-bench)
### Training Procedure
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
#### Preprocessing
無。基本上我們並沒有針對 [meta-llama/Llama-3.2-3B-Instruct](meta-llama/Llama-3.2-3B-Instruct) 做任何的預訓練或更改其模型架構;Tokenizer 也是採用原生所提供的。
#### Training Hyperparameters
- **Training regime**: bf16 mixed precision
- **Learning rate**: 5e-06
- **Batch size**: 6 (per device)
- **Epochs**: 10 *(Note: 由於算力成本考量,在 `epoch: 0.78` 就停止訓練)*
- **Gradient accumulation steps**: 8
- **Cutoff length**: 2048
- **Scheduler**: cosine
- **Optimizer**: adamw_torch
- **Max gradient norm**: 1.0
- **Warmup steps**: 100
- **Logging steps**: 5
- **Save steps**: 1000
- **Max samples**: 1,500,000
#### Speeds, Sizes, Times
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
*Note: 由於算力成本考量,在 `epoch: 0.78` 就停止訓練,故以下資訊會有部份缺陷及不具參考價值*
- **Duration**: 6h 12m 13s
- **Train runtime**: 22,333 seconds
- **Train samples per second**: `nan`
- **Train steps per second**: `nan`
- **Total training FLOPs**: `nan`
- **Train loss**: `nan` (final loss: 0.3377)
## Evaluation
<!-- This section describes the evaluation protocols and provides the results. -->
**Note**: ..(WIP)..
### Testing Data, Factors & Metrics
#### Testing Data
<!-- This should link to a Dataset Card if possible. -->
**Note**: ..(WIP)..
#### Factors
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
**Note**: ..(WIP)..
#### Metrics
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
**Note**: ..(WIP)..
### Results
**Note**: ..(WIP)..
#### Summary
**Note**: ..(WIP)..
## Model Examination
### 法條回覆
**Note**: ..(WIP)..
### 判決書內容
**Note**: ..(WIP)..
### 法律 NLP 任務
**Note**: ..(WIP)..
## Environmental Impact
- **Hardware Type:** 8 x NVIDIA A100 40GB
- **Hours used:** 6.03 hours
- **Cloud Provider:** Google Cloud Platform
- **Compute Region:** us-central1-c
- **Carbon Emitted:** `0.86 kgCO$_2$eq`
## Technical Specifications
### Model Architecture and Objective
本模型基於 `meta-llama/Llama-3.2-3B-Instruct`,使用自回歸 Transformer 架構進行語言建模。該模型的主要目標是提升對台灣法律文本的理解與生成能力,尤其是針對判決書、法條的專業處理與應用。透過專門設計的法律文本集進行微調,模型能更精確地回答法律問題並提供相關建議。
### Compute Infrastructure
#### Hardware
- 8 x NVIDIA A100 40GB
#### Software
- 微調過程使用了 [hiyouga/LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory) 框架進行訓練。
## Citation
無。
## Glossary
無。
## More Information
### 算力
儘管我們已準備了許多關於中華民國台灣法律領域的資料集,但由於算力資源有限,**無法將所有資料集進行完整訓練**(是的,我們並沒有將全部資料集都進行訓練,僅取出被認為最基礎的法律文本),導致模型尚未達到最佳表現。因此,目前的 checkpoint 是基於有限資源的版本。如果您有意願贊助算力,歡迎與我聯繫。我相信,若能將更多已準備但尚未納入訓練的法律語料進行微調,該模型將能達到繁體中文法律領域的最佳表現。
**另外**,和 [lianghsun/Llama-3.2-Taiwan-Legal-1B-Instruct](https://huggingface.co/lianghsun/Llama-3.2-Taiwan-Legal-1B-Instruct) 相較之下,又因為算力成本考量, [lianghsun/Llama-3.2-Taiwan-Legal-3B-Instruct](https://huggingface.co/lianghsun/Llama-3.2-Taiwan-Legal-3B-Instruct) 未訓練到 1 epoch,所以在表現上又更加不如預期。
### 持績更新
此模型如有進一步資源,將會不定期更新。
## Model Card Authors
[Huang Liang Hsun](https://www.linkedin.com/in/lianghsunhuang)
## Model Card Contact
[Huang Liang Hsun](https://www.linkedin.com/in/lianghsunhuang)
### Framework versions
- PEFT 0.12.0