sausheong commited on
Commit
20c7340
·
verified ·
1 Parent(s): 4b800e3

Upload 4 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ llama-3.1-8b-lexsg-q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
Modelfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ./llama-3.1-8b-lexsg-q4_k_m.gguf
2
+
3
+ # Model metadata
4
+ TEMPLATE """{{ if .System }}<|start_header_id|>system<|end_header_id|>
5
+
6
+ {{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>
7
+
8
+ {{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>
9
+
10
+ {{ .Response }}<|eot_id|>"""
11
+
12
+ SYSTEM """You are a specialized legal assistant trained on Singapore statutes and legal documents. You have extensive knowledge of Singapore's legal framework and can help users understand legal provisions, explain sections of acts, and answer questions about Singapore law.
13
+
14
+ Key capabilities:
15
+ - Explain legal sections and provisions
16
+ - Answer questions about Singapore statutes
17
+ - Provide context for legal documents
18
+ - Help interpret legal language
19
+ - Assist with understanding regulatory requirements
20
+
21
+ Please provide accurate, helpful responses based on Singapore law. If you're unsure about something, acknowledge the limitation and suggest consulting with a qualified legal professional."""
22
+
23
+ # Model parameters optimized for legal text generation
24
+ PARAMETER temperature 0.3
25
+ PARAMETER top_p 0.9
26
+ PARAMETER top_k 40
27
+ PARAMETER repeat_penalty 1.1
28
+ PARAMETER num_ctx 4096
29
+ PARAMETER num_predict 1024
30
+
31
+ # Stop tokens for Llama 3.1
32
+ PARAMETER stop "<|start_header_id|>"
33
+ PARAMETER stop "<|end_header_id|>"
34
+ PARAMETER stop "<|eot_id|>"
README.md CHANGED
@@ -1,3 +1,96 @@
1
- ---
2
- license: llama3.1
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LexSG - Singapore Legal Assistant Model
2
+
3
+ A specialized AI assistant trained on Singapore statutes and legal documents, built on the Llama 3.1 architecture and optimized for legal text generation.
4
+
5
+ ## Overview
6
+
7
+ LexSG is a fine-tuned language model designed specifically to assist with Singapore legal matters. It provides accurate, contextual responses about Singapore's legal framework and helps users understand complex legal provisions.
8
+
9
+ ## Model Details
10
+
11
+ - **Base Model**: Llama 3.1 8B Instruct
12
+ - **Quantization**: Q4_K_M (4-bit quantized for efficient inference)
13
+ - **Context Length**: 4,096 tokens
14
+ - **Max Generation**: 1,024 tokens
15
+ - **Template**: Llama 3.1 chat format with system/user/assistant roles
16
+
17
+ ## Key Capabilities
18
+
19
+ - **Legal Section Explanation**: Interpret and explain specific sections of Singapore acts and statutes
20
+ - **Statute Queries**: Answer questions about Singapore's legal framework
21
+ - **Legal Context**: Provide background and context for legal documents
22
+ - **Language Interpretation**: Help decode complex legal terminology
23
+ - **Regulatory Guidance**: Assist with understanding compliance requirements
24
+
25
+ ## Model Parameters
26
+
27
+ The model is configured with parameters optimized for legal text generation:
28
+
29
+ - **Temperature**: 0.3 (conservative, factual responses)
30
+ - **Top-p**: 0.9 (nucleus sampling for quality)
31
+ - **Top-k**: 40 (controlled vocabulary selection)
32
+ - **Repeat Penalty**: 1.1 (reduces repetition)
33
+
34
+ ## Usage
35
+
36
+ ### Prerequisites
37
+
38
+ - [Ollama](https://ollama.com/) installed on your system
39
+ - The model file `llama-3.1-8b-lexsg-q4_k_m.gguf` in the same directory
40
+
41
+ ### Running the Model
42
+
43
+ 1. Build the model from the Modelfile:
44
+ ```bash
45
+ ollama create lexsg -f Modelfile
46
+ ```
47
+
48
+ or even simpler just do this:
49
+ ```bash
50
+ ./setup_ollama_model.sh
51
+ ```
52
+
53
+ 2. Run the model:
54
+ ```bash
55
+ ollama run lexsg
56
+ ```
57
+
58
+ 3. Start asking questions about Singapore law:
59
+ ```
60
+ > What does Section 73 of the Companies Act cover?
61
+ > Explain the requirements for setting up a private limited company in Singapore
62
+ > What are the penalties for non-compliance with PDPA?
63
+ ```
64
+
65
+ ## Example Interactions
66
+
67
+ **Query**: "What is the difference between a public and private company under Singapore law?"
68
+
69
+ **Response**: The model will provide detailed explanations based on the Companies Act, highlighting key distinctions in shareholding, disclosure requirements, and regulatory obligations.
70
+
71
+ ## Important Disclaimers
72
+
73
+ ⚠️ **Legal Disclaimer**: This model is designed to provide general information about Singapore law and should not be considered as legal advice. For specific legal matters, always consult with a qualified legal professional licensed to practice in Singapore.
74
+
75
+ - Responses are based on training data and may not reflect the most recent legal changes
76
+ - Legal interpretations can be complex and context-dependent
77
+ - This tool is meant to assist with understanding, not replace professional legal counsel
78
+
79
+ ## Technical Specifications
80
+
81
+ - **Model Size**: ~4.8GB (quantized)
82
+ - **Memory Requirements**: ~6GB RAM recommended
83
+ - **Inference Speed**: Optimized for CPU inference
84
+ - **Platform Support**: Cross-platform via Ollama
85
+
86
+ ## Contributing
87
+
88
+ This model is part of the LexSG project focused on making Singapore legal information more accessible through AI assistance.
89
+
90
+ ## License
91
+
92
+ Please refer to the original Llama 3.1 license terms and any additional restrictions that may apply to the fine-tuned weights.
93
+
94
+ ---
95
+
96
+ *Built with ❤️ for the Singapore legal community*
llama-3.1-8b-lexsg-q4_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:581013a1935cc56194562e2d0aae1e6788445dfba140a81a48e131110afff71c
3
+ size 4920738784
setup_ollama_model.sh ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Setup script for importing the Singapore Statutes model into Ollama
4
+
5
+ MODEL_NAME="lexsg"
6
+ MODELFILE_PATH="./Modelfile"
7
+
8
+ echo "🚀 Setting up LexSG model in Ollama..."
9
+ echo "Model name: $MODEL_NAME"
10
+ echo "Modelfile: $MODELFILE_PATH"
11
+ echo ""
12
+
13
+ # Check if Ollama is installed
14
+ if ! command -v ollama &> /dev/null; then
15
+ echo "❌ Ollama is not installed. Please install Ollama first:"
16
+ echo " curl -fsSL https://ollama.ai/install.sh | sh"
17
+ exit 1
18
+ fi
19
+
20
+ # Check if Ollama service is running
21
+ if ! pgrep -x "ollama" > /dev/null; then
22
+ echo "⚠️ Ollama service is not running. Starting Ollama..."
23
+ ollama serve &
24
+ sleep 3
25
+ fi
26
+
27
+ # Import the model
28
+ echo "📦 Creating model from Modelfile..."
29
+ ollama create $MODEL_NAME -f $MODELFILE_PATH
30
+
31
+ if [ $? -eq 0 ]; then
32
+ echo ""
33
+ echo "✅ SUCCESS! Model '$MODEL_NAME' has been created in Ollama."
34
+ echo ""
35
+ echo "🔧 Usage examples:"
36
+ echo " # Start a chat session"
37
+ echo " ollama run $MODEL_NAME"
38
+ echo ""
39
+ echo " # Ask a specific question"
40
+ echo " ollama run $MODEL_NAME \"What does the Personal Data Protection Act cover?\""
41
+ echo ""
42
+ echo " # Use via API"
43
+ echo " curl http://localhost:11434/api/generate -d '{"
44
+ echo " \"model\": \"$MODEL_NAME\","
45
+ echo " \"prompt\": \"Explain Section 1 of the Companies Act\","
46
+ echo " \"stream\": false"
47
+ echo " }'"
48
+ echo ""
49
+ echo "📋 Model information:"
50
+ ollama show $MODEL_NAME
51
+ else
52
+ echo "❌ Failed to create model. Please check the Modelfile and try again."
53
+ exit 1
54
+ fi