Downloads · 30 days
4
13% of all-time downloads
SamerGMTM22/gpt-oss-20b-cuad-16bit
gpt-oss-20b-cuad-16bit is a machine learning model from SamerGMTM22. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This repository contains a full 16 bit merged version of a GPT-OSS 20B model that has been LoRA fine tuned on the CUAD (Contract Understanding Atticus Dataset) for contract question answering and clause understanding.
Downloads · 30 days
4
13% of all-time downloads
All-time downloads
32
Public
Parameters
20.9B
41.9 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors41.8 GB · 100%
From the Hugging Face model README
This repository contains a full 16 bit merged version of a GPT-OSS 20B model that has been LoRA fine tuned on the CUAD (Contract Understanding Atticus Dataset) for contract question answering and clause understanding.
unsloth/gpt-oss-20bSamerGMTM22/gpt-oss-20b-cuad-lora)This is the model to use if you want a single, stand alone GPT-OSS 20B checkpoint that already includes CUAD finetuning.
LoRA adapter only (small, 4 bit, Unsloth-based):
SamerGMTM22/gpt-oss-20b-cuad-lora
This repo (full 16 bit merged model):
SamerGMTM22/gpt-oss-20b-cuad-16bit
Use this repo when:
The project goal was to build a practical contracts assistant on top of GPT-OSS 20B:
Dataset access (CUAD)
theatticusproject/cuad-qa dataset on Hugging Face uses a Python loader script.datasets no longer support trust_remote_code for such scripts.data.zip directly from the official GitHub repository.datasets.Dataset from the raw JSON files.Chat formatting and supervision
train_on_responses_only with wrong markers masked all labels and produced zero training loss.input_ids and labels was critical to confirm that only assistant tokens carry labels.NaN loss and simplification
16 bit merge and disk constraints
SamerGMTM22/gpt-oss-20b-cuad-lora.save_pretrained_merged(..., save_method="merged_16bit").SamerGMTM22/gpt-oss-20b-cuad-16bit.You will find, among others:
config.jsonmodel-00000-of-00002.safetensorsmodel-00001-of-00002.safetensorsmodel-00002-of-00002.safetensors (depending on sharding layout)model.safetensors.index.jsontokenizer.jsontokenizer_config.jsonspecial_tokens_map.jsonchat_template.jinjaCombined, these files represent a complete 16 bit GPT-OSS 20B model, tuned on CUAD, with its tokenizer and chat template.
This model is intended for:
Typical questions you might ask:
You must always manually verify the model’s answer against the contract text.
Use it as an assistant, not as a decision maker.
Because GPT-OSS support is still evolving, the safest way to load this model today is via Unsloth, which patches GPT-OSS internals appropriately.
Install dependencies:
pip install "torch>=2.1.0" transformers
pip install "unsloth[base] @ git+https://github.com/unslothai/unsloth"
pip install "unsloth_zoo[base] @ git+https://github.com/unslothai/unsloth-zoo"
Load the model:
from unsloth import FastLanguageModel
import torch
model_id = "SamerGMTM22/gpt-oss-20b-cuad-16bit"
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = model_id,
max_seq_length = 1024,
dtype = torch.bfloat16, # 16 bit compute
load_in_4bit = False, # full 16 bit weights
)
from transformers import TextStreamer
clause = """
This Agreement shall commence on the Effective Date and shall continue
for a period of three (3) years, unless earlier terminated in accordance
with the provisions herein.
"""
messages = [
{
"role": "system",
"content": "You are a senior legal assistant specializing in contract review.",
},
{
"role": "user",
"content": (
"Question: What is the initial term of this agreement?\n\n"
"Contract excerpt:\n" + clause
),
},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt = True,
return_tensors = "pt",
return_dict = True,
).to(model.device)
_ = model.generate(
**inputs,
max_new_tokens = 128,
streamer = TextStreamer(tokenizer),
)
The answer should identify the initial term and may restate the relevant sentence.
GPT-OSS support in transformers and related tooling is evolving. Depending on versions, direct loading with AutoModelForCausalLM.from_pretrained may or may not work without additional patches.
If you run into router-related errors when using plain AutoModelForCausalLM, prefer the Unsloth loading path until the ecosystem stabilizes.
This model is best thought of as a specialized research tool for legal and procurement workflows, not as a replacement for professional judgment.
unsloth/gpt-oss-20bThanks to:
Single message; excerpt optional: Question: … Excerpt: … If no excerpt: Question: …
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
model_id = "SamerGMTM22/gpt-oss-20b-cuad-16bit"
tok = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
torch_dtype="auto",
device_map="auto",
)
prompt = (
"Question: How many days' notice is required to terminate? "
"Excerpt: This Agreement may be terminated by either party upon thirty (30) days' prior written notice."
)
messages = [
{"role": "system", "content": "You are a legal assistant answering contract clause questions. Be concise; no chain-of-thought in the output."},
{"role": "user", "content": prompt},
]
rendered = tok.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
inputs = tok(rendered, return_tensors="pt").to(model.device)
gen_cfg = GenerationConfig(max_new_tokens=200, do_sample=False)
outputs = model.generate(**inputs, generation_config=gen_cfg)
# Only decode the newly generated tokens
input_length = inputs.input_ids.shape[1]
print(tok.decode(outputs[0][input_length:], skip_special_tokens=True))
How-to and local relay clients: https://github.com/samerGMTM22/GPT-OSS-20B-Contracts