Spaces:
Sleeping
Sleeping
Commit
·
e0b2bb1
1
Parent(s):
d668aec
Enh model prompting and sequential processing
Browse files- Dockerfile +6 -3
- build.sh +6 -2
- requirements-dev.txt +17 -0
- requirements.txt +11 -3
Dockerfile
CHANGED
|
@@ -13,13 +13,16 @@ WORKDIR $HOME/app
|
|
| 13 |
ARG IS_LOCAL=false
|
| 14 |
ENV IS_LOCAL=${IS_LOCAL}
|
| 15 |
|
| 16 |
-
# Install Python dependencies
|
| 17 |
COPY --chown=user requirements.txt .
|
| 18 |
-
# Install local mode dependencies if IS_LOCAL is true
|
| 19 |
COPY --chown=user requirements-dev.txt .
|
| 20 |
-
RUN pip install --upgrade pip &&
|
| 21 |
if [ "$IS_LOCAL" = "true" ]; then \
|
|
|
|
| 22 |
pip install --no-cache-dir -r requirements-dev.txt; \
|
|
|
|
|
|
|
|
|
|
| 23 |
fi
|
| 24 |
|
| 25 |
# Copy the application
|
|
|
|
| 13 |
ARG IS_LOCAL=false
|
| 14 |
ENV IS_LOCAL=${IS_LOCAL}
|
| 15 |
|
| 16 |
+
# Install Python dependencies based on mode (better layer caching)
|
| 17 |
COPY --chown=user requirements.txt .
|
|
|
|
| 18 |
COPY --chown=user requirements-dev.txt .
|
| 19 |
+
RUN pip install --upgrade pip && \
|
| 20 |
if [ "$IS_LOCAL" = "true" ]; then \
|
| 21 |
+
echo "Installing LOCAL mode dependencies (MedAlpaca-13b)"; \
|
| 22 |
pip install --no-cache-dir -r requirements-dev.txt; \
|
| 23 |
+
else \
|
| 24 |
+
echo "Installing CLOUD mode dependencies (NVIDIA/Gemini APIs)"; \
|
| 25 |
+
pip install --no-cache-dir -r requirements.txt; \
|
| 26 |
fi
|
| 27 |
|
| 28 |
# Copy the application
|
build.sh
CHANGED
|
@@ -60,8 +60,8 @@ elif [ "$1" = "cloud" ]; then
|
|
| 60 |
else
|
| 61 |
# Interactive mode selection
|
| 62 |
echo "Please select the runtime mode:"
|
| 63 |
-
echo "1) Local mode (MedAlpaca-13b) - No API costs, complete privacy"
|
| 64 |
-
echo "2) Cloud mode (NVIDIA/Gemini APIs) - Faster processing, requires API keys"
|
| 65 |
echo ""
|
| 66 |
|
| 67 |
while true; do
|
|
@@ -83,9 +83,13 @@ if prompt_yes_no "Would you like to build/rebuild the Docker image?"; then
|
|
| 83 |
echo ""
|
| 84 |
if [ "$MODE" = "local" ]; then
|
| 85 |
echo "🏠 Building in LOCAL mode (MedAlpaca-13b)..."
|
|
|
|
|
|
|
| 86 |
docker build --build-arg IS_LOCAL=true -t medai-processing:local .
|
| 87 |
else
|
| 88 |
echo "☁️ Building in CLOUD mode (NVIDIA/Gemini APIs)..."
|
|
|
|
|
|
|
| 89 |
docker build --build-arg IS_LOCAL=false -t medai-processing:cloud .
|
| 90 |
fi
|
| 91 |
|
|
|
|
| 60 |
else
|
| 61 |
# Interactive mode selection
|
| 62 |
echo "Please select the runtime mode:"
|
| 63 |
+
echo "1) Local mode (MedAlpaca-13b) - No API costs, complete privacy, heavy dependencies"
|
| 64 |
+
echo "2) Cloud mode (NVIDIA/Gemini APIs) - Faster processing, requires API keys, lightweight"
|
| 65 |
echo ""
|
| 66 |
|
| 67 |
while true; do
|
|
|
|
| 83 |
echo ""
|
| 84 |
if [ "$MODE" = "local" ]; then
|
| 85 |
echo "🏠 Building in LOCAL mode (MedAlpaca-13b)..."
|
| 86 |
+
echo " - Installing local LLM dependencies (torch-cuda, accelerate, bitsandbytes, etc.)"
|
| 87 |
+
echo " - Excluding cloud API dependencies (google-genai, google-auth, etc.)"
|
| 88 |
docker build --build-arg IS_LOCAL=true -t medai-processing:local .
|
| 89 |
else
|
| 90 |
echo "☁️ Building in CLOUD mode (NVIDIA/Gemini APIs)..."
|
| 91 |
+
echo " - Installing cloud API dependencies (google-genai, google-auth, etc.)"
|
| 92 |
+
echo " - Excluding heavy local LLM dependencies (torch-cuda, accelerate, bitsandbytes, etc.)"
|
| 93 |
docker build --build-arg IS_LOCAL=false -t medai-processing:cloud .
|
| 94 |
fi
|
| 95 |
|
requirements-dev.txt
CHANGED
|
@@ -1,6 +1,18 @@
|
|
| 1 |
# Local mode dependencies for MedAlpaca-13b inference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
torch>=2.0.0
|
| 3 |
torch-cuda>=2.0.0
|
|
|
|
| 4 |
accelerate>=0.20.0
|
| 5 |
bitsandbytes>=0.41.0
|
| 6 |
peft>=0.4.0
|
|
@@ -8,3 +20,8 @@ datasets>=2.14.0
|
|
| 8 |
evaluate>=0.4.0
|
| 9 |
scipy>=1.10.0
|
| 10 |
scikit-learn>=1.3.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Local mode dependencies for MedAlpaca-13b inference
|
| 2 |
+
# Core framework dependencies
|
| 3 |
+
fastapi
|
| 4 |
+
uvicorn[standard]
|
| 5 |
+
python-dotenv
|
| 6 |
+
huggingface_hub
|
| 7 |
+
requests
|
| 8 |
+
orjson
|
| 9 |
+
ftfy
|
| 10 |
+
langid
|
| 11 |
+
|
| 12 |
+
# Local LLM dependencies
|
| 13 |
torch>=2.0.0
|
| 14 |
torch-cuda>=2.0.0
|
| 15 |
+
transformers>=4.30.0
|
| 16 |
accelerate>=0.20.0
|
| 17 |
bitsandbytes>=0.41.0
|
| 18 |
peft>=0.4.0
|
|
|
|
| 20 |
evaluate>=0.4.0
|
| 21 |
scipy>=1.10.0
|
| 22 |
scikit-learn>=1.3.0
|
| 23 |
+
sentencepiece
|
| 24 |
+
sacremoses
|
| 25 |
+
|
| 26 |
+
# Vietnamese translation (Opus model fallback)
|
| 27 |
+
# Note: google-genai and google-auth packages are excluded for local mode
|
requirements.txt
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
|
|
|
|
|
| 1 |
fastapi
|
| 2 |
uvicorn[standard]
|
| 3 |
python-dotenv
|
| 4 |
huggingface_hub
|
| 5 |
requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
google-genai
|
| 7 |
google-api-python-client
|
| 8 |
google-auth
|
| 9 |
google-auth-httplib2
|
| 10 |
google-auth-oauthlib
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
langid
|
| 14 |
transformers
|
| 15 |
torch
|
| 16 |
sentencepiece
|
| 17 |
sacremoses
|
|
|
|
|
|
|
|
|
| 1 |
+
# Cloud mode dependencies for NVIDIA/Gemini API integration
|
| 2 |
+
# Core framework dependencies
|
| 3 |
fastapi
|
| 4 |
uvicorn[standard]
|
| 5 |
python-dotenv
|
| 6 |
huggingface_hub
|
| 7 |
requests
|
| 8 |
+
orjson
|
| 9 |
+
ftfy
|
| 10 |
+
langid
|
| 11 |
+
|
| 12 |
+
# Cloud API dependencies
|
| 13 |
google-genai
|
| 14 |
google-api-python-client
|
| 15 |
google-auth
|
| 16 |
google-auth-httplib2
|
| 17 |
google-auth-oauthlib
|
| 18 |
+
|
| 19 |
+
# Vietnamese translation (Opus model fallback)
|
|
|
|
| 20 |
transformers
|
| 21 |
torch
|
| 22 |
sentencepiece
|
| 23 |
sacremoses
|
| 24 |
+
|
| 25 |
+
# Note: Heavy local LLM dependencies (accelerate, bitsandbytes, etc.) are excluded for cloud mode
|