Spaces:
Sleeping
Sleeping
RAG PDF Assistant
Initial commit: Production-ready RAG PDF Assistant with HuggingFace integration
1b31f0c Download retrieval/embedder.py from EbiAraz/RAG-PDF-Project: direct link, hf CLI and curl.
- Browser
- Download file 447 Bytes
-
https://huggingface.co/spaces/EbiAraz/RAG-PDF-Project/resolve/main/retrieval/embedder.py
- Command line
-
hf download hf://spaces/EbiAraz/RAG-PDF-Project/retrieval/embedder.py
-
curl -L -o embedder.py https://huggingface.co/spaces/EbiAraz/RAG-PDF-Project/resolve/main/retrieval/embedder.py
447 Bytes
| from sentence_transformers import SentenceTransformer | |
| from configs.settings import EMBED_MODEL | |
| import numpy as np | |
| _model = None | |
| def _get_model(): | |
| global _model | |
| if _model is None: | |
| print(f'Loading embedding model: {EMBED_MODEL}...') | |
| _model = SentenceTransformer(EMBED_MODEL) | |
| return _model | |
| def embed(texts): | |
| model = _get_model() | |
| vectors = model.encode(texts) | |
| return np.array(vectors).astype('float32') |