Downloads · 30 days
15
20% of all-time downloads
nitajadav/Legal_Pegasus_FineTuned
Legal_Pegasus_FineTuned is a machine learning model from nitajadav. 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 mit.
This modelcard aims to be fine tuned model in legal domain of the Indian Judicial.
Downloads · 30 days
15
20% of all-time downloads
All-time downloads
76
Public
Parameters
571M
2.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.3 GB · 100%
From the Hugging Face model README
This modelcard aims to be fine tuned model in legal domain of the Indian Judicial.
The Model can be directly used to generate summary of legal documents.
The model may not work for language other than english and other non-Indian legal domain.
The model may not work for long documents. Long documents need to be chunked using passage retrieval methods described in github repository.
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
Use the code below to get started with the model.
#!/usr/bin/env python3
"""
import argparse
import json
import pandas as pd
from tqdm import tqdm
from transformers import pipeline
def load_jsonl(path):
rows = []
with open(path, "r", encoding="utf-8") as f:
for line in f:
rows.append(json.loads(line))
return pd.DataFrame(rows)
def save_jsonl(records, path):
with open(path, "w", encoding="utf-8") as f:
for r in records:
f.write(json.dumps(r, ensure_ascii=False) + "\n")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Pegasus summarization using transformers.pipeline")
parser.add_argument("--input", required=True, help="Input .jsonl or .csv")
parser.add_argument("--output", required=True, help="Output JSONL file")
parser.add_argument("--model", required=True,
help="HF repo id or local model folder containing fine tuned legal-Pegasus")
parser.add_argument("--use_auth_token", default=None,
help="HF token for private models")
args = parser.parse_args()
print("Loading summarization pipeline...")
summarizer = pipeline(
"summarization",
model=args.model,
tokenizer=args.model, # tokenizer usually stored in same repo
use_auth_token=args.use_auth_token,
device=-1, # CPU; change to 0 for GPU
framework="pt"
)
print("Loading dataset...")
if args.input.endswith(".jsonl"):
df = load_jsonl(args.input)
else:
df = pd.read_csv(args.input)
if "ID" not in df.columns or "para_text" not in df.columns:
raise ValueError("Input must contain columns: ID, para_text")
results = []
print("Running summarization...")
for _, row in tqdm(df.iterrows(), total=len(df)):
text = row["para_text"]
summary = summarizer(
text,
max_length=256,
min_length=20,
do_sample=False,
num_beams=5
)[0]["summary_text"]
results.append({
"ID": str(row["ID"]),
"Summary": summary
})
save_jsonl(results, args.output)
print(f"Summaries saved to {args.output}")
Long Documents required chunking using passage retrieval methods and raw data should be normalized.
<!--#### Training Hyperparameters - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision --> <!--#### Speeds, Sizes, Times [optional] <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. --> <!--[More Information Needed] <!--## Evaluation <!-- This section describes the evaluation protocols and provides the results. --> <!--### Testing Data, Factors & Metrics <!--#### Testing Data <!-- This should link to a Dataset Card if possible. --> <!--[More Information Needed] #### Factors <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. --> <!--[More Information Needed] -->Rouge Score
21.30 (R2,RL,BLEU Average)
<!--#### Summary <!-- ## Model Examination [optional] <!-- Relevant interpretability work for the model goes here --> <!--[More Information Needed] ## Environmental Impact <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly --> <!--Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700). - **Hardware Type:** [More Information Needed] - **Hours used:** [More Information Needed] - **Cloud Provider:** [More Information Needed] - **Compute Region:** [More Information Needed] - **Carbon Emitted:** [More Information Needed] ## Technical Specifications [optional] ### Model Architecture and Objective [More Information Needed]-->Model trained with one H100 NVIDIA GPU with 94GB RAM
<!-- #### Hardware [More Information Needed] #### Software [More Information Needed] ## Citation [optional] <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. --> <!--**BibTeX:** [More Information Needed] **APA:** [More Information Needed] ## Glossary [optional] <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. --> <!--[More Information Needed] ## More Information [optional] [More Information Needed] ## Model Card Authors [optional] [More Information Needed] ## Model Card Contact [More Information Needed]