Raw legal question
AI Models & Assistants / Knowledge library
law-chat
Older 7B legal-domain research baseline; not a licensed legal adviser.
Why learn law-chat?
Provides downloadable model weights for controlled, task-specific evaluation.
The problem it solves
Supports local model experimentation; category recommendations are editorial, not measured rankings.
Where it came from
law-chat: Older 7B legal-domain research baseline; not a licensed legal adviser. License: Llama 2 Community License. Source checked 2026-10-13. Evaluate on your own task before use.
Build your understanding
Work through these exercises in order. Try the task before opening a reference.
- Explain what law-chat does.
- Identify a use case for law-chat.
- Describe a limitation of law-chat.
- Name a compatible tool for law-chat.
- Compare law-chat against an alternative.
Documentation and sources
- Primary source / model card (huggingface.co)
Catalog research notes
- See the AI Workbench for source dates, pricing evidence and configuration details.
Connect the ideas
Built on
Real World Example
Legal Research Assistant Optimization
Corporate legal departments managing high volumes of internal policy queries.
The business problem
General-purpose LLMs often lack the specialized domain knowledge required to accurately interpret complex legal terminology, leading to inconsistent or hallucinated responses.
How this topic solves it
Implementing the law-chat model, which utilizes continued pre-training on domain-specific corpora to enrich the LLM with legal knowledge while maintaining conversational capabilities through reading comprehension techniques.
- Initialize the environment using the transformers library to load the law-chat model.
- Define a system prompt that aligns with the LLaMA-2-Chat structure to ensure safe and coherent responses.
- Format user inputs as multi-turn conversations to fit the model's expected input structure.
- Execute inference using the model to generate responses based on the provided legal context.
The flow of data from user input to the specialized legal response.
Wraps input in LLaMA-2-Chat format
Domain-adapted 7B parameters
Final generated output
- User Input → formatting → Prompt Template
- Prompt Template → inference → Law-Chat Model
- Law-Chat Model → output → Legal Response
Implementation example
This code demonstrates loading the law-chat model and formatting a query using the required LLaMA-2-Chat system prompt structure.
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('AdaptLLM/law-chat') # Load model
tokenizer = AutoTokenizer.from_pretrained('AdaptLLM/law-chat') # Load tokenizer
prompt = '<s>[INST] <<SYS>>\nYou are a helpful assistant.\n<</SYS>>\n\nQuestion: Define ex post facto. [/INST]'
inputs = tokenizer(prompt, return_tensors='pt').input_ids # Tokenize input
outputs = model.generate(inputs, max_length=512) # Generate legal responseExpected business outcome
Improved accuracy in handling domain-specific legal queries compared to standard general-purpose models.
Limitations and checks
Continued pre-training can sometimes degrade the model's general prompting ability; verify performance by testing against baseline general-purpose tasks.