File size: 1,626 Bytes
fcb44cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---

library_name: peft
model_name: minicpm5-coffee-lora
tags:
- peft
- lora
- sft
- coffee
- transformers
- trl
license: apache-2.0
base_model: openbmb/MiniCPM5-1B
pipeline_tag: text-generation
---


# MiniCPM5-1B Coffee LoRA

Base model: [openbmb/MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B)

This LoRA adapter fine-tunes MiniCPM5-1B for specialty coffee knowledge Q&A.
Trained on [ynanxiu/coffee-sft-dataset](https://huggingface.co/datasets/ynanxiu/coffee-sft-dataset).

## Training

- **Method**: LoRA (r=16, alpha=32), BF16
- **Data**: coffee-sft-dataset (80/10/10 train/val/test split)
- **Epochs**: 3
- **Hardware**: RTX 4060 8GB
- **Framework**: TRL SFTTrainer + PEFT

## Usage

```python

from transformers import AutoModelForCausalLM, AutoTokenizer

from peft import PeftModel



base = AutoModelForCausalLM.from_pretrained(

    "openbmb/MiniCPM5-1B",

    torch_dtype="auto",

    device_map="auto",

    trust_remote_code=True

)

model = PeftModel.from_pretrained(base, "ynanxiu/minicpm5-coffee-lora")

tokenizer = AutoTokenizer.from_pretrained("openbmb/MiniCPM5-1B", trust_remote_code=True)



messages = [{"role": "user", "content": "阿拉比卡和罗布斯塔的区别是什么?"}]

text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)

inputs = tokenizer(text, return_tensors="pt").to(model.device)

outputs = model.generate(**inputs, max_new_tokens=256)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

```

## Framework versions

- PEFT 0.19.1
- TRL 0.24.0
- Transformers 5.5.0
- PyTorch 2.6.0+cu124