Update README.md
Browse files
README.md
CHANGED
@@ -48,10 +48,29 @@ While this model aims to reduce toxicity, it may still generate biased or harmfu
|
|
48 |
Use the code below to get started with the model:
|
49 |
|
50 |
```python
|
51 |
-
|
|
|
52 |
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
```
|
56 |
|
57 |
## Training Details
|
|
|
48 |
Use the code below to get started with the model:
|
49 |
|
50 |
```python
|
51 |
+
import torch
|
52 |
+
from transformers import AutoTokenizer, AutoPeftModelForCausalLM
|
53 |
|
54 |
+
# Set device
|
55 |
+
DEV = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
56 |
+
|
57 |
+
# Set model and tokenizer path
|
58 |
+
adapter_path = "SungJoo/llama2-7b-sft-detox-DPO"
|
59 |
+
|
60 |
+
# Load model
|
61 |
+
model = AutoPeftModelForCausalLM.from_pretrained(
|
62 |
+
adapter_path,
|
63 |
+
torch_dtype=torch.bfloat16
|
64 |
+
).to(DEV)
|
65 |
+
|
66 |
+
# Load tokenizer
|
67 |
+
tokenizer = AutoTokenizer.from_pretrained(adapter_path)
|
68 |
+
|
69 |
+
# Example usage
|
70 |
+
input_text = "Your input text here"
|
71 |
+
inputs = tokenizer(input_text, return_tensors="pt").to(DEV)
|
72 |
+
outputs = model.generate(**inputs)
|
73 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
74 |
```
|
75 |
|
76 |
## Training Details
|