
如何在沒有 ML 團隊的情況下微調法律 AI 模型
大多數 AI 代理商沒有 ML 工程師。以下是如何使用 Ertas Studio 微調生產品質的法律 AI 模型——不需要 Python、不需要租用 GPU、不需要 ML 專業知識。
AI 代理商進入法律領域的最大瓶頸不是銷售或合規知識——而是 ML 專業知識。傳統上,微調語言模型需要 Python 熟練度、理解訓練超參數、獲得 GPU 基礎設施,以及調試訓練運行的經驗。
大多數代理商不具備這些。他們有自動化工程師、工作流程專家和面向客戶的顧問。聘請 ML 工程師在他們產出任何東西之前要增加 $150K-250K 的薪資。
本文展示如何使用 Ertas Studio 完全繞過 ML 瓶頸,逐步演示從資料準備到部署的完整法律模型微調工作流程。
代理商瓶頸
法律客戶的典型 AI 代理商工作流程如下:
- 客戶需要 AI 驅動的合約審查
- 代理商使用 GPT-4o 構建提示工程解決方案
- 結果不錯,但準確性不足以用於生產環境
- 客戶要求更高準確性和資料隱私
- 代理商意識到他們需要微調和本地部署
- 代理商碰壁——團隊中沒有人知道如何微調模型
此時,代理商要麼:
- 拒絕這個項目(損失收入)
- 外包給 ML 承包商(每個模型 $10K-30K,4-8 週時間線)
- 嘗試從頭學習微調(幾個月的實驗)
這些選項都不可持續。Ertas Studio 提供了第四個選項:為非 ML 團隊專門構建的無代碼微調介面。
演示:微調法律合約審查模型
以下是完整的工作流程,逐步說明。
第 1 步:準備你的訓練資料
法律合約審查的訓練資料來自律所的歷史工作。你需要指令-回應對,其中:
- 指令: 合約條款或部分 + 分析問題
- 回應: 律師的分析、風險評估或擷取的資訊
範例:
{
"instruction": "Review the following indemnification clause and assess risk level:\n\n'Tenant shall indemnify and hold harmless Landlord from and against any and all claims, damages, losses, costs and expenses (including reasonable attorneys' fees) arising out of or in connection with Tenant's use of the Premises, except to the extent caused by Landlord's gross negligence or willful misconduct.'",
"response": "Risk Level: MODERATE\n\nAnalysis: This is a standard one-way indemnification clause favouring the landlord. The carve-out for landlord's gross negligence/willful misconduct provides some protection, but the clause is broader than ideal. Key concerns:\n1. 'Any and all claims' is very broad — consider narrowing to claims arising from tenant's negligence\n2. No cap on indemnification liability\n3. Includes attorneys' fees which could be significant\n\nRecommendation: Negotiate to add mutual indemnification and a liability cap tied to the lease value."
}
資料要求:
- 最低: 500 個範例( 用於基本模型)
- 推薦: 2,000-3,000 個範例(用於生產品質)
- 格式: JSONL(每行一個 JSON 物件)
資料來源:
- 從文件管理系統匯出(iManage、NetDocuments)
- 將律師注釋和評論轉換為結構化配對
- 使用歷史審查備忘錄作為回應模板
第 2 步:上傳到 Ertas Studio
在 Ertas Studio 中:
- 創建新項目並命名(例如「Acme Legal - Contract Review」)
- 上傳你的 JSONL 訓練文件
- Studio 自動驗證格式並顯示你範例的預覽
- 查看資料統計——回應長度分佈、指令類別
Studio 標記潛在的資料品質問題:重複條目、極短的回應、格式不一致。在繼續之前修復這些問題。
第 3 步:配置訓練
Studio 呈現帶有合理預設值的訓練配置:
| 參數 | 預設值 | 含義 |
|---|---|---|
| 基礎模型 | Llama 3.1 8B | 要微調的基礎模型 |
| 適配器類型 | LoRA | 訓練小型適配器,而不是完整模型 |
| LoRA rank | 16 | 控制適配器容量(越高 = 更多容量,更多計算) |
| Epochs | 3 | 訓練資料的訓練輪次 |
| 學習率 | 2e-4 | 模型學習的積極程度(越低 = 越穩定) |
對法律任務,預設值效果很好。主要決策是基礎模型大小:
- 8B: 訓練快,在消費級 GPU 上運行,對單任務模型足夠(例如只有合約審查)
- 13B: 訓練較慢,需要更多 VRAM,對多任務模型更好(合約審查 + 案例摘要 + 文件分類)
第 4 步:訓練
點擊「開始訓練」。Studio 處理:
- 分詞和資料格式化
- GPU 分配和調度
- 自動檢查點的訓練執行
- 在保留的驗證集上評估
- 實時顯示損失曲線和品質指標
在 8B 模型上訓練 2,000 個範例資料集的時間:大約 30-60 分鐘。
第 5 步:評估
訓練完成後,Studio 提供評估介面:
- 並排比較: 將同一合約條款發送給基礎模型和你的微調模型。比較輸出。
- 驗證指標: 保留資料的損失、回應品質分數
- 自訂輸入測試: 貼入任何合約條款並查看微調模型的分析
這是品質差異變得明顯的地方。基礎模型產生通用的、有時不準確的分析。微調模型產生的分析反映了律所自己的律師——使用他們的術語、應用他們的風險閾值、遵循他們的報告格式。
第 6 步:匯出和部署
以你偏好的格式匯出微調後的模型:
- GGUF: 用於通過 Ollama 部署(大多數代理商部署的推薦)
- SafeTensors: 用於通過 vLLM 或 Hugging Face Transformers 部署
- 僅 LoRA 適配器: 如果與同一基礎模型的其他適配器一起部署
使用 Ollama 或 vLLM 部署到客戶的硬體。模型本地運行——部署後不需要網路 連線。
前後對比:輸出品質比較
輸入條款:
"Notwithstanding any other provision of this Agreement, either party may terminate this Agreement immediately upon written notice if the other party commits a material breach and fails to cure such breach within ten (10) business days of receiving written notice thereof."
基礎模型(Llama 3.1 8B,未微調):
"This is a termination clause. It allows either party to terminate the agreement if there is a material breach. The cure period is 10 business days."
微調模型(相同基礎,在律所資料上訓練):
"Risk Level: LOW-MODERATE
Standard mutual termination for material breach with cure period. The 10 business day cure period is shorter than our typical recommendation of 30 calendar days. Key considerations:
- 'Material breach' is undefined — recommend adding examples or referencing specific obligations
- 10 business days may be insufficient for complex curing actions (e.g., insurance procurement, structural repairs)
- 'Immediately upon written notice' after cure failure is acceptable
- 'Notwithstanding any other provision' creates potential conflict with force majeure clause in Section 14
Recommendation: Negotiate cure period to 30 calendar days. Add definition of material breach or cross-reference to specific obligations."
差異不是漸進的——而是本質上的。微調模型產生的分析類似於初級律師在查看律所分析指南後所寫的內容。
從一個模型到可擴展的實踐
一旦你微調了第一個法律模型,這個過程就可以複製:
- 相同的工作流程,不同的客戶: 每個新的律所項目都遵循相同的資料 → 訓練 → 部署管道
- 相同的基礎模型,不同的適配器: 從相同的基礎模型訓練客戶特定的 LoRA 適配器
- 相同的基礎設施,多個模型: 通過適配器熱切換,單個 GPU 服務多個客戶模型
- 套餐定價: 每個客戶的成本隨著客戶增加而降低,改善利潤率
阻止你的代理商進入法律領域的 ML 瓶頸不再存在。
Ship AI that runs on your users' devices.
Ertas early bird pricing starts at $14.50/mo — locked in for life. Plans for builders and agencies.
延伸閱讀
- Fine-Tune AI Models Without Code — 使用 Ertas Studio 進行無代碼微調的一般指南
- Introducing Ertas Studio — 平台概覽和功能
Ship AI that runs on your users' devices.
Early bird pricing starts at $14.50/mo — locked in for life. Plans for builders and agencies.
Keep reading

How to QA a Fine-Tuned Model Before Client Delivery
A complete QA process for testing fine-tuned models before delivering them to clients — covering functional testing, edge cases, regression checks, and client acceptance criteria.

Running 10+ Fine-Tuned Models for Different Clients: Operations Guide
An operations guide for AI agencies managing 10+ fine-tuned models across multiple clients — covering model organization, resource allocation, monitoring, updates, and scaling without chaos.

AI Agency Proposal Template: How to Win Custom Model Projects
Most AI agency proposals lose because they lead with technology. Here's the structure, the writing formula, and the common mistakes that cost agencies deals.