Token Classification
Transformers
Safetensors
PyTorch
English
qwen2
text-generation
custom-model
text-generation-inference
Instructions to use zeltera/SMITH with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zeltera/SMITH with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="zeltera/SMITH")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zeltera/SMITH") model = AutoModelForCausalLM.from_pretrained("zeltera/SMITH", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Delete rag
Browse files- rag/__pycache__/search.cpython-312.pyc +0 -0
- rag/build_index.py +0 -32
- rag/corpus/malware_knowledge.txt +0 -13
- rag/ingest.py +0 -14
- rag/search.py +0 -20
- rag/vectorstore/index.faiss +0 -0
- rag/vectorstore/meta.pkl +0 -3
rag/__pycache__/search.cpython-312.pyc
DELETED
|
Binary file (1.52 kB)
|
|
|
rag/build_index.py
DELETED
|
@@ -1,32 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import faiss
|
| 3 |
-
import pickle
|
| 4 |
-
from sentence_transformers import SentenceTransformer
|
| 5 |
-
|
| 6 |
-
CORPUS_PATH = "../mcma/micro-cyber-llm/rag/corpus/malware_knowledge.txt"
|
| 7 |
-
OUT_DIR = "../mcma/micro-cyber-llm/rag/vectorstore"
|
| 8 |
-
|
| 9 |
-
os.makedirs(OUT_DIR, exist_ok=True)
|
| 10 |
-
|
| 11 |
-
print("[*] Loading embedding model...")
|
| 12 |
-
model = SentenceTransformer("all-MiniLM-L6-v2")
|
| 13 |
-
|
| 14 |
-
print("[*] Reading corpus...")
|
| 15 |
-
with open(CORPUS_PATH, "r", encoding="utf-8") as f:
|
| 16 |
-
documents = [line.strip() for line in f if line.strip()]
|
| 17 |
-
|
| 18 |
-
print(f"[*] Embedding {len(documents)} documents...")
|
| 19 |
-
embeddings = model.encode(documents, show_progress_bar=True)
|
| 20 |
-
|
| 21 |
-
dim = embeddings.shape[1]
|
| 22 |
-
index = faiss.IndexFlatL2(dim)
|
| 23 |
-
index.add(embeddings)
|
| 24 |
-
|
| 25 |
-
print("[*] Saving FAISS index...")
|
| 26 |
-
faiss.write_index(index, f"{OUT_DIR}/index.faiss")
|
| 27 |
-
|
| 28 |
-
print("[*] Saving metadata...")
|
| 29 |
-
with open(f"{OUT_DIR}/meta.pkl", "wb") as f:
|
| 30 |
-
pickle.dump(documents, f)
|
| 31 |
-
|
| 32 |
-
print("[✓] RAG index built successfully!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rag/corpus/malware_knowledge.txt
DELETED
|
@@ -1,13 +0,0 @@
|
|
| 1 |
-
Android malware often abuses READ_SMS to intercept OTP messages.
|
| 2 |
-
Communication with api.telegram.org is commonly used for C2 exfiltration.
|
| 3 |
-
Banking trojans target SMS permissions and overlay attacks.
|
| 4 |
-
APK files requesting SMS and internet permissions are high risk.
|
| 5 |
-
|
| 6 |
-
Windows malware may use CreateRemoteThread for process injection.
|
| 7 |
-
Suspicious EXE files often drop persistence via registry Run keys.
|
| 8 |
-
C2 traffic over HTTPS to unknown domains is a red flag.
|
| 9 |
-
PowerShell abuse is common in post-exploitation.
|
| 10 |
-
|
| 11 |
-
MITRE T1406 refers to SMS Control.
|
| 12 |
-
MITRE T1055 refers to Process Injection.
|
| 13 |
-
MITRE T1059 refers to Command and Scripting Interpreter.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rag/ingest.py
DELETED
|
@@ -1,14 +0,0 @@
|
|
| 1 |
-
from sentence_transformers import SentenceTransformer
|
| 2 |
-
import faiss, os, pickle
|
| 3 |
-
|
| 4 |
-
model = SentenceTransformer("all-MiniLM-L6-v2")
|
| 5 |
-
index = faiss.IndexFlatL2(384)
|
| 6 |
-
docs = []
|
| 7 |
-
|
| 8 |
-
def ingest(text):
|
| 9 |
-
emb = model.encode([text])
|
| 10 |
-
index.add(emb)
|
| 11 |
-
docs.append(text)
|
| 12 |
-
|
| 13 |
-
faiss.write_index(index, "rag/vectorstore/index.faiss")
|
| 14 |
-
pickle.dump(docs, open("rag/vectorstore/docs.pkl", "wb"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rag/search.py
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import faiss
|
| 3 |
-
import pickle
|
| 4 |
-
from sentence_transformers import SentenceTransformer
|
| 5 |
-
|
| 6 |
-
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
| 7 |
-
VECTOR_DIR = os.path.join(BASE_DIR, "rag", "vectorstore")
|
| 8 |
-
|
| 9 |
-
index = faiss.read_index(os.path.join(VECTOR_DIR, "index.faiss"))
|
| 10 |
-
|
| 11 |
-
with open(os.path.join(VECTOR_DIR, "meta.pkl"), "rb") as f:
|
| 12 |
-
documents = pickle.load(f)
|
| 13 |
-
|
| 14 |
-
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
def search_context(query, top_k=3):
|
| 18 |
-
q_emb = model.encode([query])
|
| 19 |
-
D, I = index.search(q_emb, top_k)
|
| 20 |
-
return "\n".join([documents[i] for i in I[0]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rag/vectorstore/index.faiss
DELETED
|
Binary file (16.9 kB)
|
|
|
rag/vectorstore/meta.pkl
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:043712a56c3aa8d0e33c60438f2a3d2fed218fe29a3e62b04f10f30ce7bf98ff
|
| 3 |
-
size 673
|
|
|
|
|
|
|
|
|
|
|
|