初始化项目,由ModelHub XC社区提供模型
Model: subrit/subrit-legal-gpt2-quecto-v1 Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
subrit_legal_gpt2_q8.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
124
README.md
Normal file
124
README.md
Normal file
@@ -0,0 +1,124 @@
|
||||
---
|
||||
license: cc-by-sa-4.0
|
||||
language:
|
||||
- en
|
||||
library_name: transformers
|
||||
tags:
|
||||
- legal
|
||||
- india
|
||||
- law
|
||||
- gpt2
|
||||
- gguf
|
||||
- quecto
|
||||
---
|
||||
|
||||
# ⚖️ Subrit's Legal AI (Quecto V1)
|
||||
|
||||
'Model:' `subrit-legal-gpt2-quecto-v1`
|
||||
'Author:' Subrit Dikshit
|
||||
'License:' CC BY-SA 4.0
|
||||
|
||||
This is a specialized miniature 'Legal AI' trained from scratch & fine-tuned on the 'Indian Penal Code (IPC)', 'CrPC', and 'Constitution'. It runs efficiently on consumer hardware (CPUs) using GGUF quantization.
|
||||
|
||||
## ⚠️ Limitations & Disclaimer
|
||||
* 'Model Architecture:' This model uses GPT-2 custom configuration (defined from scratch) architecture. It is trained from scratch and not a direct fine-tune of the gpt2-small checkpoint, but utilizes the standard GPT2LMHeadModel structure for compatibility. It performs best on simple definition and punishment questions.
|
||||
* 'Reasoning Limits:' Due to its small size, it is "NOT" capable of complex reasoning, multi-turn logic, or "lawyer-level" argumentation.
|
||||
* 'Hallucinations:' Like all Small Language Models (SLMs), this model can "hallucinate" (generate plausible-sounding but incorrect information). 'Always verify specific section numbers and punishments against official legal texts.'
|
||||
* 'Usage:' This is a research prototype for educational purposes. It is 'NOT' a substitute for professional legal advice.
|
||||
|
||||
## 📦 Model Details
|
||||
* 'Architecture:' Custom GPT-2 configuration (Trained from scratch).
|
||||
* 'Training Data:' Indian Legal Texts (IPC, CrPC, Constitution).
|
||||
* 'Formats Included:'
|
||||
* 'PyTorch:' Standard non-quantized weights for GPU inference or further fine-tuning (~500 MB).
|
||||
* 'GGUF (Q8_0):' 8-bit quantized for fast CPU/Edge inference (~130 MB).
|
||||
|
||||
## 👨💻 Credits & Attribution
|
||||
This model was trained by 'Subrit Dikshit'.
|
||||
* 'Training Data:' [Techmaestro369/indian-legal-texts-finetuning](https://huggingface.co/datasets/Techmaestro369/indian-legal-texts-finetuning) (CC BY-SA 4.0).
|
||||
* 'Base Model:' Custom GPT-2 configuration (Trained from scratch).
|
||||
|
||||
## 🚀 How to Run (Demo Script)
|
||||
This repository contains 'two versions' of the model. Choose the one that fits your needs.
|
||||
|
||||
### 🔧 Prerequisites
|
||||
* **Python:** 3.10 or 3.11 is recommended.
|
||||
* **OS:** Windows, macOS, or Linux.
|
||||
|
||||
### Option 1: Run the PyTorch Version (Standard HF). Use this if you are using the standard transformers library or have a GPU.
|
||||
|
||||
'Requires:' pip install transformers torch
|
||||
|
||||
```python
|
||||
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
||||
|
||||
# 1. Load from Hugging Face
|
||||
model_name = "subrit/subrit-legal-gpt2-quecto-v1"
|
||||
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
|
||||
model = GPT2LMHeadModel.from_pretrained(model_name)
|
||||
|
||||
# 2. Ask a Question
|
||||
input_text = "Question: What is Article 14 of the Constitution?\nAnswer:"
|
||||
inputs = tokenizer(input_text, return_tensors="pt")
|
||||
|
||||
# 3. Generate Answer
|
||||
outputs = model.generate(**inputs, max_new_tokens=50)
|
||||
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
||||
```
|
||||
|
||||
|
||||
### Option 2: Run the GGUF Version (Recommended for Speed/CPU)
|
||||
*Use this if you want to run the model on a laptop CPU without a GPU.*
|
||||
|
||||
'Requires:' `pip install llama-cpp-python huggingface_hub`
|
||||
|
||||
```python
|
||||
from huggingface_hub import hf_hub_download
|
||||
from llama_cpp import Llama
|
||||
|
||||
# 1. Download the GGUF file
|
||||
model_path = hf_hub_download(
|
||||
repo_id="subrit/subrit-legal-gpt2-quecto-v1",
|
||||
filename="subrit_legal_gpt2_q8.gguf"
|
||||
)
|
||||
|
||||
# 2. Load the Engine
|
||||
llm = Llama(model_path=model_path, n_ctx=512, verbose=False)
|
||||
|
||||
# 3. Ask a Question
|
||||
question = "What is the punishment for murder under Section 302?"
|
||||
output = llm(f"Question: {question}\nAnswer:", max_tokens=60, stop=["Question:", "\n"])
|
||||
|
||||
print(output['choices'][0]['text'])
|
||||
```
|
||||
|
||||
|
||||
Please cite it as follows:
|
||||
|
||||
```bibtex
|
||||
@misc{dikshit2025legalgpt2,
|
||||
author = {Dikshit, Subrit},
|
||||
title = {Subrit's Legal AI (Quecto V1): A Quantized GPT-2 Fine-Tune on Indian Law},
|
||||
year = {2025},
|
||||
publisher = {Hugging Face},
|
||||
journal = {Hugging Face Model Hub},
|
||||
howpublished = {\url{[https://huggingface.co/subrit/subrit-legal-gpt2-quecto-v1](https://huggingface.co/subrit/subrit-legal-gpt2-quecto-v1)}}
|
||||
}
|
||||
```
|
||||
|
||||
Acknowledgements:
|
||||
```
|
||||
@dataset{indian_legal_texts,
|
||||
author = {Gupta, Akshat (Techmaestro369)},
|
||||
title = {Indian Legal Texts Finetuning Dataset},
|
||||
year = {2024},
|
||||
publisher = {Hugging Face},
|
||||
url = {[https://huggingface.co/datasets/Techmaestro369/indian-legal-texts-finetuning](https://huggingface.co/datasets/Techmaestro369/indian-legal-texts-finetuning)}
|
||||
}
|
||||
|
||||
@article{radford2019language,
|
||||
title={Language Models are Unsupervised Multitask Learners},
|
||||
author={Radford, Alec and Wu, Jeffrey and Child, Rewon and Luan, David and Amodei, Dario and Sutskever, Ilya},
|
||||
year={2019}
|
||||
}
|
||||
```
|
||||
3
added_tokens.json
Normal file
3
added_tokens.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"<|padding|>": 50257
|
||||
}
|
||||
38
config.json
Normal file
38
config.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"activation_function": "gelu_new",
|
||||
"architectures": [
|
||||
"GPT2LMHeadModel"
|
||||
],
|
||||
"attn_pdrop": 0.1,
|
||||
"bos_token_id": 50256,
|
||||
"dtype": "float32",
|
||||
"embd_pdrop": 0.1,
|
||||
"eos_token_id": 50256,
|
||||
"initializer_range": 0.02,
|
||||
"layer_norm_epsilon": 1e-05,
|
||||
"model_type": "gpt2",
|
||||
"n_ctx": 1024,
|
||||
"n_embd": 768,
|
||||
"n_head": 12,
|
||||
"n_inner": null,
|
||||
"n_layer": 12,
|
||||
"n_positions": 1024,
|
||||
"reorder_and_upcast_attn": false,
|
||||
"resid_pdrop": 0.1,
|
||||
"scale_attn_by_inverse_layer_idx": false,
|
||||
"scale_attn_weights": true,
|
||||
"summary_activation": null,
|
||||
"summary_first_dropout": 0.1,
|
||||
"summary_proj_to_labels": true,
|
||||
"summary_type": "cls_index",
|
||||
"summary_use_proj": true,
|
||||
"task_specific_params": {
|
||||
"text-generation": {
|
||||
"do_sample": true,
|
||||
"max_length": 50
|
||||
}
|
||||
},
|
||||
"transformers_version": "4.57.6",
|
||||
"use_cache": true,
|
||||
"vocab_size": 50258
|
||||
}
|
||||
6
generation_config.json
Normal file
6
generation_config.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 50256,
|
||||
"eos_token_id": 50256,
|
||||
"transformers_version": "4.57.6"
|
||||
}
|
||||
50001
merges.txt
Normal file
50001
merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d9b637fd8b7a915a5d466efc1a01ec44196bf2cdb78ef81025b0e7e820e3d7bd
|
||||
size 497777280
|
||||
24
special_tokens_map.json
Normal file
24
special_tokens_map.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"bos_token": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": true,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"eos_token": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": true,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": "<|padding|>",
|
||||
"unk_token": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": true,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
3
subrit_legal_gpt2_q8.gguf
Normal file
3
subrit_legal_gpt2_q8.gguf
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:edcba6e62992ac41c834469d05452bfe08883db10e404b061d2ee1c68825db31
|
||||
size 136659936
|
||||
250315
tokenizer.json
Normal file
250315
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
29
tokenizer_config.json
Normal file
29
tokenizer_config.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"add_prefix_space": false,
|
||||
"added_tokens_decoder": {
|
||||
"50256": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": true,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"50257": {
|
||||
"content": "<|padding|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
}
|
||||
},
|
||||
"bos_token": "<|endoftext|>",
|
||||
"clean_up_tokenization_spaces": false,
|
||||
"eos_token": "<|endoftext|>",
|
||||
"extra_special_tokens": {},
|
||||
"model_max_length": 1024,
|
||||
"pad_token": "<|padding|>",
|
||||
"tokenizer_class": "GPT2Tokenizer",
|
||||
"unk_token": "<|endoftext|>"
|
||||
}
|
||||
3
training_args.bin
Normal file
3
training_args.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a61963e0d34d671fd9469e8f492e86c19ef26f40bd74c69a3e9e2d59e0e8d8b5
|
||||
size 5905
|
||||
1
vocab.json
Normal file
1
vocab.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user