Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -612,7 +612,7 @@ def _decode_generated(out_ids, in_len: int) -> str:
|
|
| 612 |
gen = out_ids[0][in_len:]
|
| 613 |
return tokenizer_lm.decode(gen, skip_special_tokens=True).lstrip(". \n").strip()
|
| 614 |
|
| 615 |
-
|
| 616 |
def direct_llm_fallback(question: str) -> str:
|
| 617 |
sys_prompt = (
|
| 618 |
"You are Askstein (orthopedic biomechanics). If you lack enough domain context, say you don’t know. "
|
|
@@ -625,6 +625,7 @@ def direct_llm_fallback(question: str) -> str:
|
|
| 625 |
return _post_clean(_decode_generated(out, in_len))
|
| 626 |
|
| 627 |
|
|
|
|
| 628 |
def _synthesize_answer(chunks: List[Dict[str, Any]], question: str) -> str:
|
| 629 |
prompt = build_prompt(chunks, question)
|
| 630 |
inputs = tokenizer_lm(prompt, return_tensors="pt").to(device)
|
|
|
|
| 612 |
gen = out_ids[0][in_len:]
|
| 613 |
return tokenizer_lm.decode(gen, skip_special_tokens=True).lstrip(". \n").strip()
|
| 614 |
|
| 615 |
+
@lru_cache(maxsize=None)
|
| 616 |
def direct_llm_fallback(question: str) -> str:
|
| 617 |
sys_prompt = (
|
| 618 |
"You are Askstein (orthopedic biomechanics). If you lack enough domain context, say you don’t know. "
|
|
|
|
| 625 |
return _post_clean(_decode_generated(out, in_len))
|
| 626 |
|
| 627 |
|
| 628 |
+
|
| 629 |
def _synthesize_answer(chunks: List[Dict[str, Any]], question: str) -> str:
|
| 630 |
prompt = build_prompt(chunks, question)
|
| 631 |
inputs = tokenizer_lm(prompt, return_tensors="pt").to(device)
|