🚀 印度法律助手:基於LLaMA的印度法律文本生成模型
印度法律助手是一個基於LLaMA架構的模型,在印度法律文本上進行了微調。該模型旨在協助處理與印度法律相關的各種法律任務和查詢,為法律工作者和研究者提供有力支持。
負責人信息
- 指導老師:Kalimuthu K博士
- 項目協調人:Sandeep Kumar P博士
團隊成員
- RA2111004010006:Ganesha Sai Varma
- RA2111004010008:Surendra Reddy
- RA2111004010055:Sampath Voona
✨ 主要特性
印度法律助手是一個專門為理解和生成與印度法律相關的文本而訓練的文本生成模型。它可用於以下任務:
📦 安裝指南
要使用此模型,你需要安裝所需的庫:
pip install transformers torch
pip install llama-cpp-python
💻 使用示例
基礎用法
1. 使用Hugging Face Pipeline
from transformers import pipeline
pipe = pipeline("text-generation", model="varma007ut/Indian_Legal_Assitant")
prompt = "Summarize the key points of the Indian Contract Act, 1872:"
result = pipe(prompt, max_length=200)
print(result[0]['generated_text'])
2. 直接使用Hugging Face Transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("varma007ut/Indian_Legal_Assitant")
model = AutoModelForCausalLM.from_pretrained("varma007ut/Indian_Legal_Assitant")
prompt = "What are the fundamental rights in the Indian Constitution?"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=200)
print(tokenizer.decode(outputs[0]))
高級用法
3. 使用llama-cpp-python的GGUF格式
from llama_cpp import Llama
llm = Llama.from_pretrained(
repo_id="varma007ut/Indian_Legal_Assitant",
filename="ggml-model-q4_0.gguf",
)
response = llm.create_chat_completion(
messages = [
{
"role": "user",
"content": "Explain the concept of judicial review in India."
}
]
)
print(response['choices'][0]['message']['content'])
4. 使用推理端點
此模型支持Hugging Face推理端點。你可以部署該模型並通過API調用使用它。有關設置和使用推理端點的更多信息,請參閱Hugging Face文檔。
📚 詳細文檔
模型詳情
模型評估
要評估模型的性能:
- 準備一組印度法律查詢或任務的測試集。
- 使用標準的自然語言處理評估指標,如困惑度、BLEU分數或特定任務的指標。
以下是使用BLEU分數的示例:
from datasets import load_metric
bleu = load_metric("bleu")
predictions = model.generate(encoded_input)
results = bleu.compute(predictions=predictions, references=references)
貢獻說明
我們歡迎大家貢獻代碼以改進模型或擴展其功能。有關詳細信息,請參閱我們的貢獻指南。
📄 許可證
本項目採用Apache 2.0許可證。有關詳細信息,請參閱許可證文件。
⚠️ 重要提示
雖然此模型基於LLaMA架構,但它已在印度法律文本上進行了微調。使用此模型時,請確保遵守所有相關的許可證和使用條款。