ChatbotDemo / Dockerfile
Kalpokoch's picture
Deploy full fine-tuned TinyLlama and fix retrieval recall
68e6652
Raw History Blame
1.79 kB
FROM python:3.11-slim
# Install required system dependencies
RUN apt-get update && apt-get install -y \
git curl build-essential cmake \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Create writable directories
RUN mkdir -p /app/.cache /app/vector_database && chmod -R 777 /app
# Set environment variables
ENV TRANSFORMERS_CACHE=/app/.cache \
HF_HOME=/app/.cache \
CHROMADB_DISABLE_TELEMETRY=true
# Install dependencies from requirements.txt first
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Install nltk and download punkt tokenizer once during build
RUN python -m nltk.downloader punkt punkt_tab
# ✅ STEP 1: Copy the source data and the Python script into the image
COPY ./combined_context.jsonl .
COPY ./create_granular_chunks.py .
# ✅ STEP 2: Run the script to generate the chunks file inside the image
RUN python create_granular_chunks.py
# ✅ STEP 3: The 'granular_chunks_improved.jsonl' now exists inside the image.
# We no longer need to copy it from our local machine.
# Note: As recommended before, 'llama-cpp-python' should be removed from requirements.txt
# to rely on the more stable, version-pinned installation below.
RUN pip install --no-cache-dir llama-cpp-python==0.2.61
# Copy the rest of the application code
COPY ./app ./app
# Copy the full-fine-tuned TinyLlama GGUF model (git-lfs tracked in this repo,
# see .gitattributes). Replaces the old curl-from-a-separate-HF-model-repo
# step - Spaces resolve git-lfs pointers automatically on build.
COPY ./tinyllama_dop_full_q4_k_m.gguf /app/tinyllama_dop_full_q4_k_m.gguf
# Expose the application port
EXPOSE 7860
# Run the FastAPI application
CMD ["uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "7860"]