|
258 | 258 | ], |
259 | 259 | "source": [ |
260 | 260 | "# Cell 1\n", |
261 | | - "!pip install --upgrade huggingface_hub sentence-transformers codecarbon pypdf torch scikit-learn pandas\n" |
| 261 | + "!pip install --upgrade huggingface_hub sentence-transformers codecarbon pypdf torch scikit-learn pandas" |
262 | 262 | ] |
263 | 263 | }, |
264 | 264 | { |
|
295 | 295 | "import time\n", |
296 | 296 | "import textwrap\n", |
297 | 297 | "import glob\n", |
298 | | - "import pandas as pd\n", |
299 | 298 | "import numpy as np\n", |
300 | 299 | "from huggingface_hub import InferenceClient\n", |
301 | 300 | "from sentence_transformers import SentenceTransformer\n", |
|
322 | 321 | "print(\"Data folder:\", DATA_PATH)\n", |
323 | 322 | "print(\"Answer log file:\", LOG_FILE)\n", |
324 | 323 | "print(\"Emissions log file:\", EMISSIONS_FILE)\n", |
325 | | - "print(\"API key loaded?\", (HF_API_KEY[:10] + \"...\") if HF_API_KEY else \"MISSING\")\n" |
| 324 | + "print(\"API key loaded?\", (HF_API_KEY[:10] + \"...\") if HF_API_KEY else \"MISSING\")" |
326 | 325 | ] |
327 | 326 | }, |
328 | 327 | { |
|
369 | 368 | ")\n", |
370 | 369 | "REFINER_USER_TEMPLATE = \"Original Draft:\\n{draft}\\n\\nCritic's Feedback:\\n{feedback}\"\n", |
371 | 370 | "\n", |
372 | | - "print(\"Prompts ready to use.\")\n" |
| 371 | + "print(\"Prompts ready to use.\")" |
373 | 372 | ] |
374 | 373 | }, |
375 | 374 | { |
|
424 | 423 | "source": [ |
425 | 424 | "# Cell 4\n", |
426 | 425 | "\n", |
| 426 | + "\n", |
427 | 427 | "class Node:\n", |
428 | 428 | " def __init__(self, content, doc_id, chunk_id, fname=None):\n", |
429 | 429 | " self._content = content\n", |
|
494 | 494 | " sims = embeddings_norm @ q_emb\n", |
495 | 495 | " topk_idx = np.argsort(-sims)[:k]\n", |
496 | 496 | " return [nodes[i] for i in topk_idx]\n", |
| 497 | + "\n", |
| 498 | + "\n", |
497 | 499 | "print(\"Retriever function ready to use.\")" |
498 | 500 | ] |
499 | 501 | }, |
|
573 | 575 | "print(\"\\nRunning a tiny API test...\")\n", |
574 | 576 | "test_prompt = \"Who was the first person on the Moon?\"\n", |
575 | 577 | "resp = call_hf_api(\"You are a helpful assistant.\", test_prompt, max_tokens=60)\n", |
576 | | - "print(\"\\n--- Test response ---\\n\", resp)\n" |
| 578 | + "print(\"\\n--- Test response ---\\n\", resp)" |
577 | 579 | ] |
578 | 580 | }, |
579 | 581 | { |
|
2060 | 2062 | " total_emissions = tracker.stop()\n", |
2061 | 2063 | " print(\"\\n Total Emissions Summary:\")\n", |
2062 | 2064 | " print(f\"{total_emissions * 1000:.6f} gCO2eq\")\n", |
2063 | | - " print(\"Notebook finished.\")\n" |
| 2065 | + " print(\"Notebook finished.\")" |
2064 | 2066 | ] |
2065 | 2067 | } |
2066 | 2068 | ], |
|
0 commit comments