Caleb Fahlgren commited on
Commit
7247642
·
1 Parent(s): 20998cb

move duckdb out of gpu function, add prompt lookup decoding

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from gradio_huggingfacehub_search import HuggingfaceHubSearch
 
2
  from huggingface_hub import HfApi
3
  import matplotlib.pyplot as plt
4
  from typing import Tuple, Optional
@@ -72,11 +73,13 @@ CREATE TABLE {} (
72
 
73
 
74
  @spaces.GPU(duration=120)
75
- def generate_query(dataset_id: str, query: str) -> dict:
76
  llama = llama_cpp.Llama(
77
  model_path="Hermes-2-Pro-Llama-3-8B-Q8_0.gguf",
78
  n_gpu_layers=50,
79
  chat_format="chatml",
 
 
80
  n_ctx=2048,
81
  verbose=True,
82
  temperature=0.1,
@@ -87,8 +90,6 @@ def generate_query(dataset_id: str, query: str) -> dict:
87
  mode=instructor.Mode.JSON_SCHEMA,
88
  )
89
 
90
- ddl = get_dataset_ddl(dataset_id)
91
-
92
  system_prompt = f"""
93
  You are an expert SQL assistant with access to the following PostgreSQL Table:
94
 
@@ -122,7 +123,8 @@ def generate_query(dataset_id: str, query: str) -> dict:
122
 
123
 
124
  def query_dataset(dataset_id: str, query: str) -> Tuple[pd.DataFrame, str, plt.Figure]:
125
- response = generate_query(dataset_id, query)
 
126
 
127
  print("Querying Parquet...")
128
  df = conn.execute(response.get("sql")).fetchdf()
 
1
  from gradio_huggingfacehub_search import HuggingfaceHubSearch
2
+ from llama_cpp.llama_speculative import LlamaPromptLookupDecoding
3
  from huggingface_hub import HfApi
4
  import matplotlib.pyplot as plt
5
  from typing import Tuple, Optional
 
73
 
74
 
75
  @spaces.GPU(duration=120)
76
+ def generate_query(ddl: str, query: str) -> dict:
77
  llama = llama_cpp.Llama(
78
  model_path="Hermes-2-Pro-Llama-3-8B-Q8_0.gguf",
79
  n_gpu_layers=50,
80
  chat_format="chatml",
81
+ draft_model=LlamaPromptLookupDecoding(num_pred_tokens=2),
82
+ logits_all=True,
83
  n_ctx=2048,
84
  verbose=True,
85
  temperature=0.1,
 
90
  mode=instructor.Mode.JSON_SCHEMA,
91
  )
92
 
 
 
93
  system_prompt = f"""
94
  You are an expert SQL assistant with access to the following PostgreSQL Table:
95
 
 
123
 
124
 
125
  def query_dataset(dataset_id: str, query: str) -> Tuple[pd.DataFrame, str, plt.Figure]:
126
+ ddl = get_dataset_ddl(dataset_id)
127
+ response = generate_query(ddl, query)
128
 
129
  print("Querying Parquet...")
130
  df = conn.execute(response.get("sql")).fetchdf()