Spaces:
Paused
Paused
Download utils/embedding_utils.py from MarioCerulo/FormuLLaMa-Demo: direct link, hf CLI and curl.
- Browser
- Download file 376 Bytes
-
https://huggingface.co/spaces/MarioCerulo/FormuLLaMa-Demo/resolve/main/utils/embedding_utils.py
- Command line
-
hf download hf://spaces/MarioCerulo/FormuLLaMa-Demo/utils/embedding_utils.py
-
curl -L -o embedding_utils.py https://huggingface.co/spaces/MarioCerulo/FormuLLaMa-Demo/resolve/main/utils/embedding_utils.py
376 Bytes
| from sentence_transformers import SentenceTransformer | |
| from chromadb import Documents, Embeddings, EmbeddingFunction | |
| class CustomEmbeddingFunction(EmbeddingFunction): | |
| def __call__(self, text_chunks: Documents) -> Embeddings: | |
| embedding_model = SentenceTransformer( | |
| model_name_or_path="all-mpnet-base-v2", | |
| device="cpu", | |
| ) | |
| return embedding_model.encode(text_chunks) |