Pengfa Li
commited on
Update Gradio_en.py
Browse files- Gradio_en.py +2 -6
Gradio_en.py
CHANGED
|
@@ -11,7 +11,6 @@ from collections import defaultdict
|
|
| 11 |
from LLM import zero_shot
|
| 12 |
from prompt_generate import generate_prompt_with_examples as generate_prompt
|
| 13 |
|
| 14 |
-
# Global KNN retriever instance
|
| 15 |
_knn_retriever = None
|
| 16 |
|
| 17 |
class EntityLevelRetriever:
|
|
@@ -51,8 +50,7 @@ class EntityLevelRetriever:
|
|
| 51 |
def build_index(self, train_path):
|
| 52 |
with open(train_path, 'r', encoding='utf-8') as f:
|
| 53 |
dataset = json.load(f)
|
| 54 |
-
|
| 55 |
-
# Use data from index 500-999 (501-1000 in 1-based indexing)
|
| 56 |
self.train_data = dataset[500:1000]
|
| 57 |
|
| 58 |
for item in self.train_data:
|
|
@@ -77,8 +75,6 @@ class EntityLevelRetriever:
|
|
| 77 |
if not self.train_data:
|
| 78 |
return []
|
| 79 |
|
| 80 |
-
# Extract entities from query text (simplified approach)
|
| 81 |
-
# For better results, you might want to use NER or other entity extraction methods
|
| 82 |
query_entities = self._extract_potential_entities(query_text)
|
| 83 |
|
| 84 |
context_scores = defaultdict(float)
|
|
@@ -661,7 +657,7 @@ def create_interface():
|
|
| 661 |
|
| 662 |
# QA event handling
|
| 663 |
def submit_qa_request(series, name, q_type, template, prompt, geo_text, question):
|
| 664 |
-
|
| 665 |
return call_qa_model(series, name, prompt, geo_text, question, q_type)
|
| 666 |
|
| 667 |
def update_qa_prompt_on_type_change(qa_type_value):
|
|
|
|
| 11 |
from LLM import zero_shot
|
| 12 |
from prompt_generate import generate_prompt_with_examples as generate_prompt
|
| 13 |
|
|
|
|
| 14 |
_knn_retriever = None
|
| 15 |
|
| 16 |
class EntityLevelRetriever:
|
|
|
|
| 50 |
def build_index(self, train_path):
|
| 51 |
with open(train_path, 'r', encoding='utf-8') as f:
|
| 52 |
dataset = json.load(f)
|
| 53 |
+
|
|
|
|
| 54 |
self.train_data = dataset[500:1000]
|
| 55 |
|
| 56 |
for item in self.train_data:
|
|
|
|
| 75 |
if not self.train_data:
|
| 76 |
return []
|
| 77 |
|
|
|
|
|
|
|
| 78 |
query_entities = self._extract_potential_entities(query_text)
|
| 79 |
|
| 80 |
context_scores = defaultdict(float)
|
|
|
|
| 657 |
|
| 658 |
# QA event handling
|
| 659 |
def submit_qa_request(series, name, q_type, template, prompt, geo_text, question):
|
| 660 |
+
|
| 661 |
return call_qa_model(series, name, prompt, geo_text, question, q_type)
|
| 662 |
|
| 663 |
def update_qa_prompt_on_type_change(qa_type_value):
|