File size: 1,073 Bytes
ab7b3fd
 
b47f1ab
ab7b3fd
b47f1ab
 
 
ab7b3fd
 
b47f1ab
 
 
 
ab7b3fd
 
b47f1ab
ab7b3fd
dfeab0d
ab7b3fd
 
b47f1ab
 
 
 
 
ab7b3fd
b47f1ab
ab7b3fd
b47f1ab
 
 
ab7b3fd
b47f1ab
 
 
ab7b3fd
b47f1ab
 
 
 
 
ab7b3fd
b47f1ab
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
34
35
36
37
38
39
40
41
42
43
---
library_name: peft
base_model: Qwen/Qwen2.5-1.5B
tags:
- kant
- philosophy
- persona
- lora
- unsloth
- fine-tuned
license: apache-2.0
datasets:
- tarnava/kant_qa
---

# Kant-Qwen-1.5B (LoRA)

**Qwen2.5-1.5B** fine-tuned .


## Training
- Dataset: [tarnava/kant_qa](https://huggingface.co/datasets/tarnava/kant_qa) (3873 examples)
- Base: `Qwen/Qwen2.5-1.5B`
- LoRA: r=64, 3 epochs
- Final loss: **0.21**

## Usage

```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B", device_map="auto")
model = PeftModel.from_pretrained(model, "modular-ai/qwen")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-1.5B")

def ask_kant(q):
    prompt = f"### Instruction: You are Immanuel Kant.\n\n### Input: {q}\n\n### Response:"
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
    output = model.generate(**inputs, max_new_tokens=300)
    return tokenizer.decode(output[0]).split("### Response:")[-1].strip()

print(ask_kant("What is freedom?"))