Instructions to use Canstralian/AI-DrivenExploitGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Canstralian/AI-DrivenExploitGeneration with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Canstralian/AI-DrivenExploitGeneration", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download src/model_inference.py from Canstralian/AI-DrivenExploitGeneration: direct link, hf CLI and curl.
- Browser
- Download file 877 Bytes
-
https://huggingface.co/Canstralian/AI-DrivenExploitGeneration/resolve/main/src/model_inference.py
- Command line
-
hf download hf://Canstralian/AI-DrivenExploitGeneration/src/model_inference.py
-
curl -L -o model_inference.py https://huggingface.co/Canstralian/AI-DrivenExploitGeneration/resolve/main/src/model_inference.py
877 Bytes
| from transformers import AutoModelForSequenceClassification, AutoTokenizer | |
| import torch | |
| def load_model(model_path): | |
| """Load the trained model from the specified path.""" | |
| model = AutoModelForSequenceClassification.from_pretrained(model_path) | |
| return model | |
| def load_tokenizer(model_path): | |
| """Load the tokenizer from the specified path.""" | |
| tokenizer = AutoTokenizer.from_pretrained(model_path) | |
| return tokenizer | |
| def predict(model, tokenizer, text, device='cpu'): | |
| """Predict the class of the input text.""" | |
| model.to(device) | |
| inputs = tokenizer(text, return_tensors='pt', padding=True, truncation=True) | |
| inputs = {key: value.to(device) for key, value in inputs.items()} | |
| with torch.no_grad(): | |
| outputs = model(**inputs) | |
| logits = outputs.logits | |
| predicted_class = torch.argmax(logits, dim=-1).item() | |
| return predicted_class | |