riteshraut
commited on
Commit
·
57bb94b
1
Parent(s):
2c5dd57
upgraded embedding
Browse files- Dockerfile +6 -0
- app.py +4 -1
Dockerfile
CHANGED
|
@@ -13,6 +13,12 @@ RUN apt-get update && apt-get install -y \
|
|
| 13 |
# Create a non-root user early
|
| 14 |
RUN useradd --create-home --shell /bin/bash --uid 1000 appuser
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Copy and install Python requirements as root first
|
| 17 |
COPY requirements.txt .
|
| 18 |
RUN pip install --no-cache-dir --upgrade pip
|
|
|
|
| 13 |
# Create a non-root user early
|
| 14 |
RUN useradd --create-home --shell /bin/bash --uid 1000 appuser
|
| 15 |
|
| 16 |
+
# Add this line to accept the HF_TOKEN secret
|
| 17 |
+
ARG HF_TOKEN
|
| 18 |
+
|
| 19 |
+
# Add this line to log in to Hugging Face Hub
|
| 20 |
+
RUN huggingface-cli login --token $HF_TOKEN
|
| 21 |
+
|
| 22 |
# Copy and install Python requirements as root first
|
| 23 |
COPY requirements.txt .
|
| 24 |
RUN pip install --no-cache-dir --upgrade pip
|
app.py
CHANGED
|
@@ -10,6 +10,7 @@ import re
|
|
| 10 |
import io
|
| 11 |
from gtts import gTTS
|
| 12 |
from langchain_core.documents import Document
|
|
|
|
| 13 |
from langchain_community.document_loaders import (
|
| 14 |
TextLoader,
|
| 15 |
Docx2txtLoader,
|
|
@@ -48,9 +49,11 @@ doc_stores = {} # To hold the InMemoryStore for each session
|
|
| 48 |
|
| 49 |
print("Loading embedding model...")
|
| 50 |
try:
|
|
|
|
| 51 |
EMBEDDING_MODEL = HuggingFaceEmbeddings(
|
| 52 |
model_name="google/embeddinggemma-300m",
|
| 53 |
-
model_kwargs={'device': 'cpu'}
|
|
|
|
| 54 |
)
|
| 55 |
print("Embedding model loaded successfully.")
|
| 56 |
except Exception as e:
|
|
|
|
| 10 |
import io
|
| 11 |
from gtts import gTTS
|
| 12 |
from langchain_core.documents import Document
|
| 13 |
+
|
| 14 |
from langchain_community.document_loaders import (
|
| 15 |
TextLoader,
|
| 16 |
Docx2txtLoader,
|
|
|
|
| 49 |
|
| 50 |
print("Loading embedding model...")
|
| 51 |
try:
|
| 52 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 53 |
EMBEDDING_MODEL = HuggingFaceEmbeddings(
|
| 54 |
model_name="google/embeddinggemma-300m",
|
| 55 |
+
model_kwargs={'device': 'cpu'},
|
| 56 |
+
encode_kwargs={'normalize_embeddings': True},
|
| 57 |
)
|
| 58 |
print("Embedding model loaded successfully.")
|
| 59 |
except Exception as e:
|