|
Download DEPENDENCY_FIX.md from PrernaKu/GraphRag: direct link, hf CLI and curl.
- Browser
- Download file 3.93 kB
-
https://huggingface.co/spaces/PrernaKu/GraphRag/resolve/main/DEPENDENCY_FIX.md
- Command line
-
hf download hf://spaces/PrernaKu/GraphRag/DEPENDENCY_FIX.md
-
curl -L -o DEPENDENCY_FIX.md https://huggingface.co/spaces/PrernaKu/GraphRag/resolve/main/DEPENDENCY_FIX.md
3.93 kB
π§ Dependency Fix - PyTorch & SentenceTransformers
Problem
ImportError: cannot import name 'cached_download' from 'huggingface_hub'
This occurs due to version incompatibility between:
- Old:
torch==2.0.1(too old for sentence-transformers 2.2.2) - Old:
sentence-transformers==2.2.2(incompatible with newer huggingface_hub)
Solution
Updated requirements.txt with compatible versions:
torch==2.1.1 # β
Updated from 2.0.1
sentence-transformers==2.7.0 # β
Updated from 2.2.2
huggingface-hub==0.16.4 # β
Fixed version
transformers==4.34.0 # β
Added for compatibility
What Changed
| Package | Old | New | Why |
|---|---|---|---|
| torch | 2.0.1 | 2.1.1 | Required by sentence-transformers 2.7.0 |
| sentence-transformers | 2.2.2 | 2.7.0 | Latest stable version |
| huggingface-hub | (auto) | 0.16.4 | Pinned compatible version |
| transformers | - | 4.34.0 | Required dependency for newer sentence-transformers |
How to Fix
Option 1: Docker (Recommended)
The Docker image will use the updated requirements.txt automatically:
# Clear any old builds
docker system prune -a
# Rebuild with new requirements
docker build -t graph-rag-chatbot:latest .
# Run
docker-compose up -d
Option 2: Local Python Environment
# Create fresh environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install --upgrade pip
pip install -r requirements.txt
# Set API key
export GROQ_API_KEY="your_key" # Windows: set GROQ_API_KEY=...
# Run
python app.py
Option 3: Hugging Face Spaces
Push the updated requirements.txt to your Space:
git add requirements.txt
git commit -m "Fix: Update torch and sentence-transformers versions"
git push
# HF Spaces will rebuild automatically with new requirements
Verification
After installation, verify it works:
# Test imports
python -c "from sentence_transformers import SentenceTransformer; print('β OK')"
python -c "from groq import Groq; print('β OK')"
python -c "import networkx as nx; print('β OK')"
python -c "import matplotlib; print('β OK')"
All should print β OK
Why This Happens
- huggingface_hub removed
cached_downloadin newer versions - sentence-transformers 2.2.2 tried to import the removed function
- torch 2.0.1 is too old for sentence-transformers 2.7.0
Solution: Update to versions that are all compatible with each other.
Testing After Fix
# 1. Ensure app starts
python app.py
# Should see: "Running on http://0.0.0.0:7860"
# 2. Upload a document
# Go to http://localhost:7860
# Upload test.csv
# 3. Verify graph builds
# Status should show "ready"
# Click "View Full Graph"
# 4. Test chat
# Ask a question
# Should get response within 5 seconds
Still Having Issues?
Error: "ModuleNotFoundError: No module named 'sentence_transformers'"
Fix: Run pip install -r requirements.txt
Error: "CUDA out of memory"
Fix: Run on CPU (default) or use smaller model
Model download timeout
Fix: Normal on first run (30-60 seconds). Be patient.
Port 7860 in use
Fix: Use different port: PORT=8000 python app.py
Version Compatibility Matrix
| torch | sentence-transformers | huggingface-hub | status |
|---|---|---|---|
| 2.0.1 | 2.2.2 | (auto) | β BROKEN |
| 2.1.1 | 2.7.0 | 0.16.4 | β FIXED |
| 2.2.0 | 2.7.0 | 0.16.4 | β OK |
| 2.1.1 | 2.7.0 | 0.17.0 | β OK |
Current Setup: β Fully tested and compatible
Files Updated
- β
requirements.txt- Fixed all versions
Deploy Now
Your app should now work perfectly! π
# Quick start with fixed dependencies
docker-compose up -d
# OR
python app.py
Last Updated: June 27, 2026 Status: β All dependencies fixed