File size: 7,176 Bytes
fcc005e
1d1343d
 
 
 
 
 
fcc005e
1d1343d
fcc005e
1d1343d
 
 
 
 
fcc005e
 
 
 
 
 
1d1343d
fcc005e
1d1343d
fcc005e
1d1343d
fcc005e
 
 
1d1343d
 
 
fcc005e
1d1343d
 
 
fcc005e
 
1d1343d
fcc005e
1d1343d
fcc005e
1d1343d
 
 
fcc005e
 
 
1d1343d
 
 
fcc005e
1d1343d
fcc005e
 
 
1d1343d
 
 
fcc005e
 
 
1d1343d
 
 
fcc005e
1d1343d
fcc005e
 
 
1d1343d
fcc005e
 
1d1343d
fcc005e
 
 
 
1d1343d
fcc005e
 
 
 
1d1343d
fcc005e
1d1343d
fcc005e
 
 
1d1343d
fcc005e
 
 
 
 
 
1d1343d
fcc005e
 
 
 
 
 
 
1d1343d
fcc005e
 
 
1d1343d
fcc005e
1d1343d
fcc005e
1d1343d
fcc005e
 
1d1343d
fcc005e
1d1343d
fcc005e
 
 
 
 
 
 
 
 
 
1d1343d
fcc005e
 
 
1d1343d
 
 
 
 
fcc005e
 
 
1d1343d
 
 
fcc005e
1d1343d
 
 
fcc005e
1d1343d
 
 
fcc005e
 
1d1343d
 
 
 
 
fcc005e
 
1d1343d
 
 
fcc005e
 
1d1343d
 
 
fcc005e
1d1343d
fcc005e
 
 
 
 
 
 
 
1d1343d
fcc005e
1d1343d
fcc005e
1d1343d
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

---
library_name: transformers
tags:
- unsloth
---

# Model Card for `bayrameker/threat_detection_lora`

This LoRA fine-tuned model is designed to identify and generate text related to various defense and security threats. It was trained on a dataset containing examples of different threat categories (e.g., cyber warfare, espionage, disinformation, etc.) in the context of defense industry news or statements.

## Model Details

### Model Description

- **Developed by:** [Bayram Eker (bayrameker)](https://huggingface.co/bayrameker)
- **Finetuned from model:** [unsloth/Phi-4](https://huggingface.co/unsloth/Phi-4)  
- **Model type:** LoRA-based Causal Language Model (decoder-only architecture)
- **Language(s) (NLP):** Primarily Turkish (and some English content, if present in the dataset)
- **License:** *Currently unspecified* (the base model’s license terms may apply)
- **Shared by:** [Bayram Eker (bayrameker)](https://huggingface.co/bayrameker)

This model was LoRA fine-tuned with [Unsloth](https://github.com/unslothai/unsloth) on a curated dataset dealing with defense-related threats, focusing on threat type detection and short descriptive outputs.

### Model Sources

- **Repository (Hub):** [bayrameker/threat_detection_lora](https://huggingface.co/bayrameker/threat_detection_lora)
- **Paper [optional]:** *No dedicated paper at this time*
- **Demo [optional]:** *No public demo at this time*

## Uses

This LoRA model can be used in text generation or chat-like scenarios where the user asks about potential threats in a defense/security context. The model is capable of producing threat categories (e.g., espionage, cyber-attack, disinformation) and short descriptions.

### Direct Use

- **Chatbot / QA assistant** for defense-related threat descriptions.
- **Text generation** around security/defense news, or summarizing threats.

### Downstream Use

- **Threat classification** or **risk analysis** tools, where the model’s generated categories are used as a starting point for further classification pipelines.

### Out-of-Scope Use

- Detailed, real-time intelligence or geostrategic analytics (the model does not guarantee factual correctness or current data).
- Legal, financial, or medical advice.
- Any domain requiring certified, high-stakes decision-making where incorrect predictions could cause harm.

## Bias, Risks, and Limitations

This model was fine-tuned on a relatively specialized dataset focusing on defense-related threats. It may exhibit the following limitations:

- **Hallucination**: The model may invent or exaggerate threat types not present in the data.
- **Cultural / Geographic Bias**: The training data may be more skewed towards certain regions or conflicts.
- **Incomplete or Outdated Info**: The model’s knowledge cutoff depends on the base model and fine-tuning data; it may not reflect the latest developments in defense technology or geopolitics.

### Recommendations

- Do not rely solely on model outputs for critical defense or security-related decisions.
- Cross-verify the model’s threat descriptions with domain experts.
- Be mindful of potential misinterpretations when using the model’s outputs in real-world settings.

## How to Get Started with the Model

Below is a sample code snippet to load and run inference:

```python
from unsloth import FastLanguageModel
from unsloth.chat_templates import get_chat_template

# Load LoRA fine-tuned model from Hugging Face
model_name = "bayrameker/threat_detection_lora"

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name=model_name,
    device_map="auto"
)

tokenizer = get_chat_template(
    tokenizer,
    chat_template="phi-4",
)

FastLanguageModel.for_inference(model)

messages = [
    {"role": "user", "content": "Rusya ile ilgili tehditler"}
]

inputs = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt",
).to(model.device)

outputs = model.generate(
    input_ids=inputs,
    max_new_tokens=256,
    temperature=0.8,
    min_p=0.2,
    use_cache=True,
)

generated_text = tokenizer.batch_decode(outputs, skip_special_tokens=False)[0]
print(generated_text)
```

## Training Details

### Training Data

- The dataset used is from [**bayrameker/threat-detection**](https://huggingface.co/datasets/bayrameker/threat-detection), which contains defense-related short texts (e.g., new weapon systems, geopolitical statements) paired with their potential threats (cyber warfare, espionage, etc.).
- The data is primarily in Turkish, with possible bilingual or English content in some entries.

### Training Procedure

- **LoRA Fine-Tuning Framework**: [Unsloth](https://github.com/unslothai/unsloth)
- **Base Model**: [unsloth/Phi-4](https://huggingface.co/unsloth/Phi-4)
- **Hyperparameters**:
  - LoRA rank (`r`): 16
  - LoRA `lora_alpha`: 16
  - `lora_dropout`: 0
  - Mixed-precision: typically bf16 or fp16 (depending on GPU)
  - Learning Rate (LR): ~2e-4
  - Batch Size / Gradient Accum Steps: Varied based on GPU memory
  - Steps/Epochs: Adjusted for the dataset size

#### Speeds, Sizes, Times [optional]
- Dependent on GPU hardware (e.g., NVIDIA A100 or similar).
- No explicit throughput or wall-clock times reported.

## Evaluation

### Testing Data, Factors & Metrics

- **Testing Data**: The same or a subset of [bayrameker/threat-detection](https://huggingface.co/datasets/bayrameker/threat-detection) can be used for evaluation.
- **Factors**: The content includes different security contexts, focusing on “threat_type” variety.
- **Metrics**: Primarily manual or qualitative evaluation (threat categories are short text). A formal metric (accuracy/F1) could be used if the data had clear gold-standard labels.

### Results

Qualitative evaluation shows the model can produce short paragraphs describing potential threats related to a user’s prompt (e.g., “Rusya ile ilgili tehditler”). Exact numeric scores are not reported.

## Model Examination [optional]

No specific interpretability tools were used or documented.

## Environmental Impact

Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).  
Exact figures not provided.

## Technical Specifications [optional]

### Model Architecture and Objective

- A LoRA adaptation on a GPT-style language model (decoder-only).
- Objective: Next-token prediction, guided by conversation templates (SFT — Supervised Fine Tuning).

### Compute Infrastructure

- **Hardware**: GPU (e.g., NVIDIA A100, or similar).
- **Software**: PyTorch, transformers, accelerate, [Unsloth library](https://github.com/unslothai/unsloth).

## Citation [optional]

If you use or modify this model, please credit the base model (Phi-4 by Unsloth) and the fine-tuning repository.

```bibtex
@misc{bayramekerThreatDetectionLoRA,
  author = {Eker, Bayram},
  title = {{Threat Detection LoRA}},
  howpublished = {\url{https://huggingface.co/bayrameker/threat_detection_lora}},
  year={2023}
}
```

## Model Card Authors

- [Bayram Eker (bayrameker)](https://huggingface.co/bayrameker)