giulio98 commited on
Commit
08824d8
·
1 Parent(s): 2212763

fix global variable

Browse files
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -445,6 +445,7 @@ def run_naive_rag_query(query, rag_token_size, prefix, task, few_shot_examples):
445
  For naive RAG, retrieves top-k chunks (k based on target token size)
446
  and generates an answer using those chunks.
447
  """
 
448
  k = max(1, rag_token_size // 256)
449
  retriever = global_rag_index.as_retriever(search_type="similarity", search_kwargs={"k": k})
450
  retrieved_docs = retriever.invoke(query)
@@ -464,6 +465,7 @@ def prepare_compression_and_rag(combined_text, retrieval_slider_value, global_lo
464
  """
465
  Prepares the compressed KV cache. Uses the precomputed rag_index from state.
466
  """
 
467
  percentage = int(global_local_value.replace('%', ''))
468
  question_text = task_description + "\n" + few_shot
469
  context_encoding = tokenizer(combined_text, return_tensors="pt").to(device)
 
445
  For naive RAG, retrieves top-k chunks (k based on target token size)
446
  and generates an answer using those chunks.
447
  """
448
+ global global_rag_index
449
  k = max(1, rag_token_size // 256)
450
  retriever = global_rag_index.as_retriever(search_type="similarity", search_kwargs={"k": k})
451
  retrieved_docs = retriever.invoke(query)
 
465
  """
466
  Prepares the compressed KV cache. Uses the precomputed rag_index from state.
467
  """
468
+ global global_rag_index
469
  percentage = int(global_local_value.replace('%', ''))
470
  question_text = task_description + "\n" + few_shot
471
  context_encoding = tokenizer(combined_text, return_tensors="pt").to(device)