Text Generation
Transformers
Safetensors
English
gpt2
cybersecurity
passwords
text-generation-inference
Instructions to use CodeferSystem/GPT2-Hacker-password-generator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CodeferSystem/GPT2-Hacker-password-generator with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CodeferSystem/GPT2-Hacker-password-generator")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("CodeferSystem/GPT2-Hacker-password-generator") model = AutoModelForCausalLM.from_pretrained("CodeferSystem/GPT2-Hacker-password-generator", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CodeferSystem/GPT2-Hacker-password-generator with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CodeferSystem/GPT2-Hacker-password-generator" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CodeferSystem/GPT2-Hacker-password-generator", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/CodeferSystem/GPT2-Hacker-password-generator
- SGLang
How to use CodeferSystem/GPT2-Hacker-password-generator 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 "CodeferSystem/GPT2-Hacker-password-generator" \ --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": "CodeferSystem/GPT2-Hacker-password-generator", "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 "CodeferSystem/GPT2-Hacker-password-generator" \ --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": "CodeferSystem/GPT2-Hacker-password-generator", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use CodeferSystem/GPT2-Hacker-password-generator with Docker Model Runner:
docker model run hf.co/CodeferSystem/GPT2-Hacker-password-generator
File size: 3,365 Bytes
8da5163 38c9b8b 235f3a5 8da5163 38c9b8b 8da5163 38c9b8b 8da5163 235f3a5 8f4b267 235f3a5 ee6c96a 8f4b267 ee6c96a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | ---
license: apache-2.0
language:
- en
pipeline_tag: text-generation
base_model:
- openai-community/gpt2
library_name: transformers
datasets:
- CodeferSystem/GPT2-Hacker-password-generator-dataset
tags:
- cybersecurity
- passwords
---
# GPT-2 Hacker password generator.
This model can generate hacker passwords.
# Fine-tuning results
Number of epochs: 5
Number of steps: 3125
Loss: 0.519600
Fine-tuning time: almost 34:39 on Nvidia Geforce RTX 4060 8 GB GPU (laptop)
Fine-tuned on 20k examples of 128 tokens.
# Using the model
Use this code:
```python
from transformers import GPT2Tokenizer, GPT2LMHeadModel
import torch
model_name = "CodeferSystem/GPT2-Hacker-password-generator"
# Load the pre-trained GPT-2 model and tokenizer from the specified directory
tokenizer = GPT2Tokenizer.from_pretrained(model_name) # Load standard GPT-2 tokenizer
model = GPT2LMHeadModel.from_pretrained(model_name) # Load fine-tuned GPT-2 model
# Function to generate an answer based on a given question
def generate_answer(question):
# Create a prompt by formatting the question for the model
prompt = f"Question: {question}\nAnswer:"
# Encode the prompt into input token IDs suitable for the model
input_ids = tokenizer.encode(prompt, return_tensors="pt")
# Set the model to evaluation mode
model.eval()
# Generate the output without calculating gradients (for efficiency)
with torch.no_grad():
output = model.generate(
input_ids, # Provide the input tokens
max_length=50, # Set the maximum length of the generated text
num_return_sequences=1, # Only return one sequence of text
no_repeat_ngram_size=2, # Prevent repeating n-grams (sequences of n words)
do_sample=True, # Enable sampling (randomized generation)
top_k=50, # Limit the model's choices to the top 50 probable words
top_p=0.95, # Use nucleus sampling (the cumulative probability distribution)
temperature=2.0, # Control the randomness/creativity of the output
pad_token_id=tokenizer.eos_token_id # Specify the padding token ID (EOS token in this case)
)
# Decode the generated token IDs back to a string and strip any special tokens
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
# Extract the part after "Answer:" to get the model's generated answer
answer = generated_text.split("Answer:")[-1].strip()
return answer
# Example usage
question = "generate password."
print(generate_answer(question)) # Print the generated password
```
# Example passwords generation with this model:
### If you write a prompt like "Generate a hacker password." - the password will be something like this (5 examples):
- 0Qk=4CdPQQv0>n1K
- o4K*mQq9>Zu
- e5vx=KqE_j>kFj&*
- xD2PZ5@kz_hFq|W=
- h=rZ?^<Qp~7&z7XZ
## Dataset of this model
The dataset on which the model was fine-tuned was uploaded to the public.
[Dataset this model](https://huggingface.co/datasets/CodeferSystem/GPT2-Hacker-password-generator-dataset)
## More improved model
[GPT-2-Hacker-password-generator-Medium](https://huggingface.co/CodeferSystem/GPT2-Hacker-password-generator-Medium) |