Spaces:
Sleeping
Sleeping
File size: 3,438 Bytes
93c98b5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# DynamicCache Error Fix - Quick Summary
## Problem
```
ERROR: Local model error: 'DynamicCache' object has no attribute 'seen_tokens'
```
**Result**: Quality Score 0.00 for all transcripts, no analysis extracted.
---
## Root Cause
Version incompatibility in transformers library's caching mechanism during model generation.
---
## β
Fixes Applied
### 1. Code Fix (llm.py)
Added `use_cache=False` parameter to disable problematic caching:
```python
outputs = query_llm_local.model.generate(
**inputs,
max_new_tokens=max_tokens,
temperature=temperature,
do_sample=temperature > 0,
pad_token_id=query_llm_local.tokenizer.eos_token_id,
use_cache=False # β Fixes DynamicCache error
)
```
**Trade-off**: ~10-20% slower generation, but error-free.
### 2. Enhanced Error Handling
- Better error messages with specific guidance
- Automatic detection of DynamicCache issues
- Recommendations for next steps
### 3. Diagnostic Tool
Created `fix_local_model.py` to diagnose and resolve issues automatically.
---
## π Recommended Actions (Pick One)
### Option A: Upgrade Transformers (Quick Fix)
```bash
pip install --upgrade transformers
python -c "import transformers; print(transformers.__version__)"
```
**Expected**: Version 4.36.0 or higher
### Option B: Use HuggingFace API (Easiest)
```bash
# Get token from: https://huggingface.co/settings/tokens
export HUGGINGFACE_TOKEN='hf_your_token_here'
export USE_HF_API=True
```
### Option C: Use LMStudio (Best for Offline)
1. Download: https://lmstudio.ai/
2. Install and start server
3. Set environment:
```bash
export USE_LMSTUDIO=True
export LMSTUDIO_URL=http://localhost:1234
```
### Option D: Run Diagnostic
```bash
python fix_local_model.py
```
Automatically detects and guides you through fixes.
---
## Verification
After applying any fix, test:
```bash
python -c "from llm import query_llm_local; print(query_llm_local('Test', max_tokens=10))"
```
**Success**: Returns text (not error message)
**Still failing**: Try Option B or C above
---
## Files Modified/Created
β
**Modified**:
- `llm.py` - Added use_cache=False and better error handling
- `requirements.txt` - Added version compatibility notes
β
**Created**:
- `fix_local_model.py` - Diagnostic and fix script
- `TROUBLESHOOTING_DYNAMIC_CACHE.md` - Comprehensive guide (13KB)
- `DYNAMIC_CACHE_FIX_SUMMARY.md` - This quick reference
---
## Next Steps
1. **Choose a solution** (A, B, C, or D above)
2. **Apply the fix**
3. **Restart your application**
4. **Process a test transcript**
5. **Verify Quality Score > 0.00**
If issues persist, see `TROUBLESHOOTING_DYNAMIC_CACHE.md` for detailed guidance.
---
## Quick Reference
| Issue | Fix |
|-------|-----|
| Quality Score 0.00 | LLM is failing - apply fixes above |
| DynamicCache error | use_cache=False (already applied) + upgrade transformers |
| Slow processing | Use HF API (Option B) for speed |
| Offline required | Use LMStudio (Option C) |
| Not sure what to do | Run diagnostic (Option D) |
---
## Support
- **Full troubleshooting**: See `TROUBLESHOOTING_DYNAMIC_CACHE.md`
- **Run diagnostic**: `python fix_local_model.py`
- **Check enhancements**: See `ENHANCEMENTS.md`
β
**The code fix is already applied - you just need to upgrade dependencies or switch backends!**
|