CA-Foundation / backend /SETUP_OFFLINE.md
“vinit5112”
Add all code
deb090d
|
raw
history blame
2.06 kB

Offline Mode Setup Guide

Problem

The application fails to start with network connectivity errors when trying to download the sentence transformer model from Hugging Face.

Error Message

Failed to resolve 'huggingface.co' ([Errno 11001] getaddrinfo failed)

Solutions

Option 1: Download Model When You Have Internet Access

  1. When you have internet access, run the download script:

    cd backend
    python download_model.py
    
  2. This will download and cache the model locally for offline use.

Option 2: Manual Download

If you have internet access on another machine:

  1. On a machine with internet access, run:

    from sentence_transformers import SentenceTransformer
    model = SentenceTransformer('all-MiniLM-L6-v2')
    
  2. Copy the cached model from:

    • Windows: C:\Users\{username}\.cache\huggingface\transformers\
    • Linux/Mac: ~/.cache/huggingface/transformers/
  3. Place it in the same location on your offline machine.

Option 3: Force Offline Mode

If you believe the model is already cached, you can force offline mode by setting environment variables:

set TRANSFORMERS_OFFLINE=1
set HF_HUB_OFFLINE=1
python backend_api.py

Option 4: Network Troubleshooting

If you should have internet access:

  1. Check your internet connection
  2. If behind a corporate firewall, ensure huggingface.co is accessible
  3. Try accessing https://huggingface.co in your browser
  4. Contact your IT department if needed

Verification

After setting up offline mode, you can verify the model is working by running:

python download_model.py

This will check if the model is cached and available for offline use.

Technical Details

The sentence transformer model "all-MiniLM-L6-v2" is approximately 80MB and is used for generating embeddings from text for the vector search functionality.

The application has been modified to:

  1. Try loading the model normally first
  2. Fall back to offline mode if network fails
  3. Provide clear error messages with solutions