Instructions to use anjohn0077/NEXS-toxicity-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use anjohn0077/NEXS-toxicity-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B") model = PeftModel.from_pretrained(base_model, "anjohn0077/NEXS-toxicity-lora") - Notebooks
- Google Colab
- Kaggle
Update README for sanitized vLLM-ready toxicity adapter
Browse files
README.md
CHANGED
|
@@ -6,23 +6,52 @@ library_name: peft
|
|
| 6 |
tags:
|
| 7 |
- mergekit
|
| 8 |
- peft
|
| 9 |
-
|
|
|
|
| 10 |
---
|
| 11 |
-
# toxicity
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
> The vocabulary size has been extended from the base model's 128256 to 128258. To load this adapter, you must first call `model.resize_token_embeddings(128258)`.
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
```
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
```
|
|
|
|
| 6 |
tags:
|
| 7 |
- mergekit
|
| 8 |
- peft
|
| 9 |
+
- lora
|
| 10 |
+
- vllm
|
| 11 |
---
|
| 12 |
+
# NEXS toxicity LoRA (vLLM-ready)
|
| 13 |
+
|
| 14 |
+
Rank-128 LoRA adapter for the **toxicity** domain, extracted with
|
| 15 |
+
[mergekit](https://github.com/arcee-ai/mergekit) from
|
| 16 |
+
[K-intelligence/Llama-SafetyGuard-Content-Binary](https://huggingface.co/K-intelligence/Llama-SafetyGuard-Content-Binary) against the base model
|
| 17 |
+
[meta-llama/Llama-3.1-8B](https://huggingface.co/meta-llama/Llama-3.1-8B), then sanitized for vLLM
|
| 18 |
+
serving.
|
| 19 |
+
|
| 20 |
+
## Sanitization applied
|
| 21 |
+
|
| 22 |
+
The raw mergekit extraction included full-rank `modules_to_save` tensors
|
| 23 |
+
(`embed_tokens`, `lm_head`, and RMSNorm layers) that vLLM's LoRA runtime does
|
| 24 |
+
not support. This upload contains only the pure low-rank `lora_A`/`lora_B`
|
| 25 |
+
weights (224 pairs: 32 layers x q/k/v/o/gate/up/down projections, bf16), with
|
| 26 |
+
`modules_to_save: null` in `adapter_config.json`. No `resize_token_embeddings()`
|
| 27 |
+
call is needed to load this adapter.
|
| 28 |
+
|
| 29 |
+
## Serving with vLLM
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
python -m vllm.entrypoints.openai.api_server \
|
| 33 |
+
--model meta-llama/Llama-3.1-8B \
|
| 34 |
+
--enable-lora \
|
| 35 |
+
--lora-modules toxicity=anjohn0077/NEXS-toxicity-lora \
|
| 36 |
+
--port 8000 \
|
| 37 |
+
--max-lora-rank 128 \
|
| 38 |
+
--gpu-memory-utilization 0.85
|
| 39 |
+
```
|
| 40 |
|
| 41 |
+
## Evaluation (sst2)
|
|
|
|
| 42 |
|
| 43 |
+
| Variant | Accuracy |
|
| 44 |
+
|---|---|
|
| 45 |
+
| Base model | 0.6732 |
|
| 46 |
+
| **This LoRA on base (via vLLM)** | **0.8991** |
|
| 47 |
+
| Original full fine-tune | 0.8899 |
|
| 48 |
|
| 49 |
+
Evaluated with [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness)
|
| 50 |
+
against a local vLLM OpenAI-compatible endpoint:
|
| 51 |
|
| 52 |
+
```bash
|
| 53 |
+
lm_eval --model local-completions \
|
| 54 |
+
--model_args model=toxicity,base_url=http://localhost:8000/v1/completions,tokenizer=meta-llama/Llama-3.1-8B,num_concurrent=10 \
|
| 55 |
+
--tasks sst2 \
|
| 56 |
+
--output_path results/vllm_toxicity
|
| 57 |
```
|