Update README.md
Browse files
README.md
CHANGED
@@ -1,123 +1,140 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
34 |
|
35 |
# Load the fine-tuned model and tokenizer
|
36 |
-
model_name = "your-huggingface-repo/llama-3.
|
37 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
38 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
39 |
-
|
40 |
-
python
|
41 |
-
Copy code
|
42 |
-
# Define a sample prompt
|
43 |
-
prompt = "Write a Python function to calculate the Fibonacci sequence."
|
44 |
|
45 |
-
|
46 |
-
inputs = tokenizer(prompt, return_tensors="pt")
|
47 |
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
51 |
|
52 |
print(response)
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
GPU: NVIDIA Tesla T4
|
57 |
-
Hyperparameters
|
58 |
-
Batch Size: 32
|
59 |
-
Learning Rate: 5e-5
|
60 |
-
Epochs: 3
|
61 |
-
Optimizer: AdamW with weight decay
|
62 |
-
Warmup Steps: 500
|
63 |
-
Scheduler: Linear Decay
|
64 |
-
Frameworks Used
|
65 |
-
Unsloth: For efficient distributed training
|
66 |
-
Hugging Face Transformers: For model and tokenizer handling
|
67 |
-
📊 Performance Metrics
|
68 |
-
Metric Value
|
69 |
-
Validation Loss 1.24
|
70 |
-
Perplexity 3.47
|
71 |
-
Accuracy 92% on logic tasks
|
72 |
-
Code Quality 89% on test cases
|
73 |
-
🧠 Capabilities
|
74 |
-
Logical Reasoning
|
75 |
-
"If A is true and B is false, is A ∨ B true?"
|
76 |
-
Generates accurate logical conclusions based on formal logic.
|
77 |
-
Mathematics
|
78 |
-
Computes solutions to algebra, calculus, and discrete mathematics problems.
|
79 |
-
Provides detailed step-by-step explanations.
|
80 |
-
Coding
|
81 |
-
Writes clean, efficient, and functional code.
|
82 |
-
Explains the code line-by-line for better understanding.
|
83 |
-
💻 Deployment
|
84 |
-
Deploy Locally
|
85 |
-
bash
|
86 |
-
Copy code
|
87 |
-
pip install fastapi uvicorn
|
88 |
-
python
|
89 |
-
Copy code
|
90 |
-
from fastapi import FastAPI
|
91 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
92 |
-
|
93 |
-
app = FastAPI()
|
94 |
-
|
95 |
-
tokenizer = AutoTokenizer.from_pretrained("your-huggingface-repo/llama-3.1-1b-instruct-finetuned")
|
96 |
-
model = AutoModelForCausalLM.from_pretrained("your-huggingface-repo/llama-3.1-1b-instruct-finetuned")
|
97 |
-
|
98 |
-
@app.post("/generate")
|
99 |
-
async def generate(prompt: str):
|
100 |
-
inputs = tokenizer(prompt, return_tensors="pt")
|
101 |
-
outputs = model.generate(**inputs, max_length=200)
|
102 |
-
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
103 |
-
return {"response": response}
|
104 |
|
105 |
-
|
106 |
-
# uvicorn filename:app --reload
|
107 |
-
Hugging Face Spaces
|
108 |
-
Deploy the model to Hugging Face Spaces using Gradio:
|
109 |
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
pip install gradio
|
113 |
-
|
114 |
-
Copy code
|
115 |
-
import gradio as gr
|
116 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
121 |
|
122 |
def generate_response(prompt):
|
123 |
inputs = tokenizer(prompt, return_tensors="pt")
|
@@ -125,30 +142,54 @@ def generate_response(prompt):
|
|
125 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
126 |
|
127 |
gr.Interface(fn=generate_response, inputs="text", outputs="text").launch()
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
This
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
|
|
|
|
152 |
# Uploaded model
|
153 |
|
154 |
- **Developed by:** user3432234234
|
|
|
1 |
+
Below is the proper structure formatted to align with Hugging Face's repository conventions, including **tags**, **text**, and other essential metadata.
|
2 |
+
|
3 |
+
---
|
4 |
+
|
5 |
+
# LLaMA-3.2-1B-Instruct Fine-Tuned Model
|
6 |
+
|
7 |
+
**Model Card for Hugging Face Repository**
|
8 |
+
|
9 |
+
---
|
10 |
+
|
11 |
+
## Model Summary
|
12 |
+
|
13 |
+
This is a fine-tuned version of the **LLaMA-3.2-1B-Instruct** model. Fine-tuned using the `kanhatakeyama/wizardlm8x22b-logical-math-coding-sft` dataset, this model is specialized in **logical reasoning**, **mathematical problem-solving**, and **coding tasks**. Training was performed using **Unsloth** on Google Colab, optimized for performance and usability.
|
14 |
+
|
15 |
+
---
|
16 |
+
|
17 |
+
## Model Details
|
18 |
+
|
19 |
+
- **Model Name**: LLaMA-3.2-1B-Instruct (Fine-tuned)
|
20 |
+
- **Base Model**: LLaMA-3.2-1B-Instruct
|
21 |
+
- **Fine-Tuning Dataset**: `kanhatakeyama/wizardlm8x22b-logical-math-coding-sft`
|
22 |
+
- **Fine-Tuning Framework**: Unsloth
|
23 |
+
- **Parameters**: 1 Billion
|
24 |
+
- **Domain**: Logical Reasoning, Mathematics, Coding
|
25 |
+
- **Tags**: `llama`, `fine-tuning`, `instruction-following`, `math`, `coding`, `logical-reasoning`, `unsloth`
|
26 |
+
|
27 |
+
---
|
28 |
+
|
29 |
+
## Fine-Tuning Dataset
|
30 |
+
|
31 |
+
The fine-tuning dataset, `kanhatakeyama/wizardlm8x22b-logical-math-coding-sft`, is curated for advanced reasoning tasks. It contains:
|
32 |
+
- Logical reasoning scenarios
|
33 |
+
- Step-by-step mathematical solutions
|
34 |
+
- Complex code generation and debugging examples
|
35 |
+
|
36 |
+
**Dataset Link**: [kanhatakeyama/wizardlm8x22b-logical-math-coding-sft](https://huggingface.co/datasets/kanhatakeyama/wizardlm8x22b-logical-math-coding-sft)
|
37 |
+
|
38 |
+
---
|
39 |
+
|
40 |
+
## Intended Use
|
41 |
+
|
42 |
+
This model is ideal for tasks such as:
|
43 |
+
1. **Logical Problem Solving**: Derive conclusions and explanations for logical questions.
|
44 |
+
2. **Mathematics**: Solve algebra, calculus, and other mathematical problems.
|
45 |
+
3. **Coding**: Generate, debug, and explain programming code in various languages.
|
46 |
+
4. **Instruction-Following**: Handle user queries with clear and concise answers.
|
47 |
+
|
48 |
+
### Example Applications:
|
49 |
+
- AI tutors
|
50 |
+
- Logical reasoning assistants
|
51 |
+
- Math-solving bots
|
52 |
+
- Code generation and debugging tools
|
53 |
+
|
54 |
+
---
|
55 |
+
|
56 |
+
## Usage
|
57 |
+
|
58 |
+
### Installation
|
59 |
+
|
60 |
+
To use this model, install the required dependencies:
|
61 |
+
```bash
|
62 |
+
pip install transformers datasets torch accelerate
|
63 |
+
```
|
64 |
+
|
65 |
+
### Loading the Model
|
66 |
+
|
67 |
+
```python
|
68 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
69 |
|
70 |
# Load the fine-tuned model and tokenizer
|
71 |
+
model_name = "your-huggingface-repo/llama-3.2-1b-instruct-finetuned"
|
72 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
73 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
74 |
+
```
|
|
|
|
|
|
|
|
|
75 |
|
76 |
+
### Generating Outputs
|
|
|
77 |
|
78 |
+
```python
|
79 |
+
prompt = "Solve this equation: 2x + 3 = 7. Find x."
|
80 |
+
|
81 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
82 |
+
outputs = model.generate(**inputs, max_length=100)
|
83 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
84 |
|
85 |
print(response)
|
86 |
+
```
|
87 |
+
|
88 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
+
## Evaluation Metrics
|
|
|
|
|
|
|
91 |
|
92 |
+
| Metric | Value |
|
93 |
+
|--------------------|----------------|
|
94 |
+
| **Validation Loss** | 1.24 |
|
95 |
+
| **Perplexity** | 3.47 |
|
96 |
+
| **Accuracy** | 92% (logical tasks) |
|
97 |
+
| **Code Quality** | 89% (test cases) |
|
98 |
+
|
99 |
+
---
|
100 |
+
|
101 |
+
## Model Training
|
102 |
+
|
103 |
+
### Hardware
|
104 |
+
- **Platform**: Google Colab Pro
|
105 |
+
- **GPU**: NVIDIA Tesla T4
|
106 |
+
|
107 |
+
### Training Configuration
|
108 |
+
- **Batch Size**: 32
|
109 |
+
- **Learning Rate**: 5e-5
|
110 |
+
- **Epochs**: 1
|
111 |
+
- **Optimizer**: AdamW
|
112 |
+
- **Scheduler**: Linear Decay
|
113 |
+
|
114 |
+
### Frameworks Used
|
115 |
+
- **Unsloth**: For efficient training
|
116 |
+
- **Hugging Face Transformers**: For model and tokenizer handling
|
117 |
+
|
118 |
+
---
|
119 |
+
|
120 |
+
## Limitations
|
121 |
+
|
122 |
+
While this model is highly proficient in logical reasoning, mathematics, and coding tasks, there are some limitations:
|
123 |
+
- May produce inaccurate results for ambiguous or poorly-defined prompts.
|
124 |
+
- Performance may degrade for highly specialized or niche coding languages.
|
125 |
+
|
126 |
+
---
|
127 |
+
|
128 |
+
## Deployment
|
129 |
+
|
130 |
+
### Using Gradio for Web UI
|
131 |
+
|
132 |
+
```bash
|
133 |
pip install gradio
|
134 |
+
```
|
|
|
|
|
|
|
135 |
|
136 |
+
```python
|
137 |
+
import gradio as gr
|
|
|
138 |
|
139 |
def generate_response(prompt):
|
140 |
inputs = tokenizer(prompt, return_tensors="pt")
|
|
|
142 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
143 |
|
144 |
gr.Interface(fn=generate_response, inputs="text", outputs="text").launch()
|
145 |
+
```
|
146 |
+
|
147 |
+
### Hugging Face Inference API
|
148 |
+
This model can also be accessed using the Hugging Face Inference API for hosted deployment:
|
149 |
+
```python
|
150 |
+
from transformers import pipeline
|
151 |
+
|
152 |
+
pipe = pipeline("text-generation", model="your-huggingface-repo/llama-3.2-1b-instruct-finetuned")
|
153 |
+
result = pipe("Explain the concept of recursion in programming.")
|
154 |
+
print(result)
|
155 |
+
```
|
156 |
+
|
157 |
+
---
|
158 |
+
|
159 |
+
## Acknowledgements
|
160 |
+
|
161 |
+
This fine-tuning work was made possible by:
|
162 |
+
- **Hugging Face** for their exceptional library and dataset hosting.
|
163 |
+
- **Unsloth** for providing an efficient fine-tuning framework.
|
164 |
+
- **Google Colab** for GPU resources.
|
165 |
+
|
166 |
+
---
|
167 |
+
|
168 |
+
## Citation
|
169 |
+
|
170 |
+
If you use this model in your research or project, please cite it as:
|
171 |
+
```
|
172 |
+
@model{llama31b_instruct_finetuned,
|
173 |
+
title={Fine-Tuned LLaMA-3.2-1B-Instruct},
|
174 |
+
author={Your Name},
|
175 |
+
year={2024},
|
176 |
+
url={https://huggingface.co/your-huggingface-repo/llama-3.2-1b-instruct-finetuned},
|
177 |
+
}
|
178 |
+
```
|
179 |
+
|
180 |
+
---
|
181 |
+
|
182 |
+
## Licensing
|
183 |
+
|
184 |
+
This model is released under the **Apache 2.0 License**. See `LICENSE` for details.
|
185 |
+
|
186 |
+
---
|
187 |
+
|
188 |
+
**Tags**:
|
189 |
+
`llama` `fine-tuning` `math` `coding` `logical-reasoning` `instruction-following` `transformers`
|
190 |
|
191 |
+
**Summary**:
|
192 |
+
A fine-tuned version of LLaMA-3.2-1B-Instruct specializing in logical reasoning, math problem-solving, and code generation. Perfect for AI-driven tutoring, programming assistance, and logical problem-solving tasks.
|
193 |
# Uploaded model
|
194 |
|
195 |
- **Developed by:** user3432234234
|