GLM Legal Setup: Step-by-Step Local Deployment Guide - Guides

GLM Legal Setup: Step-by-Step Local Deployment Guide

Set up GLM Legal (law-glm-10b) locally: hardware requirements, Transformers installation, trust_remote_code, and inference configuration.

2026-10-14
GLM Legal Wiki Team
Quick Guide
  • GLM Legal setup covers environment prep, dependency installation, and model loading for law-glm-10b
  • Hardware matters: the 10B model requires roughly 39.5 GB of storage and substantial GPU memory
  • trust_remote_code is required: loading the model executes custom code, so verify the source first
  • Two variants exist: law-glm-10b and law-glm-10b-v2, both hosted under the law-llm Hugging Face organization
  • License is Apache-2.0: suitable for research and many commercial uses, but verify conditions before deployment

GLM Legal Setup Overview: What You Need Before Starting

Setting up GLM Legal locally is a straightforward process if you prepare the right environment first. GLM Legal refers to the GLM-architecture legal-domain models published under the law-llm organization on Hugging Face, principally law-glm-10b and law-glm-10b-v2. Both model pages are publicly accessible and tagged with the Apache-2.0 license.

The setup process differs from a typical small-model workflow in three ways: the parameter scale (10B) demands serious hardware planning, the model files total approximately 39.5 GB, and loading requires the trust_remote_code flag because the model relies on custom modeling code.

Model Basics

  • 10B parameters, GLM architecture
  • Two variants: base and v2
  • Legal-domain fine-tuning for Chinese legal text

Storage Needs

  • ~39.5 GB model file size
  • SSD strongly recommended
  • Additional space for datasets and caches

Software Stack

  • Python 3.8+
  • PyTorch with CUDA support
  • Hugging Face Transformers
Check Before You Download

Confirm you have at least 60 GB of free disk space before starting. The 39.5 GB model download plus Hugging Face cache duplication can consume more space than expected.

The table below summarizes the core facts you should verify before setup:

ItemDetailNotes
Model pagelaw-llm/law-glm-10bPublic on Hugging Face
Variantlaw-glm-10b-v2Updated release, same org
Parameters10BRequires high-VRAM GPU
File size~39.5 GBPlan SSD storage
LicenseApache-2.0Listed on model page
Upstream codeTHUDM/GLMArchitecture reference

Hardware and Software Requirements

GLM Legal setup succeeds or fails at the hardware planning stage. A 10B-parameter model in full precision does not fit on consumer GPUs without quantization, so match your deployment strategy to your available resources.

ConfigurationGPU MemoryMethodBest For
Full precision40+ GBA100 / multi-GPUResearch, fine-tuning
Half precision (fp16)~20-24 GBHigh-end consumer/pro cardsStandard inference
Quantized (INT8/4-bit)~10-14 GBbitsandbytes / GPTQBudget local setups
CPU onlyN/AVery slow inferenceTesting only, not practical

On the software side, you need a Python environment with PyTorch built for your CUDA version, the Transformers library, and the standard Hugging Face tooling (huggingface_hub, tokenizers, accelerate for device management).

VRAM Reality Check

Do not attempt full-precision loading on GPUs with less than 40 GB of VRAM. Use half precision or quantization instead, or the load will fail with an out-of-memory error after a long download.

Verify your environment before downloading the model. A quick checklist:

Pre-Setup Environment Checklist:

  • Python 3.8 or newer installed
  • CUDA-capable GPU with current drivers
  • PyTorch installed with CUDA support
  • At least 60 GB free SSD storage
  • Stable internet connection for 39.5 GB download

Step-by-Step GLM Legal Installation

Follow this sequence to go from a clean machine to a working inference environment. Each step builds on the previous one, so do not skip ahead.

1

Create an isolated environment

Set up a dedicated virtual environment using venv or conda so GLM Legal dependencies do not conflict with other projects. Activate it before installing anything.

2

Install PyTorch with CUDA

Install the PyTorch build matching your CUDA version from the official PyTorch index. Confirm GPU visibility with a quick tensor-to-CUDA test before continuing.

3

Install Transformers and dependencies

Install the Hugging Face Transformers library along with accelerate and huggingface_hub. These handle model downloading, device placement, and tokenizer loading.

4

Download the model weights

Pull law-glm-10b or law-glm-10b-v2 from the Hugging Face model page. The full set of files totals roughly 39.5 GB, so run the download in a stable session or use resumable transfer.

5

Load with trust_remote_code

Load the model and tokenizer with trust_remote_code=True. GLM Legal ships custom modeling code that Transformers executes at load time, and loading fails without this flag.

6

Run a first inference test

Feed a short Chinese legal question or clause-extraction prompt, verify the output shape and coherence, and record baseline generation settings for later tuning.

Installation Tip

Use a Hugging Face access token and enable transfer resumption when downloading. A failed 39.5 GB download without resume support wastes hours.

trust_remote_code: What It Does and How to Stay Safe

The trust_remote_code parameter is the single most misunderstood part of GLM Legal setup. Because GLM Legal's architecture includes custom Python code hosted with the model repository, Transformers must download and execute that code when loading the model. The flag is your explicit consent to this behavior.

AspectWhat HappensRecommended Practice
Load behaviorCustom modeling code runs locallyRead the repo code before first load
Source controlCode comes from law-llm orgPin the revision you reviewed
Repeat runsCode cached after first downloadRe-verify after updates
Sharing envsCode runs with your permissionsUse isolated environments
Security Note

Never set trust_remote_code=True on unverified or mirrored repositories. Review the repository files on the official law-llm model pages, and pin a specific commit revision in production so the executed code cannot silently change.

For teams deploying GLM Legal in shared infrastructure, sandbox the loading environment, log the revision hash used, and document the review in your deployment record. This turns a security question into a routine procedural step.

Inference Configuration and Legal Prompting

Once GLM Legal setup is complete, the quality of output depends heavily on how you structure inputs. Legal tasks reward explicit prompts that separate facts, task objectives, jurisdiction, and output format.

Legal QA

  • State the jurisdiction explicitly
  • Supply the relevant legal text
  • Ask for cited conclusions only

Clause Extraction

  • Define the output schema up front
  • Require clause-level citations
  • Flag ambiguous language separately

Document Summarization

  • Limit scope to supplied materials
  • Request structured sections
  • Ask for an uncertainty note

A comparison of common generation settings for legal workloads:

SettingConservativeBalancedFast Drafting
Temperature0.1-0.30.50.7
Top-p0.90.920.95
Use caseCitation-adjacent QASummariesBrainstorm drafts
Review needStill requiredRequiredHeavier review
Output Discipline

Low temperature reduces but does not eliminate hallucinated citations. Every legal authority, date, party name, and quotation produced by the model must be verified against original sources before any professional use.

FAQ

Q: What is GLM Legal setup, and who is it for?

GLM Legal setup is the process of preparing an environment to run law-glm-10b or law-glm-10b-v2 locally: installing Python, PyTorch, and Transformers, downloading the roughly 39.5 GB weights, and loading the model with trust_remote_code. It is aimed at researchers and developers working on Chinese legal text tasks.

Q: Can I run GLM Legal on a consumer GPU?

Full-precision loading of a 10B model generally requires around 40 GB of VRAM. With half precision or quantization, capable consumer cards in the 12-24 GB range can run inference, though with some speed and quality trade-offs. CPU-only inference is technically possible but impractically slow.

Q: Why does loading fail without trust_remote_code?

GLM Legal repositories include custom modeling code that Transformers must execute to build the model. Setting trust_remote_code=True grants that permission. Always review the repository code and pin a revision before enabling it.

Q: What license applies to GLM Legal, and can I use it commercially?

The model pages list Apache-2.0, a permissive license that allows commercial use in many scenarios. You should still verify the model page terms, attribute appropriately, and note that license compliance does not replace legal review of outputs used in professional practice.

Related Articles