Merge pull request #200 from Hawksight-AI/docs

Update earnings call analysis notebook with relation extraction fixes
This commit is contained in:
Mohd Kaif
2026-01-16 03:05:07 +05:30
committed by GitHub
@@ -385,22 +385,49 @@
" \"FOR_PERIOD\",\n",
" \"RELATED_TO\",\n",
" ],\n",
" provider=\"groq\",\n",
" llm_model=\"llama-3.1-8b-instant\",\n",
" api_key=GROQ_API_KEY,\n",
" temperature=0.0,\n",
" verbose=False,\n",
")\n",
"\n",
"relationships = [\n",
" r\n",
" for c in chunks\n",
" for r in relation_extractor.extract_relations(\n",
" text=get_chunk_text(c),\n",
" entities=all_entities,\n",
" provider=\"groq\",\n",
" llm_model=\"llama-3.1-8b-instant\",\n",
" temperature=0.0,\n",
"# Process ALL chunks with ALL entities\n",
"relationships = []\n",
"total_chunks = len(chunks)\n",
"\n",
"print(f\"Processing {total_chunks} chunks with {len(all_entities)} entities each...\")\n",
"print(\"This may take a while. Starting now...\\n\")\n",
"\n",
"for i, c in enumerate(chunks):\n",
" text = get_chunk_text(c).strip()\n",
" if not text:\n",
" print(f\"Chunk {i+1}/{total_chunks}: Skipped (empty)\")\n",
" continue\n",
" \n",
" # Use ALL entities for each chunk\n",
" chunk_entities = all_entities\n",
" \n",
" # Show progress with remaining count\n",
" remaining = total_chunks - (i + 1)\n",
" print(f\"Chunk {i+1}/{total_chunks} ({remaining} remaining) - Processing {len(chunk_entities)} entities...\")\n",
" \n",
" rels = relation_extractor.extract_relations(\n",
" text=text,\n",
" entities=chunk_entities,\n",
" verbose=True, # Enable verbose to see logs\n",
" )\n",
" if get_chunk_text(c).strip()\n",
"]\n",
"print(\"Relationships:\", len(relationships))\n"
" \n",
" relationships.extend(rels)\n",
" print(f\"Chunk {i+1}: Found {len(rels)} relations\")\n",
"\n",
"print(f\"\\nComplete! Total relationships from all {total_chunks} chunks: {len(relationships)}\")\n",
"\n",
"# Show sample relations\n",
"if relationships:\n",
" print(\"\\nSample relationships:\")\n",
" for r in relationships[:15]:\n",
" print(f\"- {r.subject.text} → {r.predicate} → {r.object.text}\")"
]
},
{