shukdevdatta123 commited on
Commit
3093a0f
·
verified ·
1 Parent(s): b58a2af

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -9
README.md CHANGED
@@ -35,25 +35,56 @@ library_name: peft
35
 
36
  ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
  ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
 
 
45
 
46
- ### Downstream Use [optional]
 
 
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
 
 
 
 
49
 
50
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
 
56
- [More Information Needed]
57
 
58
  ## Bias, Risks, and Limitations
59
 
 
35
 
36
  ## Uses
37
 
 
 
38
  ### Direct Use
39
 
40
+ To use the SQL Injection Classifier model, you can follow the code snippet below. This example demonstrates how to predict whether a given SQL query is normal or an injection attack.
41
 
42
+ ```python
43
+ from unsloth import FastLanguageModel
44
+ from transformers import AutoTokenizer
45
 
46
+ # Load the model and tokenizer
47
+ model_name = "unsloth/DeepSeek-R1-Distill-Llama-8B"
48
+ hf_token = "your hf tokens"
49
 
50
+ model, tokenizer = FastLanguageModel.from_pretrained(
51
+ model_name=model_name,
52
+ load_in_4bit=True,
53
+ token=hf_token,
54
+ )
55
 
56
+ # Function for testing queries
57
+ def predict_sql_injection(query):
58
+ # Prepare the model for inference
59
+ inference_model = FastLanguageModel.for_inference(model)
60
+
61
+ prompt = f"### Instruction:\nClassify the following SQL query as normal (0) or an injection attack (1).\n\n### Query:\n{query}\n\n### Classification:\n"
62
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
63
+
64
+ # Use the inference model for generation
65
+ outputs = inference_model.generate(
66
+ input_ids=inputs.input_ids,
67
+ attention_mask=inputs.attention_mask,
68
+ max_new_tokens=1000,
69
+ use_cache=True,
70
+ )
71
+ prediction = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
72
+ return prediction.split("### Classification:\n")[-1].strip()
73
+
74
+ # Example usage
75
+ test_query = "SELECT * FROM users WHERE id = '1' OR '1'='1' --"
76
+ result = predict_sql_injection(test_query)
77
+ print(f"Query: {test_query}\nPrediction: {result}")
78
+ ```
79
+
80
+ ### Downstream Use
81
+
82
+ This model can be integrated into applications requiring SQL injection detection, such as web application firewalls, database query analyzers, and security auditing tools. It can help identify and prevent potential vulnerabilities in SQL queries.
83
 
84
  ### Out-of-Scope Use
85
 
86
+ This model should not be used for malicious purposes, such as testing vulnerabilities on unauthorized systems, or for making security decisions without human oversight. It is essential to understand that the model's predictions should be interpreted with caution and supplemented with additional security measures.
87
 
 
88
 
89
  ## Bias, Risks, and Limitations
90