File size: 1,434 Bytes
58ccfe7
5cbb644
 
 
 
 
 
 
 
 
 
 
58ccfe7
 
5cbb644
58ccfe7
 
 
5cbb644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58ccfe7
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
60
61
62
63
---
language:
- ru
license: apache-2.0
base_model: gghfez/gemma-3-4b-novision
tags:
- gemma
- gemma-3
- russian
- LoRA
- spief
- safe
---

# Alesya-Safe-4B-v3

## Model Details

* **Base Model:** gghfez/gemma-3-4b-novision
* **Fine-tuned with:** LoRA
* **Domain:** Don't speak about politics
* **Language:** Russian

## Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "ArtemkaT08/alesya-v4"

model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_id)

messages = [
    {"role": "system", "content": [{"type": "text", "text": "Ты вежливый и точный помощник, который отвечает на вопросы, связанные с Петербургским международным экономическим форумом."}]},
    {"role": "user", "content": [{"type": "text", "text": "Когда пройдет следующий ПМЭФ?"}]}
]

inputs = tokenizer.apply_chat_template(
    messages, 
    add_generation_prompt=True,
    tokenize=True,
    return_tensors="pt"
).to(model.device)

with torch.inference_mode():
    outputs = model.generate(
        inputs,
        max_new_tokens=512,
        temperature=0.7,
        top_p=0.9
    )

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