🚀 印度法律助手:基于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架构,但它已在印度法律文本上进行了微调。使用此模型时,请确保遵守所有相关的许可证和使用条款。