midrees2806 commited on
Commit
401c493
·
verified ·
1 Parent(s): 5991464

Update rag.py

Browse files
Files changed (1) hide show
  1. rag.py +3 -3
rag.py CHANGED
@@ -31,15 +31,15 @@ GREETINGS = [
31
  try:
32
  with open('dataset.json', 'r') as f:
33
  dataset = json.load(f)
34
- if not all(isinstance(item, dict) and 'Question' in item and 'Answer' in item for item in dataset):
35
  raise ValueError("Invalid dataset structure")
36
  except Exception as e:
37
  print(f"Error loading dataset: {e}")
38
  dataset = []
39
 
40
  # Precompute embeddings
41
- dataset_questions = [item.get("Question", "").lower().strip() for item in dataset]
42
- dataset_answers = [item.get("Answer", "") for item in dataset]
43
  dataset_embeddings = similarity_model.encode(dataset_questions, convert_to_tensor=True)
44
 
45
  # Save unmatched queries to Hugging Face
 
31
  try:
32
  with open('dataset.json', 'r') as f:
33
  dataset = json.load(f)
34
+ if not all(isinstance(item, dict) and 'input' in item and 'response' in item for item in dataset):
35
  raise ValueError("Invalid dataset structure")
36
  except Exception as e:
37
  print(f"Error loading dataset: {e}")
38
  dataset = []
39
 
40
  # Precompute embeddings
41
+ dataset_questions = [item.get("input", "").lower().strip() for item in dataset]
42
+ dataset_answers = [item.get("response", "") for item in dataset]
43
  dataset_embeddings = similarity_model.encode(dataset_questions, convert_to_tensor=True)
44
 
45
  # Save unmatched queries to Hugging Face