Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions eval/compile_xscode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
### XSCode
[XSCode](https://huggingface.co/datasets/purpcode/XSCode) is an overrefusal benchmark for secure code generation. While benchmarks like CyberSecEval FRR prompts are lengthy and specifically target malicious cyber activities, XSCode contains 589 short and harmless code-generation prompts that do not contain any built-in code security bias.

### XSCode Generation

```
export PYTHONPATH=$PYTHONPATH:$(pwd)
python eval/compile_xscode/main.py
```

Generation requires AWS bedrock access.

### XSCode Eval

```
export PYTHONPATH=$PYTHONPATH:$(pwd)
python eval/main.py --task "purpcode/xscode" --model <MODEL_NAME>
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

# pip install rich datasets
import argparse
import json
import os
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

"""
Script to process JSONL files and filter records where malicious, unnatural,
and too_simple are all "disagree", then display statistics.
"""

import json
from collections import Counter
from pathlib import Path
Expand All @@ -20,7 +15,7 @@ def analyze_records(records):
return None
print(f"Total records: {len(records)}")
print(
f"{len(set([ record['original_prompt']['additional_context']['cwe_id'] for record in records ]))} unique CWEs"
f"{len({record['original_prompt']['additional_context']['cwe_id'] for record in records})} unique CWEs"
)

# distribution per language
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0


import argparse
import json
from pathlib import Path
Expand Down
Loading