Spaces:
Paused
Paused
Download rag/ingest.py from zeltera/mcma_malware: direct link, hf CLI and curl.
- Browser
- Download file 397 Bytes
-
https://huggingface.co/spaces/zeltera/mcma_malware/resolve/main/rag/ingest.py
- Command line
-
hf download hf://spaces/zeltera/mcma_malware/rag/ingest.py
-
curl -L -o ingest.py https://huggingface.co/spaces/zeltera/mcma_malware/resolve/main/rag/ingest.py
397 Bytes
| from sentence_transformers import SentenceTransformer | |
| import faiss, os, pickle | |
| model = SentenceTransformer("all-MiniLM-L6-v2") | |
| index = faiss.IndexFlatL2(384) | |
| docs = [] | |
| def ingest(text): | |
| emb = model.encode([text]) | |
| index.add(emb) | |
| docs.append(text) | |
| faiss.write_index(index, "rag/vectorstore/index.faiss") | |
| pickle.dump(docs, open("rag/vectorstore/docs.pkl", "wb")) | |