Downloads · 30 days
0
slifeisenjoy/GENERATOR
GENERATOR is a machine learning model from slifeisenjoy. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
NeuralSec Transformer V2 is a Recursive Transformer (weight-tied) model designed for high-fidelity security vector synthesis. By leveraging recursive layers, the model achieves a 80.88% reduction in size compared to s…
Downloads · 30 days
0
Access
Public
Updated Aug 14, 2026
Repo size
2.9 MB
Likes
1
Public
Click a slice to open those files.
.pth2.9 MB · 99%
From the Hugging Face model README
NeuralSec Transformer V2 is a Recursive Transformer (weight-tied) model designed for high-fidelity security vector synthesis. By leveraging recursive layers, the model achieves a 80.88% reduction in size compared to standard transformers while maintaining deep logical reasoning for generating technical payloads.
vocab.jsonThis is the Dictionary of the model. Transformers do not understand characters; they understand numbers. This file maps every unique character and special token (like [PAD], <SOS>, <EOS>) to a unique integer ID.
xss_transformer_v2.pthThis is the Brain (Trained Weights). It contains the learned parameters of the Recursive Transformer. It stores the neural associations between specific security actions (e.g., CURL, SELECT, ALERT) and their corresponding technical syntax.
We used a multi-domain consolidated training set:
The Recursive Transformer architecture in this project is a specialized variant of the standard Transformer designed for extreme parameter efficiency.
Impact: This reduces the parameter count of the core transformer block by 83% (1/6th of the original size). Logic: Think of it as a 'mental loop' where the model refines its understanding of the security vector instruction through multiple passes using the same set of weights.
the model learns a more generalized, robust representation of syntax. Layer Normalization: Applied after the recursion to stabilize the gradients after the 6-step loop. Linear Head: Projects the final representation back into the vocabulary space to predict the next character.
import torch import json
def load_and_run(action="ALERT", tag="SCRIPT", event="ONLOAD"): """ Clean implementation to load the model and generate a payload. """ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# 1. Load Vocab
with open('vocab.json', 'r') as f:
v_map = json.load(f)
# 2. Re-initialize & Load Weights
# The RecursiveTransformer architecture must be defined in the namespace
model = RecursiveTransformer(len(v_map)).to(device)
model.load_state_dict(torch.load('xss_transformer_v2.pth', map_location=device))
# 3. Generate Optimized Output
result = optimized_inference(model, action, tag, event, temp=0.5)
print(f"[+] Vector: {action} via {tag}")
print(f"[+] Logic : {result['logic']}")
print(f"[+] Data : {result['payload']}")
load_and_run("CURL", "AUTH", "SUCCESS")
def generate_batch_variants(action, tag, event, count=10, temperature=0.7): """ Generates multiple unique neural variants for a specific security vector path. Uses the optimized_inference engine to ensure diversity and technical validity. """ print(f"[🔥] SYNTHESIZING {count} VARIANTS FOR: {action.upper()} -> {tag.upper()} ({event.upper()})\n")
unique_results = set()
attempts = 0
# Iterate until we reach the desired count or hit a safety limit for attempts
while len(unique_results) < count and attempts < count * 3:
# We use temperature to encourage diversity in the transformer's output
res = optimized_inference(model, action.upper(), tag.upper(), event.upper(), temp=temperature)
# Create a unique key for the variant based on the logic and payload
variant_key = f"LOGIC: {res['logic']}\nPAYLOAD: {res['payload']}"
if res['payload'] != "N/A" and variant_key not in unique_results:
unique_results.add(variant_key)
print(f"[VARIANT #{len(unique_results)}]")
print(variant_key)
print("-" * 40)
attempts += 1
if len(unique_results) < count:
print(f"[!] Only generated {len(unique_results)} unique variants after {attempts} attempts.")
generate_batch_variants("CURL", "AUTH", "SUCCESS", count=5, temperature=0.75)
def run_production_synthesis(action, tag, event, count=5): print(f"[⚙️] PRODUCING {count} HIGH-CONSISTENCY VARIANTS (TEMP=0.2)") print(f"[PATH]: {action} -> {tag} [{event}]\n")
for i in range(count):
# Calling the optimized function with low temperature for syntax stability
res = optimized_inference(model, action, tag, event, temp=0.2)
print(f"VARIANT #{i+1}")
print(f"LOGIC: {res['logic']}")
print(f"DATA : {res['payload']}")
print("-" * 60)
run_production_synthesis("SELECT", "COLUMN", "SUCCESS", count=5)
import pandas as pd from IPython.display import display
def run_python_analysis(df_results): print("=== NEURALSEC VECTOR ANALYSIS (PYTHON ONLY) ===\n")
# 1. Summary Metrics
total = len(df_results)
unique_paths = df_results['Vector Path'].nunique()
high_complexity = len(df_results[df_results['Complexity'] == 'High'])
print(f"[METRICS]")
print(f"Total Synthesized: {total}")
print(f"Unique Vector Paths: {unique_paths}")
print(f"High Complexity Variants: {high_complexity} ({(high_complexity/total)*100:.1f}%)")
print("-" * 40)
# 2. Path Distribution
print("\n[VECTOR PATH COVERAGE]")
print(df_results['Vector Path'].value_counts())
print("-" * 40)
# 3. Full Detailed Log
print("\n[SYNTHESIS LOG]")
display(df_results[['Vector Path', 'Model Logic', 'Neural Payload', 'Complexity']])
if 'final_results' in globals(): run_python_analysis(final_results) else: print("[!] No synthesis data found. Please run the generation cells first.")
import random
def run_full_batch_inference(count=50): print(f"[🚀] INITIATING FULL BATCH SYNTHESIS: {count} SAMPLES\n")
# Retrieve available metadata labels
actions = [a.upper() for a in CLEAN_ACTIONS]
tags = [t.upper() for t in CLEAN_TAGS]
events = ["NONE"] + [e.upper() for e in CLEAN_EVENTS]
for i in range(count):
# Randomly sample path parameters
target_act = random.choice(actions)
target_tag = random.choice(tags)
target_ev = random.choice(events)
# Generate using the optimized, noise-filtered inference function
result = optimized_inference(model, target_act, target_tag, target_ev, temp=0.5, top_k=40)
print(f"[#{i+1:02d}] PATH: {target_act} -> {target_tag} ({target_ev})")
print(f"LOGIC: {result['logic']}")
print(f"DATA : {result['payload']}")
print("-" * 80)
run_full_batch_inference(50)
END THANKS