Views
No views yet
openai/gpt-oss-20b model, specifically adapted for legal document analysis and reasoning.openai/gpt-oss-20btransformers and peft libraries.pip install transformers peft torch accelerate1import torch
2from peft import PeftModel, PeftConfig
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5# Model ID
6peft_model_id = "OmnisAI/lega-gpt-oss-20b-lora"
7
8# Load Config
9config = PeftConfig.from_pretrained(peft_model_id)
10
11# Load Base Model
12model = AutoModelForCausalLM.from_pretrained(
13 config.base_model_name_or_path,
14 return_dict=True,
15 load_in_8bit=False, # Set to True if you have low VRAM
16 device_map="auto",
17 trust_remote_code=True,
18)
19tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
20
21# Load the LoRA Adapter
22model = PeftModel.from_pretrained(model, peft_model_id)
23
24# Inference Example
25input_text = "Review the following clause for compliance issues: The contractor shall indemnify the client against all claims..."
26inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
27
28with torch.no_grad():
29 outputs = model.generate(**inputs, max_new_tokens=100)
30 print(tokenizer.decode(outputs[0], skip_special_tokens=True))q_proj, v_proj, k_proj, o_proj| Model | Perplexity (Lower is Better) |
|---|---|
| Base Model (gpt-oss-20b) | 135.83 |
| Finetuned Model (LegalCur Copilot) | 109.91 |