Instructions to use Vanessasml/cyber-risk-llama-3-8b-instruct-sft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Vanessasml/cyber-risk-llama-3-8b-instruct-sft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Vanessasml/cyber-risk-llama-3-8b-instruct-sft") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Vanessasml/cyber-risk-llama-3-8b-instruct-sft") model = AutoModelForCausalLM.from_pretrained("Vanessasml/cyber-risk-llama-3-8b-instruct-sft") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Vanessasml/cyber-risk-llama-3-8b-instruct-sft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Vanessasml/cyber-risk-llama-3-8b-instruct-sft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Vanessasml/cyber-risk-llama-3-8b-instruct-sft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Vanessasml/cyber-risk-llama-3-8b-instruct-sft
- SGLang
How to use Vanessasml/cyber-risk-llama-3-8b-instruct-sft 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 "Vanessasml/cyber-risk-llama-3-8b-instruct-sft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Vanessasml/cyber-risk-llama-3-8b-instruct-sft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Vanessasml/cyber-risk-llama-3-8b-instruct-sft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Vanessasml/cyber-risk-llama-3-8b-instruct-sft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Vanessasml/cyber-risk-llama-3-8b-instruct-sft with Docker Model Runner:
docker model run hf.co/Vanessasml/cyber-risk-llama-3-8b-instruct-sft
Model Card for Cyber-risk-llama-3-8b-instruct-sft
Model Description
This model is a fine-tuned version of meta-llama/Meta-Llama-3-8B-Instruct on the vanessasml/cybersecurity_32k_instruction_input_output dataset.
It is specifically designed to enhance performance in generating and understanding cybersecurity, identifying cyber threats and classifying data under the NIST taxonomy and IT Risks based on the ITC EBA guidelines.
Intended Use
- Intended users: Data scientists and developers working on cybersecurity applications.
- Out-of-scope use cases: This model should not be used for medical advice, legal decisions, or any life-critical systems.
Training Data
The model was fine-tuned on vanessasml/cybersecurity_32k_instruction_input_output, a dataset focused on cybersecurity news analysis.
No special data format was applied as recommended, although the following steps need to be applied to adjust the input:
# During training
from trl import setup_chat_format
model, tokenizer = setup_chat_format(model, tokenizer)
# During inference
messages = [
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
{"role": "user", "content": "Who are you?"},
]
prompt = pipeline.tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
Training Procedure
- Preprocessing: Text data were tokenized using the tokenizer corresponding to the base model
meta-llama/Meta-Llama-3-8B-Instruct. - Hardware: The training was performed on GPUs with mixed precision (FP16/BF16) enabled.
- Optimizer: Paged AdamW with a cosine learning rate schedule.
- Epochs: The model was trained for 1 epoch.
- Batch size: 4 per device, with gradient accumulation where required.
Evaluation Results
Model evaluation was based on qualitative assessment of generated text relevance and coherence in the context of cybersecurity.
Quantization and Optimization
- Quantization: 4-bit precision with type
nf4. Nested quantization is disabled. - Compute dtype:
float16to ensure efficient computation. - LoRA Settings:
- LoRA attention dimension:
64 - Alpha parameter for LoRA scaling:
16 - Dropout in LoRA layers:
0.1
- LoRA attention dimension:
Environmental Impact
- Compute Resources: Training leveraged energy-efficient hardware and practices to minimize carbon footprint.
- Strategies: Gradient checkpointing and group-wise data processing were used to optimize memory and power usage.
How to Use
Here is how to load and use the model using transformers:
import transformers
model_name = "vanessasml/cyber-risk-llama-3-8b-instruct-sft"
# Example of how to use the model:
pipeline = transformers.pipeline(
"text-generation",
model=model_name,
model_kwargs={"torch_dtype": torch.bfloat16},
device="cuda",
)
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "What are the main 5 cyber classes from the NIST cyber framework?"},
]
prompt = pipeline.tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
terminators = [
pipeline.tokenizer.eos_token_id,
pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = pipeline(
prompt,
max_new_tokens=256,
eos_token_id=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9,
)
print(outputs[0]["generated_text"][len(prompt):])
Limitations and Bias
The model, while robust in cybersecurity contexts, may not generalize well to unrelated domains. Users should be cautious of biases inherent in the training data which may manifest in model predictions.
Citation
If you use this model, please cite it as follows:
@misc{cyber-risk-llama-3-8b-instruct-sft,
author = {Vanessa Lopes},
title = {Cyber-risk-llama-3-8B-Instruct-sft Model},
year = {2024},
publisher = {HuggingFace Hub},
journal = {HuggingFace Model Hub}
}
- Downloads last month
- 16