Ankitajadhav commited on
Commit
f7c4af0
·
verified ·
1 Parent(s): a623cc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -1,4 +1,6 @@
1
  # import packages
 
 
2
  __import__('pysqlite3')
3
  import sys
4
  sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
@@ -8,6 +10,14 @@ from datasets import load_dataset
8
  from transformers import AutoModelForCausalLM, AutoTokenizer
9
  import gradio as gr
10
 
 
 
 
 
 
 
 
 
11
 
12
 
13
  # Embedding vector
 
1
  # import packages
2
+ import shutil
3
+ import os
4
  __import__('pysqlite3')
5
  import sys
6
  sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
 
10
  from transformers import AutoModelForCausalLM, AutoTokenizer
11
  import gradio as gr
12
 
13
+ # Function to clear the cache
14
+ def clear_cache(model_name):
15
+ cache_dir = os.path.expanduser(f'~/.cache/torch/sentence_transformers/{model_name.replace("/", "_")}')
16
+ if os.path.exists(cache_dir):
17
+ shutil.rmtree(cache_dir)
18
+ print(f"Cleared cache directory: {cache_dir}")
19
+ else:
20
+ print(f"No cache directory found for: {cache_dir}")
21
 
22
 
23
  # Embedding vector