Kanana Legal FP16 GGUF

This is a FP16 GGUF quantized version of the Korean Legal fine-tuned model based on Kakao's Kanana Nano 2.1B Instruct.

🎯 Model Overview

This ultra-lightweight 2.1B parameter model has been fine-tuned on Korean legal terminology to run efficiently on CPU-only environments without internet connectivity, making it ideal for offline legal document processing in restricted environments.

Key Features

  • βœ… CPU-Optimized: Designed for CPU inference without GPU requirements
  • βœ… Offline Capable: No internet connection needed for inference
  • βœ… Legal Domain: Fine-tuned on 17,484 Korean legal term definitions
  • βœ… GGUF Format: Compatible with llama.cpp and other GGUF-compatible tools
  • βœ… FP16 Precision: Full 16-bit floating point precision for maximum accuracy

πŸ“Š Training Data

The model was fine-tuned on the Korean Legal Terminology dataset:

  • Samples: 17,484 legal term definitions
  • Format: Instruction-following (input/output pairs)
  • Domain: Korean legal terminology, concepts, and definitions
  • Language: Korean

πŸ”§ Fine-tuning Details

Base Model

Training Configuration

QLoRA Settings:

  • Quantization Type: NF4 (Normal Float 4-bit)
  • Compute dtype: bfloat16
  • Double Quantization: Enabled
  • LoRA Rank (r): 16
  • LoRA Alpha: 32
  • Target Modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
  • LoRA Dropout: 0.05
  • Trainable Parameters: ~23M (1.95% of total)

Training Hyperparameters:

  • Epochs: 3
  • Batch Size: 4 (per device)
  • Gradient Accumulation Steps: 4
  • Effective Batch Size: 16
  • Optimizer: Paged AdamW 8-bit
  • Learning Rate: 2e-4
  • LR Scheduler: Cosine
  • Warmup Ratio: 0.03
  • Weight Decay: 0.01
  • Max Gradient Norm: 0.3
  • Mixed Precision: bfloat16
  • Max Sequence Length: 2048

Optimization Techniques

  • Gradient Checkpointing: Reduces memory during backpropagation
  • Paged Optimizers: Efficient memory management for optimizer states
  • Mixed Precision: bfloat16 for faster computation
  • Gradient Accumulation: Simulates larger batch sizes

πŸ’» Usage

Requirements

# Install llama.cpp or compatible GGUF runtime
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make

Inference Example

# Run with llama.cpp
./main -m kanana-legal-f16.gguf -p "### 질문:\nλ‹€μŒ 법λ₯  μš©μ–΄λ₯Ό μ„€λͺ…ν•΄μ€˜: ν‘μˆ˜ν•©λ³‘\n\n### λ‹΅λ³€:" -n 512

# English: "Question: Explain the following legal term: Merger by Absorption"

Python Usage (with llama-cpp-python)

from llama_cpp import Llama

# Load model
llm = Llama(
    model_path="kanana-legal-f16.gguf",
    n_ctx=2048,
    n_threads=8,
)

# Generate response
prompt = """### 질문:
λ‹€μŒ 법λ₯  μš©μ–΄λ₯Ό μ„€λͺ…ν•΄μ€˜: ν‘μˆ˜ν•©λ³‘

### λ‹΅λ³€:"""
# English: "Question: Explain the following legal term: Merger by Absorption / Answer:"

output = llm(
    prompt,
    max_tokens=512,
    temperature=0.7,
    top_p=0.9,
)

print(output['choices'][0]['text'])

πŸ“ Prompt Format

The model expects the following instruction format:

### 질문:
λ‹€μŒ 법λ₯  μš©μ–΄(ν•œμž: εΈζ”Άεˆε€‚)λ₯Ό μ„€λͺ…ν•΄μ€˜: ν‘μˆ˜ν•©λ³‘

### λ‹΅λ³€:
법λ₯ μ΄ μ •ν•˜λŠ” μ ˆμ°¨μ— μ˜ν•˜μ—¬ 2 μ΄μƒμ˜ 법인 μ „λΆ€ λ˜λŠ” 그쀑 1개의 λ²•μΈμ΄μ™Έμ˜ 법인이 ν•΄μ‚°ν•˜μ—¬...

English Translation:

### Question:
Explain the following legal term (Hanja: εΈζ”Άεˆε€‚): Merger by Absorption

### Answer:
According to the procedures prescribed by law, when two or more corporations, or all corporations except one, are dissolved...

⚠️ Disclaimer

IMPORTANT: This is an ultra-lightweight 2.1B parameter model designed for CPU-only inference in offline environments. Due to its compact size and training constraints:

  • ❌ Legal information may not be accurate or complete
  • ❌ Should NOT be used as a substitute for professional legal advice
  • ❌ No warranty or liability is provided for any use of this model
  • ❌ Users assume all responsibility for verifying information
  • ⚠️ For informational and educational purposes only

Always consult qualified legal professionals for actual legal matters.

πŸ” Model Variants

This model is available in multiple quantization levels:

Model Size Precision Use Case
kanana-legal-f16 ~4.2GB FP16 Maximum accuracy, higher memory
kanana-legal-q8_0 ~2.2GB Q8_0 Balanced accuracy/size
kanana-legal-q4_k_m ~1.4GB Q4_K_M Smallest size, fastest inference

πŸ“„ License

Apache 2.0 License - This model inherits the license from the base Kanana model.

πŸ™ Acknowledgments

πŸ“š Related Resources

πŸ“§ Contact

For questions or issues, please visit the GitHub repository.

Downloads last month
3
GGUF
Model size
2B params
Architecture
llama
Hardware compatibility
Log In to add your hardware

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for JusWis/kanana-legal-f16

Quantized
(12)
this model

Paper for JusWis/kanana-legal-f16