Feed the model a raw CVE description, CVSS score, and vendor, and it will generate a comprehensive report including:
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_id = "vanshkamra12/CyberSecurity-Model"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.float16,
10 device_map="auto"
11)
12
13prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
14
15### Instruction:
16Analyze the following vulnerability data and produce a structured threat intelligence report.
17
18### Input:
19CVE ID: CVE-2024-21762
20Description: A out-of-bound write vulnerability in FortiOS SSL VPN allows a remote unauthenticated attacker to execute arbitrary code or commands via specially crafted HTTP requests.
21CVSS Score: 9.8 CRITICAL
22Vendor: Fortinet
23
24### Response:
25"""
26
27inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
28outputs = model.generate(**inputs, max_new_tokens=1000, temperature=0.7)
29print(tokenizer.decode(outputs[0], skip_special_tokens=True))