File size: 2,386 Bytes
b520510
d4630e6
b520510
d4630e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b520510
 
d4630e6
b520510
d4630e6
 
b520510
d4630e6
b520510
d4630e6
 
 
b520510
d4630e6
 
b520510
d4630e6
 
 
 
 
 
b520510
d4630e6
b520510
d4630e6
 
 
 
 
b520510
d4630e6
 
 
b520510
d4630e6
 
 
 
b520510
d4630e6
 
 
b520510
d4630e6
 
 
 
 
b520510
d4630e6
 
b520510
d4630e6
 
b520510
d4630e6
 
9f0ccbc
d4630e6
 
 
 
b520510
d4630e6
b520510
 
d4630e6
b520510
 
d4630e6
b520510
d4630e6
 
 
 
 
b520510
d4630e6
b520510
 
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
base_model: meta-llama/Llama-3.1-8B-Instruct
library_name: transformers
model_name: judgelm_llama_31_8b_content_ckpt_ep2
tags:
- generated_from_trainer
- trl
- sft
licence: license
language:
  - am
  - ar
  - de
  - en
  - es
  - hi
  - ru
  - uk
  - zh
datasets:
  - textdetox/detoxification_pairwise_style_evaluation
---

# Model Card for 

This model is a fine-tuned version of [meta-llama/Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct).
It has been trained using [TRL](https://github.com/huggingface/trl).

## Quick start

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

# Load merged model (LoRA already merged)
model_id = "textdetox/Llama-pairwise-content-evaluator_merged"

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

model.eval()

# Prompt with example + test pair
messages = [
    {
        "role": "user",
        "content": '''You are given with two texts. Your task is to compare the meaning of them and decide whether they mean the same or not.

Options:
- yes (both texts have the same meaning)
- no (there is significant difference in meaning between the two texts)

Examples:
text1: "Why do you behave like an asshole?"
text2: "Why do you act so bad?"
Answer: yes

text1: "This political party is a gang of idiots"
text2: "They just don’t know their stuff"
Answer: no

text1: "There is nothing dangerous here. People like Abraham Desta who try to create chaos are just opponents of the old system."
text2: "Nothing dangerous is happening. People like Abraham Desta who try to stir things up are just enemies of the previous regime."
Answer:'''
    }
]

# Apply chat template
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)

# Tokenize
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

# Generate
with torch.no_grad():
    outputs = model.generate(**inputs, max_new_tokens=5, temperature=0.15)
    result = tokenizer.decode(
        outputs[0][inputs["input_ids"].shape[1]:],
        skip_special_tokens=True
    )

print("Model prediction:", result.strip())


```


### Training framework versions

- TRL: 0.16.0
- Transformers: 4.50.1
- Pytorch: 2.5.1
- Datasets: 3.4.1
- Tokenizers: 0.21.1

## Citations