|
--- |
|
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 |
|
|
|
|
|
|