Views
No views yet
mohitskaushal/gemma-3-1b-it-inlegal-merged-fp16-16kmohitskaushal/InLegalLaySum-Phi4-Train-16Klm_head.safetensors file size may not be smaller because dense tensor storage still stores zero values.1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4model_id = "mohitskaushal/gemma3-legal-sparsegpt-50"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 dtype=torch.float16,
10 device_map="auto",
11 trust_remote_code=True,
12)
13
14prompt = \"\"\"You are a legal summarization assistant. Summarize the following legal text in simple layman language.
15
16Legal text:
17The appellant challenged the judgment of the High Court on the ground that the conviction was based on insufficient evidence and that material witnesses were not examined.
18
19Layman summary:\"\"\"
20
21inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
22
23with torch.no_grad():
24 outputs = model.generate(
25 **inputs,
26 max_new_tokens=200,
27 do_sample=False,
28 repetition_penalty=1.15,
29 no_repeat_ngram_size=4,
30 pad_token_id=tokenizer.eos_token_id,
31 )
32
33print(tokenizer.decode(outputs[0], skip_special_tokens=True))