Skip to content

Commit

Permalink
chore: autopublish 2024-04-07T17:03:29Z
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 7, 2024
1 parent 6ff67a0 commit 3d68e0c
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions notebooks/RAG_LLM_experiments.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,19 @@
" total_cost = self.embedder.generate_embeddings()\n",
" self.embedder.create_faiss_index()\n",
" return total_cost\n",
" \n",
"\n",
" def find_similar_documents(self, query_text, num_results):\n",
" similar_docs = self.embedder.search_similar_sections(query_text, num_results)\n",
" return similar_docs\n",
"\n",
" def determine_expertise_and_prepare_prompt(\n",
" self, user_query, similar_docs, inference_model, max_completion_tokens, temperature):\n",
" self,\n",
" user_query,\n",
" similar_docs,\n",
" inference_model,\n",
" max_completion_tokens,\n",
" temperature,\n",
" ):\n",
" self.model_inference_manager.set_model(inference_model)\n",
" identified_expertise_area, expertise_area_usage = (\n",
" self.model_inference_manager.determine_expertise_area(\n",
Expand All @@ -321,7 +327,9 @@
" # Calculate the cost for determining expertise area\n",
" expertise_area_cost = 0 # Default to 0\n",
" if expertise_area_usage:\n",
" expertise_area_cost = self.model_inference_manager.calculate_cost(expertise_area_usage)\n",
" expertise_area_cost = self.model_inference_manager.calculate_cost(\n",
" expertise_area_usage\n",
" )\n",
" context_enhanced_prompt = self.model_inference_manager.prepare_prompt_for_llm(\n",
" identified_expertise_area, user_query, similar_docs\n",
" )\n",
Expand All @@ -334,7 +342,7 @@
" context_enhanced_prompt, max_completion_tokens, temperature\n",
" )\n",
" # Calculate the cost for querying the model\n",
" response_cost = 0 # Default to 0 \n",
" response_cost = 0 # Default to 0\n",
" if response_usage:\n",
" response_cost = self.model_inference_manager.calculate_cost(response_usage)\n",
"\n",
Expand Down Expand Up @@ -492,12 +500,14 @@
")\n",
"\n",
"# Step 3: Determine expertise area and prepare the prompt\n",
"context_enhanced_prompt, expertise_area_cost = query_pipeline.determine_expertise_and_prepare_prompt(\n",
" user_query=query_text,\n",
" similar_docs=similar_docs,\n",
" inference_model=\"gpt-3.5-turbo-0125\",\n",
" max_completion_tokens=150,\n",
" temperature=0.2,\n",
"context_enhanced_prompt, expertise_area_cost = (\n",
" query_pipeline.determine_expertise_and_prepare_prompt(\n",
" user_query=query_text,\n",
" similar_docs=similar_docs,\n",
" inference_model=\"gpt-3.5-turbo-0125\",\n",
" max_completion_tokens=150,\n",
" temperature=0.2,\n",
" )\n",
")\n",
"print(f\"Cost for determining expertise area: ${expertise_area_cost}\")\n",
"\n",
Expand Down Expand Up @@ -581,12 +591,14 @@
")\n",
"\n",
"# Step 3: Determine expertise area and prepare the prompt\n",
"context_enhanced_prompt, expertise_area_cost = query_pipeline.determine_expertise_and_prepare_prompt(\n",
" user_query=query_text,\n",
" similar_docs=similar_docs,\n",
" inference_model=\"gpt-3.5-turbo-0125\",\n",
" max_completion_tokens=150,\n",
" temperature=0.2,\n",
"context_enhanced_prompt, expertise_area_cost = (\n",
" query_pipeline.determine_expertise_and_prepare_prompt(\n",
" user_query=query_text,\n",
" similar_docs=similar_docs,\n",
" inference_model=\"gpt-3.5-turbo-0125\",\n",
" max_completion_tokens=150,\n",
" temperature=0.2,\n",
" )\n",
")\n",
"print(f\"Cost for determining expertise area: ${expertise_area_cost}\")\n",
"\n",
Expand Down

0 comments on commit 3d68e0c

Please sign in to comment.