Views
No views yet
1import warnings
2import os
3os.environ["TF_ENABLE_ONEDNN_OPTS"] = "0"
4os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
5os.environ["TRANSFORMERS_NO_ADVISORY_WARNINGS"] = "1"
6warnings.filterwarnings("ignore")
7import torch
8from transformers import AutoTokenizer, T5ForConditionalGeneration
9model_name = "Prachir-AI/cveparrot"
10tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
11
12
13model = T5ForConditionalGeneration.from_pretrained(model_name)
14
15device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
16model.to(device)
17
18prompt = "Provide detailed information about CVE-2021-3184."
19inputs = tokenizer(prompt, return_tensors="pt").to(device)
20
21with torch.no_grad():
22 output_ids = model.generate(
23 **inputs,
24 max_new_tokens=128,
25 temperature=1.0,
26 do_sample=True,
27 )
28
29response = tokenizer.decode(output_ids[0], skip_special_tokens=True)
30print(response)Note: T5 architecture support in Ollama may be experimental. If you encounter issues, please use the Hugging Face Transformers method (Option 1) or try alternative GGUF inference tools likellama.cpp.
1# Linux
2curl -fsSL https://ollama.com/install.sh | sh
3
4# macOS
5brew install ollama
6
7# Or download from https://ollama.comcveparrot.gguf from the Files section of this repository.Modelfile in the same directory as the downloaded GGUF:FROM ./cveparrot.gguf
TEMPLATE """{{ .Prompt }}"""
PARAMETER temperature 0.7
PARAMETER top_p 0.9
PARAMETER top_k 40
PARAMETER num_ctx 20481# Create the model in Ollama
2ollama create cveparrot -f Modelfile
3
4# Interactive mode
5ollama run cveparrot
6
7# Single query
8ollama run cveparrot "Describe CVE-2024-1234"pip install ollama1import ollama
2
3# Generate response
4response = ollama.generate(
5 model='cveparrot', # Use the local model name you created
6 prompt='Describe the security vulnerability CVE-2024-1234',
7)
8
9print(response['response'])1curl http://localhost:11434/api/generate -d '{
2 "model": "cveparrot",
3 "prompt": "Describe CVE-2024-1234",
4 "stream": false
5}'model.safetensors: PyTorch model weights in Safetensors formatcveparrot.gguf: Quantized GGUF model for efficient inferencetokenizer_config.json: Tokenizer configurationconfig.json: Model configurationspiece.model: SentencePiece tokenizer model