Views
No views yet
1from peft import PeftModel
2from transformers import AutoTokenizer, AutoModelForCausalLM
3import torch
4
5# Define the base model and your fine-tuned model's ID
6base_model_id = "unsloth/tinyllama-chat-bnb-4bit"
7adapter_id = "menikev/nigerian-legal-chatbot-tinyllama"
8
9# Load the base model and tokenizer
10model = AutoModelForCausalLM.from_pretrained(
11 base_model_id,
12 torch_dtype=torch.float16,
13 device_map="auto"
14)
15tokenizer = AutoTokenizer.from_pretrained(base_model_id)
16
17# Load the PEFT adapter
18model = PeftModel.from_pretrained(model, adapter_id)
19
20# Example for inference
21prompt = "what are the rights of an employee in Nigeria?"
22inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
23outputs = model.generate(**inputs, max_new_tokens=256)
24print(tokenizer.decode(outputs[0], skip_special_tokens=True))
25
26
27
28[More Information Needed]
29
30## Training Details
31
32### Training Data
33
34- The model was fine-tuned on a custom dataset of Nigerian legal documents. This includes the Nigerian Constitution (1999), the Federal Competition and Consumer Protection Act (FCCPA), the Nigeria Data Protection Act (2023), and the Labour Law. The data was formatted into a chat-like format for instruction fine-tuning.
35
36[More Information Needed]
37
38### Training Procedure
39
40<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
41
42#### Preprocessing [optional]
43
44[More Information Needed]
45
46
47#### Training Hyperparameters
48
49- The model was fine-tuned using the QLoRA method, as implemented by the Unsloth library. The training was performed on a T4 GPU.
50
51 Training regime: bf16 mixed precision
52
53 Optimizer: AdamW
54
55#### Speeds, Sizes, Times [optional]
56
57<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
58
59[More Information Needed]
60
61## Evaluation
62
63<!-- This section describes the evaluation protocols and provides the results. -->
64
65### Testing Data, Factors & Metrics
66
67#### Testing Data
68
69<!-- This should link to a Dataset Card if possible. -->
70
71[More Information Needed]
72
73#### Factors
74
75<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
76
77[More Information Needed]
78
79#### Metrics
80
81<!-- These are the evaluation metrics being used, ideally with a description of why. -->
82
83[More Information Needed]
84
85### Results
86
87[More Information Needed]
88
89#### Summary
90
91
92
93## Model Examination [optional]
94
95<!-- Relevant interpretability work for the model goes here -->
96
97[More Information Needed]
98
99## Environmental Impact
100
101<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
102
103Carbon 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).
104
105- **Hardware Type:** [More Information Needed]
106- **Hours used:** [More Information Needed]
107- **Cloud Provider:** [More Information Needed]
108- **Compute Region:** [More Information Needed]
109- **Carbon Emitted:** [More Information Needed]
110
111## Technical Specifications [optional]
112
113### Model Architecture and Objective
114
115[More Information Needed]
116
117### Compute Infrastructure
118
119[More Information Needed]
120
121#### Hardware
122
123[More Information Needed]
124
125#### Software
126
127[More Information Needed]
128
129## Citation [optional]
130
131- Please cite the base model, unsloth/tinyllama-chat-bnb-4bit, as well as the fine-tuning work in your publications.
132
133@misc{nigerian-legal-chatbot-tinyllama,
134 author = {menikev},
135 title = {Nigerian Legal Chatbot: Fine-Tuned TinyLlama for Legal Queries},
136 year = {2025},
137 publisher = {Hugging Face},
138 url = {[https://huggingface.co/menikev/nigerian-legal-chatbot-tinyllama](https://huggingface.co/menikev/nigerian-legal-chatbot-tinyllama)}
139}
140
141[More Information Needed]
142
143**APA:**
144
145[More Information Needed]
146
147## Glossary [optional]
148
149<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
150
151[More Information Needed]
152
153## More Information [optional]
154
155[More Information Needed]
156
157## Model Card Authors [optional]
158
159[More Information Needed]
160
161## Model Card Contact
162
163[More Information Needed]
164### Framework versions
165
166- PEFT 0.17.0