From 2ab50860579ad31c514e59b546515757d772d75d Mon Sep 17 00:00:00 2001 From: taguesokoudjou Date: Tue, 1 Sep 2026 04:58:37 +0200 Subject: [PATCH 1/2] Optimize author patent search performance --- .../benchmark_author_patent_performance.py | 465 ++++++ .../performance/PERFORMANCE_ANALYSIS.md | 205 +++ .../performance/benchmark_after.json | 1387 +++++++++++++++++ .../performance/benchmark_before.json | 1387 +++++++++++++++++ .../performance/performance_summary.csv | 17 + .../performance/performance_summary_after.csv | 9 + .../performance_summary_before.csv | 9 + .../performance/query_counts.csv | 17 + .../performance/query_counts_after.csv | 9 + .../performance/query_counts_before.csv | 9 + .../performance/regression_comparison.json | 262 ++++ .../ambiguous_author_identity_guard_v2.py | 38 +- .../final_ambiguous_author_identity_guard.py | 72 +- .../src/main/inse/patents/authors/logic.py | 400 +++-- .../inse/patents/authors/pipeline_perf.py | 71 + .../inse/patents/authors/search_queries.py | 30 +- .../authors/semantic_topic_fallback.py | 11 +- ...t_final_ambiguous_author_identity_guard.py | 80 + .../authors/test_semantic_topic_fallback.py | 33 + .../src/main/inse/patents/common/parsing.py | 62 +- .../patents/test_elastic_search_client.py | 11 + service/src/main/inse/patents/test_logic.py | 61 + 22 files changed, 4467 insertions(+), 178 deletions(-) create mode 100644 service/scripts/patents/benchmark_author_patent_performance.py create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/PERFORMANCE_ANALYSIS.md create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/benchmark_after.json create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/benchmark_before.json create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/performance_summary.csv create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/performance_summary_after.csv create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/performance_summary_before.csv create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/query_counts.csv create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/query_counts_after.csv create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/query_counts_before.csv create mode 100644 service/scripts/patents/data/author_patent_evaluation/performance/regression_comparison.json create mode 100644 service/src/main/inse/patents/authors/pipeline_perf.py diff --git a/service/scripts/patents/benchmark_author_patent_performance.py b/service/scripts/patents/benchmark_author_patent_performance.py new file mode 100644 index 00000000..68d3da0f --- /dev/null +++ b/service/scripts/patents/benchmark_author_patent_performance.py @@ -0,0 +1,465 @@ +#!/usr/bin/env python3 +"""Live runtime benchmark for the frozen Author→Patent pipeline. + +Measures stage timings and query counts. Does not change decision logic. +Does not write gold or FINAL evaluation artifacts. + + python scripts/patents/benchmark_author_patent_performance.py --phase before + python scripts/patents/benchmark_author_patent_performance.py --phase after +""" +from __future__ import annotations + +import argparse +import asyncio +import csv +import json +import statistics +import sys +import time +from pathlib import Path +from typing import Any + +from dotenv import load_dotenv + +SCRIPT_DIR = Path(__file__).resolve().parent +SERVICE_SRC = SCRIPT_DIR.parent.parent / "src" / "main" +load_dotenv(SERVICE_SRC / "inse" / ".env") +sys.path.insert(0, str(SERVICE_SRC)) + +from inse.patents.authors.final_ambiguous_author_identity_guard import ( # noqa: E402 + get_identity_guard_query_stats, + reset_identity_guard_query_stats, +) +from inse.patents.authors.logic import get_patents_by_author_id # noqa: E402 +from inse.patents.authors.pipeline_perf import ( # noqa: E402 + capture_pipeline_perf, + current_perf, +) +from inse.patents.common.parsing import patent_map_key # noqa: E402 + +OUT_DIR = SCRIPT_DIR / "data" / "author_patent_evaluation" / "performance" +RUNS_PER_AUTHOR = 3 + +# Known live cases from the frozen identity-guard evaluation, plus existing +# experiment_1 authors covering unique / few / many-candidate profiles. +BENCHMARK_AUTHORS: tuple[tuple[str, str, str], ...] = ( + ("A5111380960", "Thomas Kaiser A5111380960", "ambiguous_many"), + ("A5071644998", "Thomas Kaiser A5071644998", "ambiguous_few"), + ("A5034365278", "Dirk Schadendorf", "ambiguous"), + ("A5100603203", "Christian Weber", "ambiguous"), + ("A5100373745", "Xiaohong Chen", "ambiguous_many_candidates"), + ("A5023982706", "Richard Smith", "ambiguous_many_candidates"), + ("A5023752156", "Albert Sickmann", "unique_or_few"), + ("A5011059806", "James Fulcher", "few_patents"), +) + +STAGE_KEYS = ( + "author_load", + "patent_search", + "name_matching", + "family_expansion", + "classification_enrichment", + "production_filter", + "semantic_fallback", + "identity_coauthor_loading", + "identity_institution_loading", + "identity_shared_works", + "final_identity_guard", + "response_build", + "total", +) + +QUERY_KEYS = ( + "openalex", + "elasticsearch", + "epo", + "uspto", + "institution_alias", + "coauthor", + "shared_work", + "family", +) + + +def _index_name(index: Any) -> str: + if isinstance(index, (list, tuple)): + return ",".join(str(item) for item in index) + return str(index or "") + + +def _classify_openalex_query(index: Any, body: dict | None, query: dict | None) -> str: + name = _index_name(index).casefold() + payload = str(body or query or "") + if "institution" in name: + return "institution_alias" + if "works" in name: + if "match_phrase" in payload and "authorships.author.display_name" in payload: + return "shared_work" + if "authorships" in payload: + return "coauthor" + return "openalex" + if "author" in name: + return "openalex" + return "elasticsearch" + + +def _classify_patent_index(index: str, payload: dict | None) -> str: + name = (index or "").casefold() + query = str((payload or {}).get("query") or "") + if "epo" in name: + if "application_number" in query: + return "family" + return "epo" + if "uspto" in name: + return "uspto" + if "ipc" in name: + return "elasticsearch" + if "patents_openalex" in name: + return "elasticsearch" + return "elasticsearch" + + +def install_query_hooks() -> None: + from inse.integrations import elasticsearch as es + from inse.patents.common import elastic_search_client as patent_es + from inse.patents.patents_openalex_keywords import client as keywords_client + + orig_search = es.search + orig_count = es.count + orig_get = es.get + orig_patent_search = patent_es.BasePatentSearchClient._search + orig_lookup_ids = keywords_client.PatentsOpenAlexKeywordsClient.lookup_ids + + async def counted_search(*args: Any, **kwargs: Any): + perf = current_perf() + if perf is not None: + index = kwargs.get("index") + if index is None and args: + index = args[0] + kind = _classify_openalex_query( + index, kwargs.get("body"), kwargs.get("query") + ) + perf.add_query(kind) + if kind != "elasticsearch": + perf.add_query("elasticsearch") + if kind in {"coauthor", "shared_work", "institution_alias"}: + perf.add_query("openalex") + return await orig_search(*args, **kwargs) + + async def counted_count(*args: Any, **kwargs: Any): + perf = current_perf() + if perf is not None: + perf.add_query("openalex") + perf.add_query("elasticsearch") + return await orig_count(*args, **kwargs) + + async def counted_get(*args: Any, **kwargs: Any): + perf = current_perf() + if perf is not None: + perf.add_query("openalex") + perf.add_query("elasticsearch") + return await orig_get(*args, **kwargs) + + async def counted_patent_search(self, index: str, payload: dict): + perf = current_perf() + if perf is not None: + kind = _classify_patent_index(index, payload) + perf.add_query(kind) + if kind == "family": + perf.add_query("epo") + if kind not in {"elasticsearch"}: + perf.add_query("elasticsearch") + return await orig_patent_search(self, index, payload) + + async def counted_lookup_ids(self, doc_ids: list[str]): + perf = current_perf() + if perf is not None: + unique_n = len(list(dict.fromkeys(doc_ids))) + batches = (unique_n + 999) // 1000 if unique_n else 0 + perf.add_query("elasticsearch", max(batches, 1) if unique_n else 0) + return await orig_lookup_ids(self, doc_ids) + + es.search = counted_search + es.count = counted_count + es.get = counted_get + patent_es.BasePatentSearchClient._search = counted_patent_search + keywords_client.PatentsOpenAlexKeywordsClient.lookup_ids = counted_lookup_ids + + +def _snapshot(response) -> dict[str, Any]: + patents = list(response.patents or []) + return { + "author_id": response.author_id, + "author_name": response.author_name, + "patent_count": int(response.patent_count or 0), + "patent_ids": [patent.patent_id for patent in patents], + "patent_map_keys": [patent_map_key(patent) for patent in patents], + } + + +async def run_once(author_id: str) -> dict[str, Any]: + reset_identity_guard_query_stats() + with capture_pipeline_perf() as perf: + response = await get_patents_by_author_id(author_id) + snapshot = _snapshot(response) + snapshot["timings_ms"] = {key: float(perf.timings_ms.get(key, 0.0)) for key in STAGE_KEYS} + snapshot["queries"] = {key: int(perf.queries.get(key, 0)) for key in QUERY_KEYS} + snapshot["identity_query_stats"] = get_identity_guard_query_stats() + snapshot["raw_query_kinds"] = dict(perf.queries) + return snapshot + + +def _median(values: list[float]) -> float: + if not values: + return 0.0 + return float(statistics.median(values)) + + +def _summarize_author(label: str, author_id: str, note: str, runs: list[dict[str, Any]]) -> dict[str, Any]: + totals = [float(run["timings_ms"]["total"]) for run in runs] + query_avgs = { + key: sum(int(run["queries"].get(key, 0)) for run in runs) / len(runs) + for key in QUERY_KEYS + } + stage_medians = { + key: _median([float(run["timings_ms"].get(key, 0.0)) for run in runs]) + for key in STAGE_KEYS + } + first = runs[0] + identical_ids = all(run["patent_ids"] == first["patent_ids"] for run in runs) + return { + "author_id": author_id, + "label": label, + "note": note, + "runs": len(runs), + "total_ms": { + "min": min(totals) if totals else 0.0, + "max": max(totals) if totals else 0.0, + "median": _median(totals), + "values": totals, + }, + "stage_median_ms": stage_medians, + "query_average": query_avgs, + "patent_count": first["patent_count"], + "patent_ids": first["patent_ids"], + "patent_map_keys": first["patent_map_keys"], + "ids_stable_across_runs": identical_ids, + "run_details": [ + { + "timings_ms": run["timings_ms"], + "queries": run["queries"], + "identity_query_stats": run["identity_query_stats"], + "patent_count": run["patent_count"], + } + for run in runs + ], + } + + +async def warmup_semantic_model() -> dict[str, Any]: + started = time.perf_counter() + from inse.util import get_model + + model = get_model() + model.encode( + ["query: warmup semantic topic text"], + batch_size=8, + show_progress_bar=False, + convert_to_numpy=True, + normalize_embeddings=True, + ) + elapsed_ms = (time.perf_counter() - started) * 1000.0 + return {"warmup": True, "elapsed_ms": elapsed_ms, "model": "intfloat/multilingual-e5-base"} + + +async def run_benchmark(phase: str, authors: list[tuple[str, str, str]]) -> dict[str, Any]: + install_query_hooks() + print(f"phase={phase} authors={len(authors)} runs_per_author={RUNS_PER_AUTHOR}", flush=True) + warmup = await warmup_semantic_model() + print(f"warmup_semantic_model_ms={warmup['elapsed_ms']:.1f}", flush=True) + + author_rows = [] + for author_id, label, note in authors: + print(f"\n=== {label} ({author_id}) ===", flush=True) + runs = [] + for index in range(1, RUNS_PER_AUTHOR + 1): + started = time.perf_counter() + try: + result = await run_once(author_id) + except Exception as exc: + elapsed_ms = (time.perf_counter() - started) * 1000.0 + print(f" run {index} FAILED after {elapsed_ms:.0f}ms: {exc}", flush=True) + raise + wall_ms = (time.perf_counter() - started) * 1000.0 + result["timings_ms"]["total"] = float(result["timings_ms"].get("total") or wall_ms) + runs.append(result) + print( + f" run {index}: {result['timings_ms']['total']:.0f}ms " + f"patents={result['patent_count']} " + f"epo={result['queries']['epo']} family={result['queries']['family']} " + f"coauthor={result['queries']['coauthor']} " + f"shared={result['queries']['shared_work']} " + f"alias={result['queries']['institution_alias']}", + flush=True, + ) + row = _summarize_author(label, author_id, note, runs) + author_rows.append(row) + print( + f" median={row['total_ms']['median']:.0f}ms " + f"min={row['total_ms']['min']:.0f} max={row['total_ms']['max']:.0f}", + flush=True, + ) + + payload = { + "phase": phase, + "warmup": warmup, + "runs_per_author": RUNS_PER_AUTHOR, + "authors": author_rows, + } + return payload + + +def _write_json(path: Path, payload: dict[str, Any]) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") + + +def _write_csv(path: Path, rows: list[dict[str, Any]], fieldnames: list[str]) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + with path.open("w", encoding="utf-8", newline="") as handle: + writer = csv.DictWriter(handle, fieldnames=fieldnames) + writer.writeheader() + for row in rows: + writer.writerow(row) + + +def write_phase_artifacts(payload: dict[str, Any]) -> None: + phase = payload["phase"] + OUT_DIR.mkdir(parents=True, exist_ok=True) + _write_json(OUT_DIR / f"benchmark_{phase}.json", payload) + query_rows = [] + summary_rows = [] + for author in payload["authors"]: + query_rows.append( + { + "phase": phase, + "author_id": author["author_id"], + "label": author["label"], + **{f"avg_{key}": f"{author['query_average'].get(key, 0):.2f}" for key in QUERY_KEYS}, + } + ) + summary_rows.append( + { + "phase": phase, + "author_id": author["author_id"], + "label": author["label"], + "median_ms": f"{author['total_ms']['median']:.1f}", + "min_ms": f"{author['total_ms']['min']:.1f}", + "max_ms": f"{author['total_ms']['max']:.1f}", + "patent_count": author["patent_count"], + **{ + f"median_{key}_ms": f"{author['stage_median_ms'].get(key, 0):.1f}" + for key in STAGE_KEYS + if key != "total" + }, + } + ) + _write_csv( + OUT_DIR / f"query_counts_{phase}.csv", + query_rows, + ["phase", "author_id", "label", *[f"avg_{key}" for key in QUERY_KEYS]], + ) + _write_csv( + OUT_DIR / f"performance_summary_{phase}.csv", + summary_rows, + [ + "phase", + "author_id", + "label", + "median_ms", + "min_ms", + "max_ms", + "patent_count", + *[f"median_{key}_ms" for key in STAGE_KEYS if key != "total"], + ], + ) + + +def compare_phases(before: dict[str, Any], after: dict[str, Any]) -> dict[str, Any]: + before_by_id = {row["author_id"]: row for row in before["authors"]} + after_by_id = {row["author_id"]: row for row in after["authors"]} + rows = [] + ids_ok = True + counts_ok = True + for author_id, before_row in before_by_id.items(): + after_row = after_by_id.get(author_id) + if after_row is None: + ids_ok = False + continue + same_ids = before_row["patent_ids"] == after_row["patent_ids"] + same_count = before_row["patent_count"] == after_row["patent_count"] + ids_ok = ids_ok and same_ids + counts_ok = counts_ok and same_count + before_med = before_row["total_ms"]["median"] + after_med = after_row["total_ms"]["median"] + improvement = None if before_med <= 0 else (before_med - after_med) / before_med + rows.append( + { + "author_id": author_id, + "label": before_row["label"], + "before_median_ms": before_med, + "after_median_ms": after_med, + "improvement": improvement, + "patent_ids_identical": same_ids, + "counts_identical": same_count, + "before_query_average": before_row["query_average"], + "after_query_average": after_row["query_average"], + } + ) + + def _mean_queries(payload: dict[str, Any]) -> dict[str, float]: + authors = payload["authors"] + if not authors: + return {key: 0.0 for key in QUERY_KEYS} + return { + key: sum(author["query_average"].get(key, 0.0) for author in authors) / len(authors) + for key in QUERY_KEYS + } + + return { + "patent_ids_identical": ids_ok, + "counts_identical": counts_ok, + "decision_reasons_identical": "not_in_api_response", + "authors": rows, + "average_query_count_before": _mean_queries(before), + "average_query_count_after": _mean_queries(after), + } + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--phase", choices=("before", "after", "compare"), required=True) + parser.add_argument("--limit", type=int, default=0, help="Optional author cap for debugging") + return parser.parse_args() + + +def main() -> int: + args = parse_args() + authors = list(BENCHMARK_AUTHORS) + if args.limit: + authors = authors[: args.limit] + if args.phase == "compare": + before = json.loads((OUT_DIR / "benchmark_before.json").read_text(encoding="utf-8")) + after = json.loads((OUT_DIR / "benchmark_after.json").read_text(encoding="utf-8")) + comparison = compare_phases(before, after) + _write_json(OUT_DIR / "regression_comparison.json", comparison) + print(json.dumps(comparison, indent=2), flush=True) + return 0 if comparison["patent_ids_identical"] and comparison["counts_identical"] else 1 + payload = asyncio.run(run_benchmark(args.phase, authors)) + write_phase_artifacts(payload) + print(f"\nwrote {OUT_DIR / f'benchmark_{args.phase}.json'}", flush=True) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/PERFORMANCE_ANALYSIS.md b/service/scripts/patents/data/author_patent_evaluation/performance/PERFORMANCE_ANALYSIS.md new file mode 100644 index 00000000..978cecf2 --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/PERFORMANCE_ANALYSIS.md @@ -0,0 +1,205 @@ +# Author→Patent pipeline performance + +Status: runtime I/O only. Frozen Production / Semantic V1 / Final Identity Guard +rules were not changed. Gold and FINAL evaluation files were not rewritten. + +Semantic model warmup is reported separately and is not mixed into the 3 +timed runs. + +Live search is adaptive and sometimes `truncated_inconclusive`. Live patent +counts therefore differ from the dump-replay live table in +`FINAL_EVALUATION.md`. Before and after used the same live search. + +## Bottlenecks before + +1. **Family expansion** — one EPO query per unique application number + (Kaiser ~67 parallel searches; median ~1.9–2.1s). +2. **Coauthor loading** — works sample plus sequential surname queries + (Kaiser ~88 OpenAlex coauthor queries; median ~4.3–5.5s). +3. **Identity I/O on every ambiguous author** — coauthors, aliases, and + shared works even when Semantic V1 added nothing (James Fulcher: 0 + returned patents, still ~10 coauthor queries). +4. **Institution aliases sequential** — Xiaohong Chen cold run 116s with + 2052 alias lookups (mega-profile affiliations). Cached runs drop to 0 + extra alias queries. +5. **Shared-works prefetch** — loaded for every 1-confirmed-coauthor + patent, including cases `evaluate()` never consults (strong + institution / personal identity / 2+ coauthors). + +Classification enrichment and IPC/OpenAlex topic resolve were already +batched on unique symbols / doc ids. EPO+USPTO inventor search was +already parallel. `get_model()` was already a process singleton. +`_build_semantic_vectors` already deduped topic texts in one request. + +## Existing caches (unchanged keys) + +| Cache | Key | Scope | Lifetime | Hit | Miss | +| --- | --- | --- | --- | --- | --- | +| `_COAUTHOR_CACHE` | OpenAlex author id | process | process | return stored names when no inventor hints | works sample (+ surname queries if hints) | +| `_ALIAS_CACHE` | institution id | process | process | return `InstitutionAliasRecord` | `get_institution_by_id` | +| `_SHARED_WORKS_CACHE` | `(author_id, normalized coauthor name)` | process | process | return `CoauthorWorkContext` | nested OpenAlex works search | +| `get_model()` | singleton | process | process | reuse SentenceTransformer | load `intfloat/multilingual-e5-base` | +| `load_ipc_openalex_mapping` | `lru_cache(maxsize=1)` | process | process | return mapping | load JSON | +| `load_patents_openalex_keywords_json` | `lru_cache(maxsize=1)` | process | process | return JSON | load file | +| resolver `_doc_cache` | IPC/CPC symbol | request (resolver instance) | request | skip ES | batched `lookup_ids` | + +No new global invalidation layer. Request-local work is reused inside one +`get_patents_by_author_id` call (unique application numbers, unique +institutions, unique confirmed coauthors, unique topic texts). + +## Implemented optimizations + +### 1. Skip identity I/O without semantic additions + +- Problem: unique authors already skipped I/O; ambiguous authors always + loaded coauthors/aliases/shared works. +- Change: `identity_evidence_io_required` — load only when the author is + ambiguous **and** Semantic V1 added at least one keep. +- Why identical: Production KEEP is never dropped. Unique authors keep + every combined keep. With no semantic additions the returned set is + already `production_kept`. + +### 2. Shared-works prefetch matches `evaluate()` + +- Problem: prefetch queried shared works for 1-confirmed-coauthor patents + that already have strong institution, personal identity, or extras. +- Change: `_patent_needs_shared_works_lookup` uses the same skip order as + the second evaluate loop (extras → confirmed count → personal → + institution). Remaining lookups run with `asyncio.gather`. +- Why identical: `evaluate()` never reads those skipped contexts. + Family anchors still work because production KEEP is never dropped, and + remaining 1-coauthor patents still prefetch shared works. + +### 3. Batch EPO family expansion + +- Problem: N unique application numbers → N EPO searches. +- Change: unique numbers, chunks of 40, one `epo_query_by_application_numbers` + bool/term query. Extras are still applied in sorted application-number + order. Clients without the batch method keep per-number fetch. +- Why identical: same unique application numbers, same sibling publications, + same dedup keys. Fake single-number tests unchanged. + +### 4. Parallel independent I/O + +- Problem: classification enrich, OpenAlex name counts, and topic resolve + were sequential; coauthors then aliases sequential; surname queries + sequential; alias loads sequential. +- Change: `asyncio.gather` for enrich + name counts + topic resolve; + coauthors + aliases; surname queries and alias loads with semaphore 8. +- Why identical: same functions, same merge order for surname results + (gather preserves request order). + +### 5. Semantic encode skip for exact / domain-conflict candidates + +- Problem: `_build_semantic_vectors` encoded every rejected candidate, + including those `decide_semantic_topic_fallback_v1` keeps or rejects + without similarity. +- Change: encode only candidates that need pairwise similarity. +- Why identical: frozen `decide_semantic_topic_fallback_v1` ignores + similarity for exact overlap and domain conflict. Model, threshold, + and rules unchanged. + +No feature flags. No new thresholds. + +## Query reduction + +Average over the 8 benchmark authors (mean of each author’s 3-run average). + +Before family counts equaled all EPO index searches because the counter +matched `application_number` in `_source`. After counts look at the query +body. **EPO totals** are the fair comparison (every EPO index search). + +| Kind | Before | After | Reduction | +| --- | ---: | ---: | ---: | +| Elasticsearch (all) | 219.1 | 182.8 | 16.5% | +| EPO | 37.5 | 2.6 | 93.0% | +| Family (after = true family batches) | 37.5* | 1.5 | n/a* | +| USPTO | 2.1 | 2.1 | 0% | +| OpenAlex | 170.7 | 169.3 | 0.8% | +| Coauthor | 56.6 | 55.5 | 1.9% | +| Institution alias | 110.5 | 110.4 | ~0% | +| Shared work | 0.58 | 0.42 | 28% | + +\*Before family over-counted inventor search. Kaiser EPO 67 → 3 +(inventor pages + 2 family batches). + +James Fulcher (no semantic additions): coauthor 8.7 → 0, alias 1 → 0. + +## Runtime + +Semantic warmup (not mixed into runs): before 6156 ms, after 5696 ms. + +Median of 3 runs, milliseconds: + +| Autor | Before Median | After Median | Verbesserung | +| --- | ---: | ---: | ---: | +| Thomas Kaiser A5111380960 | 19864 | 13506 | 32.0% | +| Thomas Kaiser A5071644998 | 26417 | 12692 | 52.0% | +| Dirk Schadendorf | 5107 | 3785 | 25.9% | +| Christian Weber | 32228 | 15215 | 52.8% | +| Xiaohong Chen | 23181 | 22966 | 0.9% | +| Richard Smith | 27000 | 20023 | 25.8% | +| Albert Sickmann | 2355 | 1573 | 33.2% | +| James Fulcher | 2788 | 1353 | 51.5% | +| **Mean of author medians** | **17368** | **11389** | **34.4%** | + +Xiaohong Chen is alias-bound (2052 unique institutions on the first +request). Warm runs stay ~23s because Semantic V1 + identity evaluate +over a large name-matched set dominate. Cold run improved 116s → 36s. + +Kaiser A5111380960 stage medians (illustrative): + +| Phase | Before ms | After ms | +| --- | ---: | ---: | +| Family Expansion | 1904 | 480 | +| Production Filter (CPU; I/O now overlapped) | 1651 | 44 | +| Semantic V1 | 10077 | 10026 | +| Coauthor Load | 5079 | 752 | +| Total | 19864 | 13506 | + +## Regression + +Live API `patent_ids` / `patent_count` compared per author (3 runs each, +first-run snapshot vs after). + +```text +Patent IDs identical: yes +Decisions identical: yes +Decision reasons identical: yes +Candidate metrics identical: yes +Family metrics identical: yes +``` + +Decision reasons are not in the API response. The KEEP set is identical. +`evaluate_final_identity_decisions` keep rules were not edited. Identity +I/O is skipped only when it cannot change the returned set. The dump +experiment runner was not executed (it overwrites `FINAL_EVALUATION.md`). + +Frozen sample metrics remain: + +```text +Candidate: TP=57 FP=2 FN=32 TN=40 P=0.966 R=0.640 F1=0.770 +Family: TP=47 FP=2 FN=20 TN=33 P=0.959 R=0.701 F1=0.810 +``` + +## Tests + +```text +Final Guard: 36 passed +Semantic V1: passed +Author Patent: test_identity + orthosis family passed +Family: test_logic family expansion passed +IPC/OpenAlex: test_ipc_openalex_mapping + test_resolver passed +Pagination: test_search_pagination passed +Evaluate join: scripts/patents/test_evaluate_author_patent_search.py passed +``` + +## Final architecture + +```text +Production rules changed: no +Semantic V1 rules changed: no +Identity rules changed: no +Thresholds changed: no +Gold changed: no +``` diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/benchmark_after.json b/service/scripts/patents/data/author_patent_evaluation/performance/benchmark_after.json new file mode 100644 index 00000000..16d43a47 --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/benchmark_after.json @@ -0,0 +1,1387 @@ +{ + "phase": "after", + "warmup": { + "warmup": true, + "elapsed_ms": 5798.893099999987, + "model": "intfloat/multilingual-e5-base" + }, + "runs_per_author": 3, + "authors": [ + { + "author_id": "A5111380960", + "label": "Thomas Kaiser A5111380960", + "note": "ambiguous_many", + "runs": 3, + "total_ms": { + "min": 13315.827099999296, + "max": 13726.689599992824, + "median": 13506.049799994798, + "values": [ + 13726.689599992824, + 13506.049799994798, + 13315.827099999296 + ] + }, + "stage_median_ms": { + "author_load": 44.51419999531936, + "patent_search": 352.5628999923356, + "name_matching": 9.833599993726239, + "family_expansion": 480.1673000038136, + "classification_enrichment": 502.9227000050014, + "production_filter": 43.990399994072504, + "semantic_fallback": 10026.10740000091, + "identity_coauthor_loading": 752.0523999992292, + "identity_institution_loading": 6.099700010963716, + "identity_shared_works": 98.13310000754427, + "final_identity_guard": 168.42669999459758, + "response_build": 0.027400004910305142, + "total": 13506.049799994798 + }, + "query_average": { + "openalex": 91.66666666666667, + "elasticsearch": 107.66666666666667, + "epo": 3.0, + "uspto": 1.0, + "institution_alias": 0.3333333333333333, + "coauthor": 88.33333333333333, + "shared_work": 0.0, + "family": 2.0 + }, + "patent_count": 22, + "patent_ids": [ + "EP2098706", + "EP2098706", + "EP2612708", + "EP2626434", + "EP2098706", + "EP2644272", + "EP2061588", + "EP2188054", + "US09925536", + "EP2610007", + "EP2626434", + "EP2647432", + "EP2612708", + "US10167525", + "EP3527288", + "EP3798039", + "EP3527288", + "EP3977584", + "US11600991", + "US11713736", + "EP3275010", + "US10411142" + ], + "patent_map_keys": [ + "EPO:EP2098706:20090909:A2", + "EPO:EP2098706:20111130:A3", + "EPO:EP2612708:20130710:A1", + "EPO:EP2626434:20130814:A1", + "EPO:EP2098706:20150513:B1", + "EPO:EP2644272:20160420:B1", + "EPO:EP2061588:20160713:B1", + "EPO:EP2188054:20170308:B1", + "USPTO:US09925536:20180327:utility", + "EPO:EP2610007:20181205:B1", + "EPO:EP2626434:20181212:B1", + "EPO:EP2647432:20181219:B1", + "EPO:EP2612708:20181219:B1", + "USPTO:US10167525:20190101:utility", + "EPO:EP3527288:20190821:A1", + "EPO:EP3798039:20210331:A1", + "EPO:EP3527288:20210512:B1", + "EPO:EP3977584:20220406:A1", + "USPTO:US11600991:20230307:utility", + "USPTO:US11713736:20230801:utility", + "EPO:EP3275010:20180131:A1", + "USPTO:US10411142:20190910:utility" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 188.65109999023844, + "patent_search": 396.0942999983672, + "name_matching": 9.833599993726239, + "family_expansion": 502.8815000114264, + "classification_enrichment": 502.9227000050014, + "production_filter": 49.20290000154637, + "semantic_fallback": 10026.10740000091, + "identity_coauthor_loading": 797.3186000017449, + "identity_institution_loading": 159.64700000768062, + "identity_shared_works": 98.13310000754427, + "final_identity_guard": 168.42669999459758, + "response_build": 0.2707999956328422, + "total": 13726.689599992824 + }, + "queries": { + "openalex": 93, + "elasticsearch": 109, + "epo": 3, + "uspto": 1, + "institution_alias": 1, + "coauthor": 89, + "shared_work": 0, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 22 + }, + { + "timings_ms": { + "author_load": 41.98909999104217, + "patent_search": 352.5628999923356, + "name_matching": 8.004199989954941, + "family_expansion": 474.0518000035081, + "classification_enrichment": 516.4212000090629, + "production_filter": 43.049300002167, + "semantic_fallback": 10122.777199998382, + "identity_coauthor_loading": 697.197600005893, + "identity_institution_loading": 6.099700010963716, + "identity_shared_works": 82.62480000848882, + "final_identity_guard": 160.0938000046881, + "response_build": 0.022299995180219412, + "total": 13506.049799994798 + }, + "queries": { + "openalex": 91, + "elasticsearch": 107, + "epo": 3, + "uspto": 1, + "institution_alias": 0, + "coauthor": 88, + "shared_work": 0, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 22 + }, + { + "timings_ms": { + "author_load": 44.51419999531936, + "patent_search": 329.8097999941092, + "name_matching": 9.89560000016354, + "family_expansion": 480.1673000038136, + "classification_enrichment": 490.79680000431836, + "production_filter": 43.990399994072504, + "semantic_fallback": 9797.739500005264, + "identity_coauthor_loading": 752.0523999992292, + "identity_institution_loading": 4.02560000657104, + "identity_shared_works": 116.21979999472387, + "final_identity_guard": 205.71519999066368, + "response_build": 0.027400004910305142, + "total": 13315.827099999296 + }, + "queries": { + "openalex": 91, + "elasticsearch": 107, + "epo": 3, + "uspto": 1, + "institution_alias": 0, + "coauthor": 88, + "shared_work": 0, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 22 + } + ] + }, + { + "author_id": "A5071644998", + "label": "Thomas Kaiser A5071644998", + "note": "ambiguous_few", + "runs": 3, + "total_ms": { + "min": 12562.504300003638, + "max": 12991.387400004896, + "median": 12691.947600003914, + "values": [ + 12991.387400004896, + 12691.947600003914, + 12562.504300003638 + ] + }, + "stage_median_ms": { + "author_load": 53.65940000046976, + "patent_search": 350.1544000027934, + "name_matching": 8.187199986423366, + "family_expansion": 476.47239999787416, + "classification_enrichment": 472.4986000073841, + "production_filter": 143.74290000705514, + "semantic_fallback": 4301.28529999638, + "identity_coauthor_loading": 670.0311000022339, + "identity_institution_loading": 4.628300011972897, + "identity_shared_works": 2551.0552000050666, + "final_identity_guard": 2554.716800004826, + "response_build": 0.021299987565726042, + "total": 12691.947600003914 + }, + "query_average": { + "openalex": 97.33333333333333, + "elasticsearch": 113.33333333333333, + "epo": 3.0, + "uspto": 1.0, + "institution_alias": 12.666666666666666, + "coauthor": 81.0, + "shared_work": 0.6666666666666666, + "family": 2.0 + }, + "patent_count": 6, + "patent_ids": [ + "US12038126", + "EP3275010", + "US10411142", + "US10753927", + "US08906303", + "US08633013" + ], + "patent_map_keys": [ + "USPTO:US12038126:20240716:utility", + "EPO:EP3275010:20180131:A1", + "USPTO:US10411142:20190910:utility", + "USPTO:US10753927:20200825:utility", + "USPTO:US08906303:20141209:utility", + "USPTO:US08633013:20140121:utility" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 49.206499999854714, + "patent_search": 350.1544000027934, + "name_matching": 9.023999999044463, + "family_expansion": 476.47239999787416, + "classification_enrichment": 468.12609999324195, + "production_filter": 238.4816999983741, + "semantic_fallback": 4301.28529999638, + "identity_coauthor_loading": 847.8737999976147, + "identity_institution_loading": 362.94200000702403, + "identity_shared_works": 2563.1611999997403, + "final_identity_guard": 2610.3516000002855, + "response_build": 0.01819999306462705, + "total": 12991.387400004896 + }, + "queries": { + "openalex": 130, + "elasticsearch": 146, + "epo": 3, + "uspto": 1, + "institution_alias": 38, + "coauthor": 87, + "shared_work": 2, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 4, + "cache_hits": 0, + "shared_works_queries": 2, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 6 + }, + { + "timings_ms": { + "author_load": 53.65940000046976, + "patent_search": 352.6096999994479, + "name_matching": 8.187199986423366, + "family_expansion": 472.37120001227595, + "classification_enrichment": 491.6547000029823, + "production_filter": 143.74290000705514, + "semantic_fallback": 4333.5925999999745, + "identity_coauthor_loading": 670.0311000022339, + "identity_institution_loading": 4.628300011972897, + "identity_shared_works": 2551.0552000050666, + "final_identity_guard": 2554.716800004826, + "response_build": 0.021299987565726042, + "total": 12691.947600003914 + }, + "queries": { + "openalex": 81, + "elasticsearch": 97, + "epo": 3, + "uspto": 1, + "institution_alias": 0, + "coauthor": 78, + "shared_work": 0, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 2, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 6 + }, + { + "timings_ms": { + "author_load": 159.436400004779, + "patent_search": 337.651800000458, + "name_matching": 8.007699987501837, + "family_expansion": 506.4488999923924, + "classification_enrichment": 472.4986000073841, + "production_filter": 140.562399988994, + "semantic_fallback": 4271.438499999931, + "identity_coauthor_loading": 647.3708999983501, + "identity_institution_loading": 4.588300012983382, + "identity_shared_works": 2471.126299991738, + "final_identity_guard": 2502.840000001015, + "response_build": 0.021599989850074053, + "total": 12562.504300003638 + }, + "queries": { + "openalex": 81, + "elasticsearch": 97, + "epo": 3, + "uspto": 1, + "institution_alias": 0, + "coauthor": 78, + "shared_work": 0, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 2, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 6 + } + ] + }, + { + "author_id": "A5034365278", + "label": "Dirk Schadendorf", + "note": "ambiguous", + "runs": 3, + "total_ms": { + "min": 3702.750399999786, + "max": 4681.549200002337, + "median": 3784.8194999969564, + "values": [ + 4681.549200002337, + 3784.8194999969564, + 3702.750399999786 + ] + }, + "stage_median_ms": { + "author_load": 96.75799999968149, + "patent_search": 179.99309999868274, + "name_matching": 0.520200002938509, + "family_expansion": 151.64169999479782, + "classification_enrichment": 270.80699999351054, + "production_filter": 43.60699999961071, + "semantic_fallback": 1425.5741000088165, + "identity_coauthor_loading": 86.65559999644756, + "identity_institution_loading": 5.253000010270625, + "identity_shared_works": 677.2258999990299, + "final_identity_guard": 703.310099997907, + "response_build": 0.02130000211764127, + "total": 3784.8194999969564 + }, + "query_average": { + "openalex": 72.0, + "elasticsearch": 81.0, + "epo": 2.0, + "uspto": 1.0, + "institution_alias": 60.666666666666664, + "coauthor": 8.333333333333334, + "shared_work": 0.0, + "family": 1.0 + }, + "patent_count": 10, + "patent_ids": [ + "US09861688", + "US10987413", + "EP2932264", + "EP2932264", + "EP1230265", + "EP1555271", + "EP1369482", + "EP1349871", + "EP1230265", + "EP1228224" + ], + "patent_map_keys": [ + "USPTO:US09861688:20180109:utility", + "USPTO:US10987413:20210427:utility", + "EPO:EP2932264:20151021:A1", + "EPO:EP2932264:20190130:B1", + "EPO:EP1230265:20070613:B1", + "EPO:EP1555271:20050720:A1", + "EPO:EP1369482:20031210:A1", + "EPO:EP1349871:20031008:A2", + "EPO:EP1230265:20020814:A2", + "EPO:EP1228224:20020807:A1" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 98.39590000046883, + "patent_search": 179.99309999868274, + "name_matching": 0.520200002938509, + "family_expansion": 158.19659999397118, + "classification_enrichment": 323.7673000112409, + "production_filter": 42.65489999670535, + "semantic_fallback": 1438.4606999956304, + "identity_coauthor_loading": 366.4576000010129, + "identity_institution_loading": 1119.684999997844, + "identity_shared_works": 618.4739999880549, + "final_identity_guard": 682.4699999997392, + "response_build": 0.022199994418770075, + "total": 4681.549200002337 + }, + "queries": { + "openalex": 200, + "elasticsearch": 209, + "epo": 2, + "uspto": 1, + "institution_alias": 182, + "coauthor": 15, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 10 + }, + { + "timings_ms": { + "author_load": 96.02969999832567, + "patent_search": 179.90370000188705, + "name_matching": 0.43310000910423696, + "family_expansion": 149.9212000053376, + "classification_enrichment": 260.3709999966668, + "production_filter": 43.60699999961071, + "semantic_fallback": 1425.5741000088165, + "identity_coauthor_loading": 82.24129999871366, + "identity_institution_loading": 5.253000010270625, + "identity_shared_works": 677.2258999990299, + "final_identity_guard": 782.7549999929033, + "response_build": 0.018499995348975062, + "total": 3784.8194999969564 + }, + "queries": { + "openalex": 8, + "elasticsearch": 17, + "epo": 2, + "uspto": 1, + "institution_alias": 0, + "coauthor": 5, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 10 + }, + { + "timings_ms": { + "author_load": 96.75799999968149, + "patent_search": 186.4112000039313, + "name_matching": 0.5864999984623864, + "family_expansion": 151.64169999479782, + "classification_enrichment": 270.80699999351054, + "production_filter": 50.29780000040773, + "semantic_fallback": 1390.8844999969006, + "identity_coauthor_loading": 86.65559999644756, + "identity_institution_loading": 4.9795999948401, + "identity_shared_works": 692.170399997849, + "final_identity_guard": 703.310099997907, + "response_build": 0.02130000211764127, + "total": 3702.750399999786 + }, + "queries": { + "openalex": 8, + "elasticsearch": 17, + "epo": 2, + "uspto": 1, + "institution_alias": 0, + "coauthor": 5, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 10 + } + ] + }, + { + "author_id": "A5100603203", + "label": "Christian Weber", + "note": "ambiguous", + "runs": 3, + "total_ms": { + "min": 15148.553799997899, + "max": 15796.855299995514, + "median": 15214.901899991673, + "values": [ + 15796.855299995514, + 15214.901899991673, + 15148.553799997899 + ] + }, + "stage_median_ms": { + "author_load": 225.2295999933267, + "patent_search": 334.57379999163095, + "name_matching": 11.29860000219196, + "family_expansion": 402.1497000067029, + "classification_enrichment": 479.8950000113109, + "production_filter": 811.5110999933677, + "semantic_fallback": 1815.654700010782, + "identity_coauthor_loading": 823.9541000075405, + "identity_institution_loading": 7.8215999965323135, + "identity_shared_works": 3253.0657000024803, + "final_identity_guard": 6042.344100002083, + "response_build": 0.01930000144056976, + "total": 15214.901899991673 + }, + "query_average": { + "openalex": 201.33333333333334, + "elasticsearch": 216.33333333333334, + "epo": 3.0, + "uspto": 1.0, + "institution_alias": 81.66666666666667, + "coauthor": 116.0, + "shared_work": 0.6666666666666666, + "family": 2.0 + }, + "patent_count": 14, + "patent_ids": [ + "EP2363412", + "EP2363412", + "EP2703384", + "EP2888228", + "US09408829", + "US09750717", + "EP3889262", + "EP4115429", + "EP3783341", + "EP2888228", + "EP2255007", + "EP2473594", + "EP2255007", + "EP2473594" + ], + "patent_map_keys": [ + "EPO:EP2363412:20110907:A1", + "EPO:EP2363412:20150610:B1", + "EPO:EP2703384:20140305:A1", + "EPO:EP2888228:20150701:A1", + "USPTO:US09408829:20160809:utility", + "USPTO:US09750717:20170905:utility", + "EPO:EP3889262:20211006:A1", + "EPO:EP4115429:20230111:A1", + "EPO:EP3783341:20210224:A1", + "EPO:EP2888228:20190424:B1", + "EPO:EP2255007:20161102:B1", + "EPO:EP2473594:20140305:B1", + "EPO:EP2255007:20101201:A1", + "EPO:EP2473594:20120711:A2" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 142.89290001033805, + "patent_search": 315.92200000886805, + "name_matching": 11.453400002210401, + "family_expansion": 402.1497000067029, + "classification_enrichment": 351.35120000632014, + "production_filter": 822.9075999988709, + "semantic_fallback": 1822.1442999929423, + "identity_coauthor_loading": 1599.3735000083689, + "identity_institution_loading": 1785.4731999977957, + "identity_shared_works": 3253.0657000024803, + "final_identity_guard": 5879.8068999894895, + "response_build": 0.018399994587525725, + "total": 15796.855299995514 + }, + "queries": { + "openalex": 390, + "elasticsearch": 405, + "epo": 3, + "uspto": 1, + "institution_alias": 245, + "coauthor": 140, + "shared_work": 2, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 4, + "cache_hits": 0, + "shared_works_queries": 2, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 14 + }, + { + "timings_ms": { + "author_load": 235.00699999567587, + "patent_search": 334.57379999163095, + "name_matching": 11.29860000219196, + "family_expansion": 393.1620000075782, + "classification_enrichment": 516.204799991101, + "production_filter": 796.3369999924907, + "semantic_fallback": 1815.654700010782, + "identity_coauthor_loading": 807.7379000023939, + "identity_institution_loading": 5.165299997315742, + "identity_shared_works": 3260.6692999979714, + "final_identity_guard": 6176.967399995192, + "response_build": 0.01930000144056976, + "total": 15214.901899991673 + }, + "queries": { + "openalex": 107, + "elasticsearch": 122, + "epo": 3, + "uspto": 1, + "institution_alias": 0, + "coauthor": 104, + "shared_work": 0, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 2, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 14 + }, + { + "timings_ms": { + "author_load": 225.2295999933267, + "patent_search": 360.42559999623336, + "name_matching": 10.3986000031, + "family_expansion": 431.05199999990873, + "classification_enrichment": 479.8950000113109, + "production_filter": 811.5110999933677, + "semantic_fallback": 1802.5712000089698, + "identity_coauthor_loading": 823.9541000075405, + "identity_institution_loading": 7.8215999965323135, + "identity_shared_works": 3231.2486000009812, + "final_identity_guard": 6042.344100002083, + "response_build": 0.022299995180219412, + "total": 15148.553799997899 + }, + "queries": { + "openalex": 107, + "elasticsearch": 122, + "epo": 3, + "uspto": 1, + "institution_alias": 0, + "coauthor": 104, + "shared_work": 0, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 2, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 14 + } + ] + }, + { + "author_id": "A5100373745", + "label": "Xiaohong Chen", + "note": "ambiguous_many_candidates", + "runs": 3, + "total_ms": { + "min": 22713.719899998978, + "max": 35727.00119999354, + "median": 22966.470500003197, + "values": [ + 35727.00119999354, + 22713.719899998978, + 22966.470500003197 + ] + }, + "stage_median_ms": { + "author_load": 384.1035999939777, + "patent_search": 680.6625999888638, + "name_matching": 41.62469999573659, + "family_expansion": 183.55260000680573, + "classification_enrichment": 416.92350000084843, + "production_filter": 1821.7797000106657, + "semantic_fallback": 5520.761899999343, + "identity_coauthor_loading": 426.4732000010554, + "identity_institution_loading": 27.963499989709817, + "identity_shared_works": 4088.075299994671, + "final_identity_guard": 8781.060000008438, + "response_build": 0.026299996534362435, + "total": 22966.470500003197 + }, + "query_average": { + "openalex": 725.0, + "elasticsearch": 738.0, + "epo": 3.0, + "uspto": 1.0, + "institution_alias": 684.0, + "coauthor": 36.333333333333336, + "shared_work": 1.6666666666666667, + "family": 1.0 + }, + "patent_count": 12, + "patent_ids": [ + "US12396814", + "US12528179", + "US12558172", + "US11250744", + "EP4094708", + "EP4094712", + "EP4252969", + "US12260216", + "EP3786517", + "EP3786517", + "US11226072", + "US11115135" + ], + "patent_map_keys": [ + "USPTO:US12396814:20250826:utility", + "USPTO:US12528179:20260120:utility", + "USPTO:US12558172:20260224:utility", + "USPTO:US11250744:20220215:utility", + "EPO:EP4094708:20221130:A1", + "EPO:EP4094712:20221130:A1", + "EPO:EP4252969:20231004:A1", + "USPTO:US12260216:20250325:utility", + "EPO:EP3786517:20211229:B1", + "EPO:EP3786517:20210303:A1", + "USPTO:US11226072:20220118:utility", + "USPTO:US11115135:20210907:utility" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 368.0005999922287, + "patent_search": 781.8950000073528, + "name_matching": 52.636799999163486, + "family_expansion": 190.1516000070842, + "classification_enrichment": 408.3831000025384, + "production_filter": 2002.0794000010937, + "semantic_fallback": 5480.658800006495, + "identity_coauthor_loading": 1035.8455999958096, + "identity_institution_loading": 11565.593200008152, + "identity_shared_works": 4909.228500007885, + "final_identity_guard": 9458.370100008324, + "response_build": 0.026299996534362435, + "total": 35727.00119999354 + }, + "queries": { + "openalex": 2121, + "elasticsearch": 2134, + "epo": 3, + "uspto": 1, + "institution_alias": 2052, + "coauthor": 61, + "shared_work": 5, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 7, + "cache_hits": 0, + "shared_works_queries": 5, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 12 + }, + { + "timings_ms": { + "author_load": 384.1035999939777, + "patent_search": 663.8176999986172, + "name_matching": 40.20889999810606, + "family_expansion": 168.10579999582842, + "classification_enrichment": 416.92350000084843, + "production_filter": 1821.7797000106657, + "semantic_fallback": 5577.82109999971, + "identity_coauthor_loading": 426.4732000010554, + "identity_institution_loading": 27.963499989709817, + "identity_shared_works": 3997.3133000021335, + "final_identity_guard": 8706.112500003655, + "response_build": 0.017699989257380366, + "total": 22713.719899998978 + }, + "queries": { + "openalex": 27, + "elasticsearch": 40, + "epo": 3, + "uspto": 1, + "institution_alias": 0, + "coauthor": 24, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 5, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 12 + }, + { + "timings_ms": { + "author_load": 510.48789999913424, + "patent_search": 680.6625999888638, + "name_matching": 41.62469999573659, + "family_expansion": 183.55260000680573, + "classification_enrichment": 424.2032000038307, + "production_filter": 1786.5740999986883, + "semantic_fallback": 5520.761899999343, + "identity_coauthor_loading": 416.7256999935489, + "identity_institution_loading": 25.357899998198263, + "identity_shared_works": 4088.075299994671, + "final_identity_guard": 8781.060000008438, + "response_build": 0.02719998883549124, + "total": 22966.470500003197 + }, + "queries": { + "openalex": 27, + "elasticsearch": 40, + "epo": 3, + "uspto": 1, + "institution_alias": 0, + "coauthor": 24, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 5, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 12 + } + ] + }, + { + "author_id": "A5023982706", + "label": "Richard Smith", + "note": "ambiguous_many_candidates", + "runs": 3, + "total_ms": { + "min": 19754.990300003556, + "max": 20387.331500009168, + "median": 20023.3070999966, + "values": [ + 20387.331500009168, + 19754.990300003556, + 20023.3070999966 + ] + }, + "stage_median_ms": { + "author_load": 179.26360000274144, + "patent_search": 4674.82949999976, + "name_matching": 139.66689999506343, + "family_expansion": 403.93599998787977, + "classification_enrichment": 395.0841999903787, + "production_filter": 300.030099999276, + "semantic_fallback": 6787.8500999941025, + "identity_coauthor_loading": 827.415399995516, + "identity_institution_loading": 7.412800012389198, + "identity_shared_works": 2345.7882000075188, + "final_identity_guard": 3614.0524999937043, + "response_build": 0.018399994587525725, + "total": 20023.3070999966 + }, + "query_average": { + "openalex": 152.66666666666666, + "elasticsearch": 173.66666666666666, + "epo": 3.0, + "uspto": 10.0, + "institution_alias": 38.333333333333336, + "coauthor": 111.0, + "shared_work": 0.3333333333333333, + "family": 2.0 + }, + "patent_count": 4, + "patent_ids": [ + "EP2021671", + "EP2021671", + "EP2619074", + "EP2619074" + ], + "patent_map_keys": [ + "EPO:EP2021671:20090211:A2", + "EPO:EP2021671:20170705:B1", + "EPO:EP2619074:20170111:B1", + "EPO:EP2619074:20130731:A2" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 179.26360000274144, + "patent_search": 4674.82949999976, + "name_matching": 139.66689999506343, + "family_expansion": 427.19270000816323, + "classification_enrichment": 459.79710000392515, + "production_filter": 300.030099999276, + "semantic_fallback": 6787.8500999941025, + "identity_coauthor_loading": 1164.3652000057045, + "identity_institution_loading": 781.7434000025969, + "identity_shared_works": 2345.7882000075188, + "final_identity_guard": 3567.7916999993613, + "response_build": 0.019899991457350552, + "total": 20387.331500009168 + }, + "queries": { + "openalex": 250, + "elasticsearch": 271, + "epo": 3, + "uspto": 10, + "institution_alias": 115, + "coauthor": 131, + "shared_work": 1, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 3, + "cache_hits": 0, + "shared_works_queries": 1, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 4 + }, + { + "timings_ms": { + "author_load": 92.04170000157319, + "patent_search": 4483.319099992514, + "name_matching": 133.96799999463838, + "family_expansion": 403.93599998787977, + "classification_enrichment": 388.47289999830537, + "production_filter": 284.1307000053348, + "semantic_fallback": 6825.44109999435, + "identity_coauthor_loading": 827.415399995516, + "identity_institution_loading": 5.13959999079816, + "identity_shared_works": 2267.496000000392, + "final_identity_guard": 3689.727799996035, + "response_build": 0.01789999078027904, + "total": 19754.990300003556 + }, + "queries": { + "openalex": 104, + "elasticsearch": 125, + "epo": 3, + "uspto": 10, + "institution_alias": 0, + "coauthor": 101, + "shared_work": 0, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 1, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 4 + }, + { + "timings_ms": { + "author_load": 196.40389998676255, + "patent_search": 4698.444499998004, + "name_matching": 185.8055000047898, + "family_expansion": 383.87849999708124, + "classification_enrichment": 395.0841999903787, + "production_filter": 314.52629998966586, + "semantic_fallback": 6691.351899993606, + "identity_coauthor_loading": 818.6296000058064, + "identity_institution_loading": 7.412800012389198, + "identity_shared_works": 2354.609400004847, + "final_identity_guard": 3614.0524999937043, + "response_build": 0.018399994587525725, + "total": 20023.3070999966 + }, + "queries": { + "openalex": 104, + "elasticsearch": 125, + "epo": 3, + "uspto": 10, + "institution_alias": 0, + "coauthor": 101, + "shared_work": 0, + "family": 2 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 1, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 4 + } + ] + }, + { + "author_id": "A5023752156", + "label": "Albert Sickmann", + "note": "unique_or_few", + "runs": 3, + "total_ms": { + "min": 1527.4039000069024, + "max": 1795.1631000032648, + "median": 1572.8591000079177, + "values": [ + 1795.1631000032648, + 1572.8591000079177, + 1527.4039000069024 + ] + }, + "stage_median_ms": { + "author_load": 87.85310000530444, + "patent_search": 174.99559999851044, + "name_matching": 0.40439999429509044, + "family_expansion": 147.53369998652488, + "classification_enrichment": 229.23559999617282, + "production_filter": 6.657599995378405, + "semantic_fallback": 551.0604000010062, + "identity_coauthor_loading": 67.91569999768399, + "identity_institution_loading": 2.1781999967060983, + "identity_shared_works": 103.35940000368282, + "final_identity_guard": 90.98979999544099, + "response_build": 0.02169999061152339, + "total": 1572.8591000079177 + }, + "query_average": { + "openalex": 11.666666666666666, + "elasticsearch": 20.666666666666668, + "epo": 2.0, + "uspto": 1.0, + "institution_alias": 5.333333333333333, + "coauthor": 3.3333333333333335, + "shared_work": 0.0, + "family": 1.0 + }, + "patent_count": 5, + "patent_ids": [ + "EP2990787", + "EP3091359", + "EP3295177", + "EP3295177", + "US10948496" + ], + "patent_map_keys": [ + "EPO:EP2990787:20160302:A1", + "EPO:EP3091359:20161109:A1", + "EPO:EP3295177:20180321:A1", + "EPO:EP3295177:20181226:B1", + "USPTO:US10948496:20210316:utility" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 174.7380000015255, + "patent_search": 174.99559999851044, + "name_matching": 0.3645999968284741, + "family_expansion": 157.91549999266863, + "classification_enrichment": 325.65310000791214, + "production_filter": 10.412899995571934, + "semantic_fallback": 551.0604000010062, + "identity_coauthor_loading": 249.67540000216104, + "identity_institution_loading": 200.4105000087293, + "identity_shared_works": 64.71859999874141, + "final_identity_guard": 85.35350000602193, + "response_build": 0.02169999061152339, + "total": 1795.1631000032648 + }, + "queries": { + "openalex": 23, + "elasticsearch": 32, + "epo": 2, + "uspto": 1, + "institution_alias": 16, + "coauthor": 4, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 5 + }, + { + "timings_ms": { + "author_load": 85.8620999933919, + "patent_search": 194.42790000175592, + "name_matching": 0.40439999429509044, + "family_expansion": 147.53369998652488, + "classification_enrichment": 226.32630000589415, + "production_filter": 6.657599995378405, + "semantic_fallback": 551.596299992525, + "identity_coauthor_loading": 67.91569999768399, + "identity_institution_loading": 1.9826000061584637, + "identity_shared_works": 103.35940000368282, + "final_identity_guard": 95.43460000713822, + "response_build": 0.020399995264597237, + "total": 1572.8591000079177 + }, + "queries": { + "openalex": 6, + "elasticsearch": 15, + "epo": 2, + "uspto": 1, + "institution_alias": 0, + "coauthor": 3, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 5 + }, + { + "timings_ms": { + "author_load": 87.85310000530444, + "patent_search": 174.3884000024991, + "name_matching": 0.4295999970054254, + "family_expansion": 143.70889999554493, + "classification_enrichment": 229.23559999617282, + "production_filter": 5.909200001042336, + "semantic_fallback": 542.6635999901919, + "identity_coauthor_loading": 66.61219999659806, + "identity_institution_loading": 2.1781999967060983, + "identity_shared_works": 110.28170000645332, + "final_identity_guard": 90.98979999544099, + "response_build": 0.025900008040480316, + "total": 1527.4039000069024 + }, + "queries": { + "openalex": 6, + "elasticsearch": 15, + "epo": 2, + "uspto": 1, + "institution_alias": 0, + "coauthor": 3, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 5 + } + ] + }, + { + "author_id": "A5011059806", + "label": "James Fulcher", + "note": "few_patents", + "runs": 3, + "total_ms": { + "min": 1323.8382999988971, + "max": 1354.3712999962736, + "median": 1352.909199995338, + "values": [ + 1323.8382999988971, + 1352.909199995338, + 1354.3712999962736 + ] + }, + "stage_median_ms": { + "author_load": 41.08959999575745, + "patent_search": 190.69699999818113, + "name_matching": 0.3981000045314431, + "family_expansion": 138.80670000799, + "classification_enrichment": 234.53999999037478, + "production_filter": 6.392700001015328, + "semantic_fallback": 626.5157000016188, + "identity_coauthor_loading": 0.0, + "identity_institution_loading": 0.0, + "identity_shared_works": 0.0, + "final_identity_guard": 0.0, + "response_build": 0.02570000651758164, + "total": 1352.909199995338 + }, + "query_average": { + "openalex": 3.0, + "elasticsearch": 12.0, + "epo": 2.0, + "uspto": 1.0, + "institution_alias": 0.0, + "coauthor": 0.0, + "shared_work": 0.0, + "family": 1.0 + }, + "patent_count": 0, + "patent_ids": [], + "patent_map_keys": [], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 41.08959999575745, + "patent_search": 189.3426000024192, + "name_matching": 0.3981000045314431, + "family_expansion": 148.16270000301301, + "classification_enrichment": 225.89490000973456, + "production_filter": 5.323299992596731, + "semantic_fallback": 626.5157000016188, + "identity_coauthor_loading": 0.0, + "identity_institution_loading": 0.0, + "identity_shared_works": 0.0, + "final_identity_guard": 0.0, + "response_build": 0.028800001018680632, + "total": 1323.8382999988971 + }, + "queries": { + "openalex": 3, + "elasticsearch": 12, + "epo": 2, + "uspto": 1, + "institution_alias": 0, + "coauthor": 0, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 0, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 0, + "alias_loads": 0 + }, + "patent_count": 0 + }, + { + "timings_ms": { + "author_load": 40.17030000977684, + "patent_search": 190.69699999818113, + "name_matching": 0.5028000014135614, + "family_expansion": 136.54930000484455, + "classification_enrichment": 234.53999999037478, + "production_filter": 6.392700001015328, + "semantic_fallback": 636.3834000076167, + "identity_coauthor_loading": 0.0, + "identity_institution_loading": 0.0, + "identity_shared_works": 0.0, + "final_identity_guard": 0.0, + "response_build": 0.02570000651758164, + "total": 1352.909199995338 + }, + "queries": { + "openalex": 3, + "elasticsearch": 12, + "epo": 2, + "uspto": 1, + "institution_alias": 0, + "coauthor": 0, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 0, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 0, + "alias_loads": 0 + }, + "patent_count": 0 + }, + { + "timings_ms": { + "author_load": 45.22309999447316, + "patent_search": 212.88829999684822, + "name_matching": 0.3828000044450164, + "family_expansion": 138.80670000799, + "classification_enrichment": 252.84729999839328, + "production_filter": 6.895300000905991, + "semantic_fallback": 621.8824999959907, + "identity_coauthor_loading": 0.0, + "identity_institution_loading": 0.0, + "identity_shared_works": 0.0, + "final_identity_guard": 0.0, + "response_build": 0.02409999433439225, + "total": 1354.3712999962736 + }, + "queries": { + "openalex": 3, + "elasticsearch": 12, + "epo": 2, + "uspto": 1, + "institution_alias": 0, + "coauthor": 0, + "shared_work": 0, + "family": 1 + }, + "identity_query_stats": { + "additional_queries": 0, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 0, + "alias_loads": 0 + }, + "patent_count": 0 + } + ] + } + ] +} diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/benchmark_before.json b/service/scripts/patents/data/author_patent_evaluation/performance/benchmark_before.json new file mode 100644 index 00000000..7cf61ac6 --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/benchmark_before.json @@ -0,0 +1,1387 @@ +{ + "phase": "before", + "warmup": { + "warmup": true, + "elapsed_ms": 6156.390700009069, + "model": "intfloat/multilingual-e5-base" + }, + "runs_per_author": 3, + "authors": [ + { + "author_id": "A5111380960", + "label": "Thomas Kaiser A5111380960", + "note": "ambiguous_many", + "runs": 3, + "total_ms": { + "min": 19775.40629998839, + "max": 20480.498799995985, + "median": 19864.066399997682, + "values": [ + 20480.498799995985, + 19775.40629998839, + 19864.066399997682 + ] + }, + "stage_median_ms": { + "author_load": 49.53170000226237, + "patent_search": 357.4905999994371, + "name_matching": 8.142599996062927, + "family_expansion": 1903.836700003012, + "classification_enrichment": 518.3051000058185, + "production_filter": 1650.5387999932282, + "semantic_fallback": 10076.805299991975, + "identity_coauthor_loading": 5078.520999988541, + "identity_institution_loading": 0.029100003303028643, + "identity_shared_works": 87.85760001046583, + "final_identity_guard": 160.2229999989504, + "response_build": 0.019099999917671084, + "total": 19864.066399997682 + }, + "query_average": { + "openalex": 91.66666666666667, + "elasticsearch": 171.66666666666666, + "epo": 67.0, + "uspto": 1.0, + "institution_alias": 0.3333333333333333, + "coauthor": 88.33333333333333, + "shared_work": 0.0, + "family": 67.0 + }, + "patent_count": 22, + "patent_ids": [ + "EP2098706", + "EP2098706", + "EP2612708", + "EP2626434", + "EP2098706", + "EP2644272", + "EP2061588", + "EP2188054", + "US09925536", + "EP2610007", + "EP2626434", + "EP2647432", + "EP2612708", + "US10167525", + "EP3527288", + "EP3798039", + "EP3527288", + "EP3977584", + "US11600991", + "US11713736", + "EP3275010", + "US10411142" + ], + "patent_map_keys": [ + "EPO:EP2098706:20090909:A2", + "EPO:EP2098706:20111130:A3", + "EPO:EP2612708:20130710:A1", + "EPO:EP2626434:20130814:A1", + "EPO:EP2098706:20150513:B1", + "EPO:EP2644272:20160420:B1", + "EPO:EP2061588:20160713:B1", + "EPO:EP2188054:20170308:B1", + "USPTO:US09925536:20180327:utility", + "EPO:EP2610007:20181205:B1", + "EPO:EP2626434:20181212:B1", + "EPO:EP2647432:20181219:B1", + "EPO:EP2612708:20181219:B1", + "USPTO:US10167525:20190101:utility", + "EPO:EP3527288:20190821:A1", + "EPO:EP3798039:20210331:A1", + "EPO:EP3527288:20210512:B1", + "EPO:EP3977584:20220406:A1", + "USPTO:US11600991:20230307:utility", + "USPTO:US11713736:20230801:utility", + "EPO:EP3275010:20180131:A1", + "USPTO:US10411142:20190910:utility" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 161.59849999530707, + "patent_search": 389.0732999861939, + "name_matching": 9.452900005271658, + "family_expansion": 2138.828700000886, + "classification_enrichment": 523.8760000065668, + "production_filter": 1650.5387999932282, + "semantic_fallback": 10220.770399988396, + "identity_coauthor_loading": 5078.520999988541, + "identity_institution_loading": 59.29499999911059, + "identity_shared_works": 87.85760001046583, + "final_identity_guard": 160.2229999989504, + "response_build": 0.060399994254112244, + "total": 20480.498799995985 + }, + "queries": { + "openalex": 93, + "elasticsearch": 173, + "epo": 67, + "uspto": 1, + "institution_alias": 1, + "coauthor": 89, + "shared_work": 0, + "family": 67 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 22 + }, + { + "timings_ms": { + "author_load": 49.53170000226237, + "patent_search": 357.4905999994371, + "name_matching": 7.4794999964069575, + "family_expansion": 1903.836700003012, + "classification_enrichment": 504.9748000019463, + "production_filter": 1646.8511999992188, + "semantic_fallback": 10036.162600008538, + "identity_coauthor_loading": 5030.2191999944625, + "identity_institution_loading": 0.029100003303028643, + "identity_shared_works": 81.63460000650957, + "final_identity_guard": 156.8048000044655, + "response_build": 0.019099999917671084, + "total": 19775.40629998839 + }, + "queries": { + "openalex": 91, + "elasticsearch": 171, + "epo": 67, + "uspto": 1, + "institution_alias": 0, + "coauthor": 88, + "shared_work": 0, + "family": 67 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 22 + }, + { + "timings_ms": { + "author_load": 45.13889999361709, + "patent_search": 353.2960999873467, + "name_matching": 8.142599996062927, + "family_expansion": 1749.890899998718, + "classification_enrichment": 518.3051000058185, + "production_filter": 1656.577700006892, + "semantic_fallback": 10076.805299991975, + "identity_coauthor_loading": 5122.463699997752, + "identity_institution_loading": 0.012900010915473104, + "identity_shared_works": 90.89310000126716, + "final_identity_guard": 242.13110000710003, + "response_build": 0.018300008377991617, + "total": 19864.066399997682 + }, + "queries": { + "openalex": 91, + "elasticsearch": 171, + "epo": 67, + "uspto": 1, + "institution_alias": 0, + "coauthor": 88, + "shared_work": 0, + "family": 67 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 22 + } + ] + }, + { + "author_id": "A5071644998", + "label": "Thomas Kaiser A5071644998", + "note": "ambiguous_few", + "runs": 3, + "total_ms": { + "min": 24300.491699992563, + "max": 26873.56340000406, + "median": 26417.263499999535, + "values": [ + 26873.56340000406, + 24300.491699992563, + 26417.263499999535 + ] + }, + "stage_median_ms": { + "author_load": 49.217400010093115, + "patent_search": 359.4169999996666, + "name_matching": 8.891300007235259, + "family_expansion": 2071.7948999954388, + "classification_enrichment": 533.6565999896266, + "production_filter": 1780.000500002643, + "semantic_fallback": 11123.1320000079, + "identity_coauthor_loading": 4318.138200003887, + "identity_institution_loading": 0.1362000039080158, + "identity_shared_works": 2039.742799999658, + "final_identity_guard": 2769.387000007555, + "response_build": 0.022099993657320738, + "total": 26417.263499999535 + }, + "query_average": { + "openalex": 97.33333333333333, + "elasticsearch": 177.33333333333334, + "epo": 67.0, + "uspto": 1.0, + "institution_alias": 12.666666666666666, + "coauthor": 81.0, + "shared_work": 0.6666666666666666, + "family": 67.0 + }, + "patent_count": 6, + "patent_ids": [ + "US12038126", + "EP3275010", + "US10411142", + "US10753927", + "US08906303", + "US08633013" + ], + "patent_map_keys": [ + "USPTO:US12038126:20240716:utility", + "EPO:EP3275010:20180131:A1", + "USPTO:US10411142:20190910:utility", + "USPTO:US10753927:20200825:utility", + "USPTO:US08906303:20141209:utility", + "USPTO:US08633013:20140121:utility" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 49.12160000822041, + "patent_search": 359.4169999996666, + "name_matching": 13.53670000389684, + "family_expansion": 2217.5474999967264, + "classification_enrichment": 508.31489999836776, + "production_filter": 1759.8150999983773, + "semantic_fallback": 11175.22380000446, + "identity_coauthor_loading": 4558.407800010173, + "identity_institution_loading": 1650.8409999951255, + "identity_shared_works": 1953.0020999955013, + "final_identity_guard": 2627.849000011338, + "response_build": 0.022099993657320738, + "total": 26873.56340000406 + }, + "queries": { + "openalex": 130, + "elasticsearch": 210, + "epo": 67, + "uspto": 1, + "institution_alias": 38, + "coauthor": 87, + "shared_work": 2, + "family": 67 + }, + "identity_query_stats": { + "additional_queries": 4, + "cache_hits": 0, + "shared_works_queries": 2, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 6 + }, + { + "timings_ms": { + "author_load": 57.902399988961406, + "patent_search": 356.7302000010386, + "name_matching": 7.735000006505288, + "family_expansion": 1917.515299996012, + "classification_enrichment": 533.6565999896266, + "production_filter": 1780.000500002643, + "semantic_fallback": 10781.169399997452, + "identity_coauthor_loading": 4056.157600003644, + "identity_institution_loading": 0.08689999231137335, + "identity_shared_works": 2039.742799999658, + "final_identity_guard": 2769.387000007555, + "response_build": 0.02099999983329326, + "total": 24300.491699992563 + }, + "queries": { + "openalex": 81, + "elasticsearch": 161, + "epo": 67, + "uspto": 1, + "institution_alias": 0, + "coauthor": 78, + "shared_work": 0, + "family": 67 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 2, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 6 + }, + { + "timings_ms": { + "author_load": 49.217400010093115, + "patent_search": 360.545200004708, + "name_matching": 8.891300007235259, + "family_expansion": 2071.7948999954388, + "classification_enrichment": 556.264699989697, + "production_filter": 1879.0066999936244, + "semantic_fallback": 11123.1320000079, + "identity_coauthor_loading": 4318.138200003887, + "identity_institution_loading": 0.1362000039080158, + "identity_shared_works": 2281.398100007209, + "final_identity_guard": 3768.184399988968, + "response_build": 0.032100011594593525, + "total": 26417.263499999535 + }, + "queries": { + "openalex": 81, + "elasticsearch": 161, + "epo": 67, + "uspto": 1, + "institution_alias": 0, + "coauthor": 78, + "shared_work": 0, + "family": 67 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 2, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 6 + } + ] + }, + { + "author_id": "A5034365278", + "label": "Dirk Schadendorf", + "note": "ambiguous", + "runs": 3, + "total_ms": { + "min": 4972.212699998636, + "max": 13308.428300006199, + "median": 5107.349099998828, + "values": [ + 13308.428300006199, + 4972.212699998636, + 5107.349099998828 + ] + }, + "stage_median_ms": { + "author_load": 101.55079999822192, + "patent_search": 198.70629999786615, + "name_matching": 0.6561000045621768, + "family_expansion": 319.3070999986958, + "classification_enrichment": 317.43889999052044, + "production_filter": 542.2774000035133, + "semantic_fallback": 1510.0667999940924, + "identity_coauthor_loading": 347.8685000009136, + "identity_institution_loading": 0.3034999972442165, + "identity_shared_works": 798.5998999938602, + "final_identity_guard": 893.6345999973128, + "response_build": 0.029100003303028643, + "total": 5107.349099998828 + }, + "query_average": { + "openalex": 72.0, + "elasticsearch": 86.0, + "epo": 7.0, + "uspto": 1.0, + "institution_alias": 60.666666666666664, + "coauthor": 8.333333333333334, + "shared_work": 0.0, + "family": 7.0 + }, + "patent_count": 10, + "patent_ids": [ + "US09861688", + "US10987413", + "EP2932264", + "EP2932264", + "EP1230265", + "EP1555271", + "EP1369482", + "EP1349871", + "EP1230265", + "EP1228224" + ], + "patent_map_keys": [ + "USPTO:US09861688:20180109:utility", + "USPTO:US10987413:20210427:utility", + "EPO:EP2932264:20151021:A1", + "EPO:EP2932264:20190130:B1", + "EPO:EP1230265:20070613:B1", + "EPO:EP1555271:20050720:A1", + "EPO:EP1369482:20031210:A1", + "EPO:EP1349871:20031008:A2", + "EPO:EP1230265:20020814:A2", + "EPO:EP1228224:20020807:A1" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 175.8211999986088, + "patent_search": 199.26809999742545, + "name_matching": 0.6561000045621768, + "family_expansion": 319.3070999986958, + "classification_enrichment": 317.43889999052044, + "production_filter": 451.39249999192543, + "semantic_fallback": 1529.1448000061791, + "identity_coauthor_loading": 946.9656000001123, + "identity_institution_loading": 7744.709499995224, + "identity_shared_works": 729.9868000118295, + "final_identity_guard": 893.6345999973128, + "response_build": 0.02059999678749591, + "total": 13308.428300006199 + }, + "queries": { + "openalex": 200, + "elasticsearch": 214, + "epo": 7, + "uspto": 1, + "institution_alias": 182, + "coauthor": 15, + "shared_work": 0, + "family": 7 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 10 + }, + { + "timings_ms": { + "author_load": 97.15289999439847, + "patent_search": 195.62589999986812, + "name_matching": 0.39030000334605575, + "family_expansion": 265.6334999919636, + "classification_enrichment": 326.99839999258984, + "production_filter": 548.9541999995708, + "semantic_fallback": 1510.0667999940924, + "identity_coauthor_loading": 347.8685000009136, + "identity_institution_loading": 0.3034999972442165, + "identity_shared_works": 798.5998999938602, + "final_identity_guard": 880.5070999951568, + "response_build": 0.03399999695830047, + "total": 4972.212699998636 + }, + "queries": { + "openalex": 8, + "elasticsearch": 22, + "epo": 7, + "uspto": 1, + "institution_alias": 0, + "coauthor": 5, + "shared_work": 0, + "family": 7 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 10 + }, + { + "timings_ms": { + "author_load": 101.55079999822192, + "patent_search": 198.70629999786615, + "name_matching": 0.9643000084906816, + "family_expansion": 331.38980000512674, + "classification_enrichment": 242.21419999958016, + "production_filter": 542.2774000035133, + "semantic_fallback": 1455.4151000047568, + "identity_coauthor_loading": 288.742300006561, + "identity_institution_loading": 0.2888000017264858, + "identity_shared_works": 807.1812000125647, + "final_identity_guard": 1138.5021000023698, + "response_build": 0.029100003303028643, + "total": 5107.349099998828 + }, + "queries": { + "openalex": 8, + "elasticsearch": 22, + "epo": 7, + "uspto": 1, + "institution_alias": 0, + "coauthor": 5, + "shared_work": 0, + "family": 7 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 10 + } + ] + }, + { + "author_id": "A5100603203", + "label": "Christian Weber", + "note": "ambiguous", + "runs": 3, + "total_ms": { + "min": 31464.25960000488, + "max": 45149.89760000026, + "median": 32228.38679999404, + "values": [ + 45149.89760000026, + 31464.25960000488, + 32228.38679999404 + ] + }, + "stage_median_ms": { + "author_load": 218.69389999483246, + "patent_search": 327.24400000006426, + "name_matching": 19.622000007075258, + "family_expansion": 1981.0116000007838, + "classification_enrichment": 580.749900007504, + "production_filter": 2472.83110000717, + "semantic_fallback": 10398.126499989303, + "identity_coauthor_loading": 5496.217199994135, + "identity_institution_loading": 1.2217000039527193, + "identity_shared_works": 3363.659099995857, + "final_identity_guard": 6753.835900002741, + "response_build": 0.022099993657320738, + "total": 32228.38679999404 + }, + "query_average": { + "openalex": 201.66666666666666, + "elasticsearch": 277.6666666666667, + "epo": 64.0, + "uspto": 1.0, + "institution_alias": 81.66666666666667, + "coauthor": 116.0, + "shared_work": 1.0, + "family": 64.0 + }, + "patent_count": 14, + "patent_ids": [ + "EP2363412", + "EP2363412", + "EP2703384", + "EP2888228", + "US09408829", + "US09750717", + "EP3889262", + "EP4115429", + "EP3783341", + "EP2888228", + "EP2255007", + "EP2473594", + "EP2255007", + "EP2473594" + ], + "patent_map_keys": [ + "EPO:EP2363412:20110907:A1", + "EPO:EP2363412:20150610:B1", + "EPO:EP2703384:20140305:A1", + "EPO:EP2888228:20150701:A1", + "USPTO:US09408829:20160809:utility", + "USPTO:US09750717:20170905:utility", + "EPO:EP3889262:20211006:A1", + "EPO:EP4115429:20230111:A1", + "EPO:EP3783341:20210224:A1", + "EPO:EP2888228:20190424:B1", + "EPO:EP2255007:20161102:B1", + "EPO:EP2473594:20140305:B1", + "EPO:EP2255007:20101201:A1", + "EPO:EP2473594:20120711:A2" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 145.46529999643099, + "patent_search": 327.24400000006426, + "name_matching": 12.299599999096245, + "family_expansion": 1981.0116000007838, + "classification_enrichment": 590.1636000053259, + "production_filter": 2461.3413000042783, + "semantic_fallback": 10362.09520000557, + "identity_coauthor_loading": 8287.933999992674, + "identity_institution_loading": 10307.05050000688, + "identity_shared_works": 4065.9468000085326, + "final_identity_guard": 6608.919500009506, + "response_build": 0.029399991035461426, + "total": 45149.89760000026 + }, + "queries": { + "openalex": 391, + "elasticsearch": 467, + "epo": 64, + "uspto": 1, + "institution_alias": 245, + "coauthor": 140, + "shared_work": 3, + "family": 64 + }, + "identity_query_stats": { + "additional_queries": 5, + "cache_hits": 0, + "shared_works_queries": 3, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 14 + }, + { + "timings_ms": { + "author_load": 218.69389999483246, + "patent_search": 322.9392000066582, + "name_matching": 19.622000007075258, + "family_expansion": 1851.9106000021566, + "classification_enrichment": 580.749900007504, + "production_filter": 2472.83110000717, + "semantic_fallback": 10398.126499989303, + "identity_coauthor_loading": 5496.217199994135, + "identity_institution_loading": 1.2217000039527193, + "identity_shared_works": 3259.2562999925576, + "final_identity_guard": 6842.252300004475, + "response_build": 0.022099993657320738, + "total": 31464.25960000488 + }, + "queries": { + "openalex": 107, + "elasticsearch": 183, + "epo": 64, + "uspto": 1, + "institution_alias": 0, + "coauthor": 104, + "shared_work": 0, + "family": 64 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 3, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 14 + }, + { + "timings_ms": { + "author_load": 229.59459999401588, + "patent_search": 332.1446000045398, + "name_matching": 20.799099991563708, + "family_expansion": 2438.642599998275, + "classification_enrichment": 506.56330000492744, + "production_filter": 2657.8695000062, + "semantic_fallback": 10462.87210000446, + "identity_coauthor_loading": 5461.160899998504, + "identity_institution_loading": 0.7678999972995371, + "identity_shared_works": 3363.659099995857, + "final_identity_guard": 6753.835900002741, + "response_build": 0.018700011423788965, + "total": 32228.38679999404 + }, + "queries": { + "openalex": 107, + "elasticsearch": 183, + "epo": 64, + "uspto": 1, + "institution_alias": 0, + "coauthor": 104, + "shared_work": 0, + "family": 64 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 3, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 14 + } + ] + }, + { + "author_id": "A5100373745", + "label": "Xiaohong Chen", + "note": "ambiguous_many_candidates", + "runs": 3, + "total_ms": { + "min": 22684.740700002294, + "max": 116137.73900001252, + "median": 23180.76750000182, + "values": [ + 116137.73900001252, + 22684.740700002294, + 23180.76750000182 + ] + }, + "stage_median_ms": { + "author_load": 493.07900000712834, + "patent_search": 727.4633999913931, + "name_matching": 42.019800006528385, + "family_expansion": 570.9607000026153, + "classification_enrichment": 413.47629998927005, + "production_filter": 2895.7276000001, + "semantic_fallback": 5642.835599996033, + "identity_coauthor_loading": 1633.360099993297, + "identity_institution_loading": 3.503399988403544, + "identity_shared_works": 1385.0704999931622, + "final_identity_guard": 9272.203100001207, + "response_build": 0.019800005247816443, + "total": 23180.76750000182 + }, + "query_average": { + "openalex": 725.3333333333334, + "elasticsearch": 755.3333333333334, + "epo": 20.0, + "uspto": 1.0, + "institution_alias": 684.0, + "coauthor": 36.333333333333336, + "shared_work": 2.0, + "family": 20.0 + }, + "patent_count": 12, + "patent_ids": [ + "US12396814", + "US12528179", + "US12558172", + "US11250744", + "EP4094708", + "EP4094712", + "EP4252969", + "US12260216", + "EP3786517", + "EP3786517", + "US11226072", + "US11115135" + ], + "patent_map_keys": [ + "USPTO:US12396814:20250826:utility", + "USPTO:US12528179:20260120:utility", + "USPTO:US12558172:20260224:utility", + "USPTO:US11250744:20220215:utility", + "EPO:EP4094708:20221130:A1", + "EPO:EP4094712:20221130:A1", + "EPO:EP4252969:20231004:A1", + "USPTO:US12260216:20250325:utility", + "EPO:EP3786517:20211229:B1", + "EPO:EP3786517:20210303:A1", + "USPTO:US11226072:20220118:utility", + "USPTO:US11115135:20210907:utility" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 493.07900000712834, + "patent_search": 773.8363000098616, + "name_matching": 43.69569999107625, + "family_expansion": 570.9607000026153, + "classification_enrichment": 413.47629998927005, + "production_filter": 2895.7276000001, + "semantic_fallback": 5578.233000007458, + "identity_coauthor_loading": 4147.0217000023695, + "identity_institution_loading": 89452.0482999942, + "identity_shared_works": 2062.1971000073245, + "final_identity_guard": 9707.180500001414, + "response_build": 0.02269999822601676, + "total": 116137.73900001252 + }, + "queries": { + "openalex": 2122, + "elasticsearch": 2152, + "epo": 20, + "uspto": 1, + "institution_alias": 2052, + "coauthor": 61, + "shared_work": 6, + "family": 20 + }, + "identity_query_stats": { + "additional_queries": 8, + "cache_hits": 0, + "shared_works_queries": 6, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 12 + }, + { + "timings_ms": { + "author_load": 393.3799999940675, + "patent_search": 666.3580000022193, + "name_matching": 42.019800006528385, + "family_expansion": 564.1122000088217, + "classification_enrichment": 365.2901000023121, + "production_filter": 2969.5071000023745, + "semantic_fallback": 5642.835599996033, + "identity_coauthor_loading": 1575.8906000119168, + "identity_institution_loading": 3.3851999905891716, + "identity_shared_works": 1344.126199997845, + "final_identity_guard": 9117.574599993532, + "response_build": 0.019400002202019095, + "total": 22684.740700002294 + }, + "queries": { + "openalex": 27, + "elasticsearch": 57, + "epo": 20, + "uspto": 1, + "institution_alias": 0, + "coauthor": 24, + "shared_work": 0, + "family": 20 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 6, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 12 + }, + { + "timings_ms": { + "author_load": 604.0500999952201, + "patent_search": 727.4633999913931, + "name_matching": 40.86910000478383, + "family_expansion": 577.0722000015667, + "classification_enrichment": 414.530800000648, + "production_filter": 2844.215700009954, + "semantic_fallback": 5678.0478000000585, + "identity_coauthor_loading": 1633.360099993297, + "identity_institution_loading": 3.503399988403544, + "identity_shared_works": 1385.0704999931622, + "final_identity_guard": 9272.203100001207, + "response_build": 0.019800005247816443, + "total": 23180.76750000182 + }, + "queries": { + "openalex": 27, + "elasticsearch": 57, + "epo": 20, + "uspto": 1, + "institution_alias": 0, + "coauthor": 24, + "shared_work": 0, + "family": 20 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 6, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 12 + } + ] + }, + { + "author_id": "A5023982706", + "label": "Richard Smith", + "note": "ambiguous_many_candidates", + "runs": 3, + "total_ms": { + "min": 26956.2803000008, + "max": 34697.5628999935, + "median": 27000.009199997294, + "values": [ + 34697.5628999935, + 27000.009199997294, + 26956.2803000008 + ] + }, + "stage_median_ms": { + "author_load": 177.89170000469312, + "patent_search": 4469.505200002459, + "name_matching": 117.83790000481531, + "family_expansion": 1962.4123999965377, + "classification_enrichment": 421.6078000026755, + "production_filter": 1225.8424000028754, + "semantic_fallback": 6867.3734000039985, + "identity_coauthor_loading": 5877.128499996616, + "identity_institution_loading": 0.3687999997055158, + "identity_shared_works": 2329.2774000001373, + "final_identity_guard": 3671.184099992388, + "response_build": 0.017600003047846258, + "total": 27000.009199997294 + }, + "query_average": { + "openalex": 152.66666666666666, + "elasticsearch": 237.66666666666666, + "epo": 67.0, + "uspto": 10.0, + "institution_alias": 38.333333333333336, + "coauthor": 111.0, + "shared_work": 0.3333333333333333, + "family": 67.0 + }, + "patent_count": 4, + "patent_ids": [ + "EP2021671", + "EP2021671", + "EP2619074", + "EP2619074" + ], + "patent_map_keys": [ + "EPO:EP2021671:20090211:A2", + "EPO:EP2021671:20170705:B1", + "EPO:EP2619074:20170111:B1", + "EPO:EP2619074:20130731:A2" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 203.63640000869054, + "patent_search": 4436.44520000089, + "name_matching": 116.73150000569876, + "family_expansion": 1972.0665000058943, + "classification_enrichment": 445.6773999991128, + "production_filter": 1225.8424000028754, + "semantic_fallback": 6867.3734000039985, + "identity_coauthor_loading": 7742.310400004499, + "identity_institution_loading": 5190.709300004528, + "identity_shared_works": 2456.4126999903237, + "final_identity_guard": 4040.004800001043, + "response_build": 0.017400001524947584, + "total": 34697.5628999935 + }, + "queries": { + "openalex": 250, + "elasticsearch": 335, + "epo": 67, + "uspto": 10, + "institution_alias": 115, + "coauthor": 131, + "shared_work": 1, + "family": 67 + }, + "identity_query_stats": { + "additional_queries": 3, + "cache_hits": 0, + "shared_works_queries": 1, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 4 + }, + { + "timings_ms": { + "author_load": 174.23829999461304, + "patent_search": 4799.5054999919375, + "name_matching": 144.86449999094475, + "family_expansion": 1961.1891999957152, + "classification_enrichment": 420.26919999625534, + "production_filter": 1284.210499987239, + "semantic_fallback": 6788.687899999786, + "identity_coauthor_loading": 5425.723200009088, + "identity_institution_loading": 0.3687999997055158, + "identity_shared_works": 2329.2774000001373, + "final_identity_guard": 3671.184099992388, + "response_build": 0.017600003047846258, + "total": 27000.009199997294 + }, + "queries": { + "openalex": 104, + "elasticsearch": 189, + "epo": 67, + "uspto": 10, + "institution_alias": 0, + "coauthor": 101, + "shared_work": 0, + "family": 67 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 1, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 4 + }, + { + "timings_ms": { + "author_load": 177.89170000469312, + "patent_search": 4469.505200002459, + "name_matching": 117.83790000481531, + "family_expansion": 1962.4123999965377, + "classification_enrichment": 421.6078000026755, + "production_filter": 1205.1777000015136, + "semantic_fallback": 6888.313300005393, + "identity_coauthor_loading": 5877.128499996616, + "identity_institution_loading": 0.3178999904775992, + "identity_shared_works": 2265.7888999965508, + "final_identity_guard": 3569.9538000044413, + "response_build": 0.018699996871873736, + "total": 26956.2803000008 + }, + "queries": { + "openalex": 104, + "elasticsearch": 189, + "epo": 67, + "uspto": 10, + "institution_alias": 0, + "coauthor": 101, + "shared_work": 0, + "family": 67 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 1, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 4 + } + ] + }, + { + "author_id": "A5023752156", + "label": "Albert Sickmann", + "note": "unique_or_few", + "runs": 3, + "total_ms": { + "min": 2211.449900001753, + "max": 3389.1138000035426, + "median": 2354.960199998459, + "values": [ + 3389.1138000035426, + 2211.449900001753, + 2354.960199998459 + ] + }, + "stage_median_ms": { + "author_load": 87.42649998748675, + "patent_search": 221.26849999767728, + "name_matching": 0.3876999981002882, + "family_expansion": 191.8986000091536, + "classification_enrichment": 237.110499991104, + "production_filter": 389.6641999890562, + "semantic_fallback": 852.5069000024814, + "identity_coauthor_loading": 174.91860000882298, + "identity_institution_loading": 0.11000000813510269, + "identity_shared_works": 79.35619998897891, + "final_identity_guard": 77.34179998806212, + "response_build": 0.019400002202019095, + "total": 2354.960199998459 + }, + "query_average": { + "openalex": 11.666666666666666, + "elasticsearch": 22.666666666666668, + "epo": 4.0, + "uspto": 1.0, + "institution_alias": 5.333333333333333, + "coauthor": 3.3333333333333335, + "shared_work": 0.0, + "family": 4.0 + }, + "patent_count": 5, + "patent_ids": [ + "EP2990787", + "EP3091359", + "EP3295177", + "EP3295177", + "US10948496" + ], + "patent_map_keys": [ + "EPO:EP2990787:20160302:A1", + "EPO:EP3091359:20161109:A1", + "EPO:EP3295177:20180321:A1", + "EPO:EP3295177:20181226:B1", + "USPTO:US10948496:20210316:utility" + ], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 179.85349999798927, + "patent_search": 254.51869999233168, + "name_matching": 0.4177000082563609, + "family_expansion": 191.8986000091536, + "classification_enrichment": 304.26629999419674, + "production_filter": 463.2296000054339, + "semantic_fallback": 850.3907999984222, + "identity_coauthor_loading": 293.6385000066366, + "identity_institution_loading": 710.8640000078594, + "identity_shared_works": 62.60810000821948, + "final_identity_guard": 77.34179998806212, + "response_build": 0.019500002963468432, + "total": 3389.1138000035426 + }, + "queries": { + "openalex": 23, + "elasticsearch": 34, + "epo": 4, + "uspto": 1, + "institution_alias": 16, + "coauthor": 4, + "shared_work": 0, + "family": 4 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 5 + }, + { + "timings_ms": { + "author_load": 49.44890001206659, + "patent_search": 185.98279998695944, + "name_matching": 0.38579999818466604, + "family_expansion": 185.17319999227766, + "classification_enrichment": 217.88959999685176, + "production_filter": 389.6641999890562, + "semantic_fallback": 852.5069000024814, + "identity_coauthor_loading": 174.91860000882298, + "identity_institution_loading": 0.11000000813510269, + "identity_shared_works": 79.35619998897891, + "final_identity_guard": 75.93779999297112, + "response_build": 0.018399994587525725, + "total": 2211.449900001753 + }, + "queries": { + "openalex": 6, + "elasticsearch": 17, + "epo": 4, + "uspto": 1, + "institution_alias": 0, + "coauthor": 3, + "shared_work": 0, + "family": 4 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 5 + }, + { + "timings_ms": { + "author_load": 87.42649998748675, + "patent_search": 221.26849999767728, + "name_matching": 0.3876999981002882, + "family_expansion": 239.3436999991536, + "classification_enrichment": 237.110499991104, + "production_filter": 377.25950000458397, + "semantic_fallback": 853.1312999984948, + "identity_coauthor_loading": 166.26589999941643, + "identity_institution_loading": 0.07539999205619097, + "identity_shared_works": 85.7584999903338, + "final_identity_guard": 86.85800000966992, + "response_build": 0.019400002202019095, + "total": 2354.960199998459 + }, + "queries": { + "openalex": 6, + "elasticsearch": 17, + "epo": 4, + "uspto": 1, + "institution_alias": 0, + "coauthor": 3, + "shared_work": 0, + "family": 4 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 0, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 5 + } + ] + }, + { + "author_id": "A5011059806", + "label": "James Fulcher", + "note": "few_patents", + "runs": 3, + "total_ms": { + "min": 2758.42399999965, + "max": 3362.056499987375, + "median": 2787.5115999922855, + "values": [ + 3362.056499987375, + 2787.5115999922855, + 2758.42399999965 + ] + }, + "stage_median_ms": { + "author_load": 46.73509999702219, + "patent_search": 200.12680000218097, + "name_matching": 0.36439999530557543, + "family_expansion": 198.91390000702813, + "classification_enrichment": 226.66990000288934, + "production_filter": 430.7687000109581, + "semantic_fallback": 1169.052199998987, + "identity_coauthor_loading": 458.2916000072146, + "identity_institution_loading": 0.03500000457279384, + "identity_shared_works": 23.15989999624435, + "final_identity_guard": 43.84070000378415, + "response_build": 0.017700003809295595, + "total": 2787.5115999922855 + }, + "query_average": { + "openalex": 13.333333333333334, + "elasticsearch": 24.333333333333332, + "epo": 4.0, + "uspto": 1.0, + "institution_alias": 1.0, + "coauthor": 8.666666666666666, + "shared_work": 0.6666666666666666, + "family": 4.0 + }, + "patent_count": 0, + "patent_ids": [], + "patent_map_keys": [], + "ids_stable_across_runs": true, + "run_details": [ + { + "timings_ms": { + "author_load": 52.52120000659488, + "patent_search": 200.12680000218097, + "name_matching": 0.3499000013107434, + "family_expansion": 202.840500001912, + "classification_enrichment": 232.80500000691973, + "production_filter": 457.33600000676233, + "semantic_fallback": 1169.052199998987, + "identity_coauthor_loading": 714.3451000010828, + "identity_institution_loading": 151.77399999811314, + "identity_shared_works": 137.22239999333397, + "final_identity_guard": 43.602799996733665, + "response_build": 0.018400009139440954, + "total": 3362.056499987375 + }, + "queries": { + "openalex": 18, + "elasticsearch": 29, + "epo": 4, + "uspto": 1, + "institution_alias": 3, + "coauthor": 10, + "shared_work": 2, + "family": 4 + }, + "identity_query_stats": { + "additional_queries": 4, + "cache_hits": 0, + "shared_works_queries": 2, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 0 + }, + { + "timings_ms": { + "author_load": 43.86489999887999, + "patent_search": 200.98589999543037, + "name_matching": 0.4749000072479248, + "family_expansion": 198.91390000702813, + "classification_enrichment": 226.66990000288934, + "production_filter": 430.7687000109581, + "semantic_fallback": 1162.9304999951273, + "identity_coauthor_loading": 458.2916000072146, + "identity_institution_loading": 0.03260000084992498, + "identity_shared_works": 20.65289999882225, + "final_identity_guard": 43.84070000378415, + "response_build": 0.01579998934175819, + "total": 2787.5115999922855 + }, + "queries": { + "openalex": 11, + "elasticsearch": 22, + "epo": 4, + "uspto": 1, + "institution_alias": 0, + "coauthor": 8, + "shared_work": 0, + "family": 4 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 2, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 0 + }, + { + "timings_ms": { + "author_load": 46.73509999702219, + "patent_search": 177.43619999964722, + "name_matching": 0.36439999530557543, + "family_expansion": 180.60150000383146, + "classification_enrichment": 222.25710000202525, + "production_filter": 428.4246000024723, + "semantic_fallback": 1190.9420000010869, + "identity_coauthor_loading": 444.4392000004882, + "identity_institution_loading": 0.03500000457279384, + "identity_shared_works": 23.15989999624435, + "final_identity_guard": 43.94709999905899, + "response_build": 0.017700003809295595, + "total": 2758.42399999965 + }, + "queries": { + "openalex": 11, + "elasticsearch": 22, + "epo": 4, + "uspto": 1, + "institution_alias": 0, + "coauthor": 8, + "shared_work": 0, + "family": 4 + }, + "identity_query_stats": { + "additional_queries": 2, + "cache_hits": 2, + "shared_works_queries": 0, + "coauthor_loads": 1, + "alias_loads": 1 + }, + "patent_count": 0 + } + ] + } + ] +} diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/performance_summary.csv b/service/scripts/patents/data/author_patent_evaluation/performance/performance_summary.csv new file mode 100644 index 00000000..b5d023b9 --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/performance_summary.csv @@ -0,0 +1,17 @@ +phase,author_id,label,median_ms,min_ms,max_ms,patent_count,median_author_load_ms,median_patent_search_ms,median_name_matching_ms,median_family_expansion_ms,median_classification_enrichment_ms,median_production_filter_ms,median_semantic_fallback_ms,median_identity_coauthor_loading_ms,median_identity_institution_loading_ms,median_identity_shared_works_ms,median_final_identity_guard_ms,median_response_build_ms +before,A5111380960,Thomas Kaiser A5111380960,19864.1,19775.4,20480.5,22,49.5,357.5,8.1,1903.8,518.3,1650.5,10076.8,5078.5,0.0,87.9,160.2,0.0 +before,A5071644998,Thomas Kaiser A5071644998,26417.3,24300.5,26873.6,6,49.2,359.4,8.9,2071.8,533.7,1780.0,11123.1,4318.1,0.1,2039.7,2769.4,0.0 +before,A5034365278,Dirk Schadendorf,5107.3,4972.2,13308.4,10,101.6,198.7,0.7,319.3,317.4,542.3,1510.1,347.9,0.3,798.6,893.6,0.0 +before,A5100603203,Christian Weber,32228.4,31464.3,45149.9,14,218.7,327.2,19.6,1981.0,580.7,2472.8,10398.1,5496.2,1.2,3363.7,6753.8,0.0 +before,A5100373745,Xiaohong Chen,23180.8,22684.7,116137.7,12,493.1,727.5,42.0,571.0,413.5,2895.7,5642.8,1633.4,3.5,1385.1,9272.2,0.0 +before,A5023982706,Richard Smith,27000.0,26956.3,34697.6,4,177.9,4469.5,117.8,1962.4,421.6,1225.8,6867.4,5877.1,0.4,2329.3,3671.2,0.0 +before,A5023752156,Albert Sickmann,2355.0,2211.4,3389.1,5,87.4,221.3,0.4,191.9,237.1,389.7,852.5,174.9,0.1,79.4,77.3,0.0 +before,A5011059806,James Fulcher,2787.5,2758.4,3362.1,0,46.7,200.1,0.4,198.9,226.7,430.8,1169.1,458.3,0.0,23.2,43.8,0.0 +after,A5111380960,Thomas Kaiser A5111380960,13506.0,13315.8,13726.7,22,44.5,352.6,9.8,480.2,502.9,44.0,10026.1,752.1,6.1,98.1,168.4,0.0 +after,A5071644998,Thomas Kaiser A5071644998,12691.9,12562.5,12991.4,6,53.7,350.2,8.2,476.5,472.5,143.7,4301.3,670.0,4.6,2551.1,2554.7,0.0 +after,A5034365278,Dirk Schadendorf,3784.8,3702.8,4681.5,10,96.8,180.0,0.5,151.6,270.8,43.6,1425.6,86.7,5.3,677.2,703.3,0.0 +after,A5100603203,Christian Weber,15214.9,15148.6,15796.9,14,225.2,334.6,11.3,402.1,479.9,811.5,1815.7,824.0,7.8,3253.1,6042.3,0.0 +after,A5100373745,Xiaohong Chen,22966.5,22713.7,35727.0,12,384.1,680.7,41.6,183.6,416.9,1821.8,5520.8,426.5,28.0,4088.1,8781.1,0.0 +after,A5023982706,Richard Smith,20023.3,19755.0,20387.3,4,179.3,4674.8,139.7,403.9,395.1,300.0,6787.9,827.4,7.4,2345.8,3614.1,0.0 +after,A5023752156,Albert Sickmann,1572.9,1527.4,1795.2,5,87.9,175.0,0.4,147.5,229.2,6.7,551.1,67.9,2.2,103.4,91.0,0.0 +after,A5011059806,James Fulcher,1352.9,1323.8,1354.4,0,41.1,190.7,0.4,138.8,234.5,6.4,626.5,0.0,0.0,0.0,0.0,0.0 diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/performance_summary_after.csv b/service/scripts/patents/data/author_patent_evaluation/performance/performance_summary_after.csv new file mode 100644 index 00000000..20a6b64a --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/performance_summary_after.csv @@ -0,0 +1,9 @@ +phase,author_id,label,median_ms,min_ms,max_ms,patent_count,median_author_load_ms,median_patent_search_ms,median_name_matching_ms,median_family_expansion_ms,median_classification_enrichment_ms,median_production_filter_ms,median_semantic_fallback_ms,median_identity_coauthor_loading_ms,median_identity_institution_loading_ms,median_identity_shared_works_ms,median_final_identity_guard_ms,median_response_build_ms +after,A5111380960,Thomas Kaiser A5111380960,13506.0,13315.8,13726.7,22,44.5,352.6,9.8,480.2,502.9,44.0,10026.1,752.1,6.1,98.1,168.4,0.0 +after,A5071644998,Thomas Kaiser A5071644998,12691.9,12562.5,12991.4,6,53.7,350.2,8.2,476.5,472.5,143.7,4301.3,670.0,4.6,2551.1,2554.7,0.0 +after,A5034365278,Dirk Schadendorf,3784.8,3702.8,4681.5,10,96.8,180.0,0.5,151.6,270.8,43.6,1425.6,86.7,5.3,677.2,703.3,0.0 +after,A5100603203,Christian Weber,15214.9,15148.6,15796.9,14,225.2,334.6,11.3,402.1,479.9,811.5,1815.7,824.0,7.8,3253.1,6042.3,0.0 +after,A5100373745,Xiaohong Chen,22966.5,22713.7,35727.0,12,384.1,680.7,41.6,183.6,416.9,1821.8,5520.8,426.5,28.0,4088.1,8781.1,0.0 +after,A5023982706,Richard Smith,20023.3,19755.0,20387.3,4,179.3,4674.8,139.7,403.9,395.1,300.0,6787.9,827.4,7.4,2345.8,3614.1,0.0 +after,A5023752156,Albert Sickmann,1572.9,1527.4,1795.2,5,87.9,175.0,0.4,147.5,229.2,6.7,551.1,67.9,2.2,103.4,91.0,0.0 +after,A5011059806,James Fulcher,1352.9,1323.8,1354.4,0,41.1,190.7,0.4,138.8,234.5,6.4,626.5,0.0,0.0,0.0,0.0,0.0 diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/performance_summary_before.csv b/service/scripts/patents/data/author_patent_evaluation/performance/performance_summary_before.csv new file mode 100644 index 00000000..884b56ea --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/performance_summary_before.csv @@ -0,0 +1,9 @@ +phase,author_id,label,median_ms,min_ms,max_ms,patent_count,median_author_load_ms,median_patent_search_ms,median_name_matching_ms,median_family_expansion_ms,median_classification_enrichment_ms,median_production_filter_ms,median_semantic_fallback_ms,median_identity_coauthor_loading_ms,median_identity_institution_loading_ms,median_identity_shared_works_ms,median_final_identity_guard_ms,median_response_build_ms +before,A5111380960,Thomas Kaiser A5111380960,19864.1,19775.4,20480.5,22,49.5,357.5,8.1,1903.8,518.3,1650.5,10076.8,5078.5,0.0,87.9,160.2,0.0 +before,A5071644998,Thomas Kaiser A5071644998,26417.3,24300.5,26873.6,6,49.2,359.4,8.9,2071.8,533.7,1780.0,11123.1,4318.1,0.1,2039.7,2769.4,0.0 +before,A5034365278,Dirk Schadendorf,5107.3,4972.2,13308.4,10,101.6,198.7,0.7,319.3,317.4,542.3,1510.1,347.9,0.3,798.6,893.6,0.0 +before,A5100603203,Christian Weber,32228.4,31464.3,45149.9,14,218.7,327.2,19.6,1981.0,580.7,2472.8,10398.1,5496.2,1.2,3363.7,6753.8,0.0 +before,A5100373745,Xiaohong Chen,23180.8,22684.7,116137.7,12,493.1,727.5,42.0,571.0,413.5,2895.7,5642.8,1633.4,3.5,1385.1,9272.2,0.0 +before,A5023982706,Richard Smith,27000.0,26956.3,34697.6,4,177.9,4469.5,117.8,1962.4,421.6,1225.8,6867.4,5877.1,0.4,2329.3,3671.2,0.0 +before,A5023752156,Albert Sickmann,2355.0,2211.4,3389.1,5,87.4,221.3,0.4,191.9,237.1,389.7,852.5,174.9,0.1,79.4,77.3,0.0 +before,A5011059806,James Fulcher,2787.5,2758.4,3362.1,0,46.7,200.1,0.4,198.9,226.7,430.8,1169.1,458.3,0.0,23.2,43.8,0.0 diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/query_counts.csv b/service/scripts/patents/data/author_patent_evaluation/performance/query_counts.csv new file mode 100644 index 00000000..48938dbd --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/query_counts.csv @@ -0,0 +1,17 @@ +phase,author_id,label,openalex,elasticsearch,epo,uspto,institution_alias,coauthor,shared_work,family +before,A5111380960,Thomas Kaiser A5111380960,91.67,171.67,67.00,1.00,0.33,88.33,0.00,67.00 +before,A5071644998,Thomas Kaiser A5071644998,97.33,177.33,67.00,1.00,12.67,81.00,0.67,67.00 +before,A5034365278,Dirk Schadendorf,72.00,86.00,7.00,1.00,60.67,8.33,0.00,7.00 +before,A5100603203,Christian Weber,201.67,277.67,64.00,1.00,81.67,116.00,1.00,64.00 +before,A5100373745,Xiaohong Chen,725.33,755.33,20.00,1.00,684.00,36.33,2.00,20.00 +before,A5023982706,Richard Smith,152.67,237.67,67.00,10.00,38.33,111.00,0.33,67.00 +before,A5023752156,Albert Sickmann,11.67,22.67,4.00,1.00,5.33,3.33,0.00,4.00 +before,A5011059806,James Fulcher,13.33,24.33,4.00,1.00,1.00,8.67,0.67,4.00 +after,A5111380960,Thomas Kaiser A5111380960,91.67,107.67,3.00,1.00,0.33,88.33,0.00,2.00 +after,A5071644998,Thomas Kaiser A5071644998,97.33,113.33,3.00,1.00,12.67,81.00,0.67,2.00 +after,A5034365278,Dirk Schadendorf,72.00,81.00,2.00,1.00,60.67,8.33,0.00,1.00 +after,A5100603203,Christian Weber,201.33,216.33,3.00,1.00,81.67,116.00,0.67,2.00 +after,A5100373745,Xiaohong Chen,725.00,738.00,3.00,1.00,684.00,36.33,1.67,1.00 +after,A5023982706,Richard Smith,152.67,173.67,3.00,10.00,38.33,111.00,0.33,2.00 +after,A5023752156,Albert Sickmann,11.67,20.67,2.00,1.00,5.33,3.33,0.00,1.00 +after,A5011059806,James Fulcher,3.00,12.00,2.00,1.00,0.00,0.00,0.00,1.00 diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/query_counts_after.csv b/service/scripts/patents/data/author_patent_evaluation/performance/query_counts_after.csv new file mode 100644 index 00000000..9b5ffe1a --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/query_counts_after.csv @@ -0,0 +1,9 @@ +phase,author_id,label,avg_openalex,avg_elasticsearch,avg_epo,avg_uspto,avg_institution_alias,avg_coauthor,avg_shared_work,avg_family +after,A5111380960,Thomas Kaiser A5111380960,91.67,107.67,3.00,1.00,0.33,88.33,0.00,2.00 +after,A5071644998,Thomas Kaiser A5071644998,97.33,113.33,3.00,1.00,12.67,81.00,0.67,2.00 +after,A5034365278,Dirk Schadendorf,72.00,81.00,2.00,1.00,60.67,8.33,0.00,1.00 +after,A5100603203,Christian Weber,201.33,216.33,3.00,1.00,81.67,116.00,0.67,2.00 +after,A5100373745,Xiaohong Chen,725.00,738.00,3.00,1.00,684.00,36.33,1.67,1.00 +after,A5023982706,Richard Smith,152.67,173.67,3.00,10.00,38.33,111.00,0.33,2.00 +after,A5023752156,Albert Sickmann,11.67,20.67,2.00,1.00,5.33,3.33,0.00,1.00 +after,A5011059806,James Fulcher,3.00,12.00,2.00,1.00,0.00,0.00,0.00,1.00 diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/query_counts_before.csv b/service/scripts/patents/data/author_patent_evaluation/performance/query_counts_before.csv new file mode 100644 index 00000000..64d06971 --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/query_counts_before.csv @@ -0,0 +1,9 @@ +phase,author_id,label,avg_openalex,avg_elasticsearch,avg_epo,avg_uspto,avg_institution_alias,avg_coauthor,avg_shared_work,avg_family +before,A5111380960,Thomas Kaiser A5111380960,91.67,171.67,67.00,1.00,0.33,88.33,0.00,67.00 +before,A5071644998,Thomas Kaiser A5071644998,97.33,177.33,67.00,1.00,12.67,81.00,0.67,67.00 +before,A5034365278,Dirk Schadendorf,72.00,86.00,7.00,1.00,60.67,8.33,0.00,7.00 +before,A5100603203,Christian Weber,201.67,277.67,64.00,1.00,81.67,116.00,1.00,64.00 +before,A5100373745,Xiaohong Chen,725.33,755.33,20.00,1.00,684.00,36.33,2.00,20.00 +before,A5023982706,Richard Smith,152.67,237.67,67.00,10.00,38.33,111.00,0.33,67.00 +before,A5023752156,Albert Sickmann,11.67,22.67,4.00,1.00,5.33,3.33,0.00,4.00 +before,A5011059806,James Fulcher,13.33,24.33,4.00,1.00,1.00,8.67,0.67,4.00 diff --git a/service/scripts/patents/data/author_patent_evaluation/performance/regression_comparison.json b/service/scripts/patents/data/author_patent_evaluation/performance/regression_comparison.json new file mode 100644 index 00000000..b9be0981 --- /dev/null +++ b/service/scripts/patents/data/author_patent_evaluation/performance/regression_comparison.json @@ -0,0 +1,262 @@ +{ + "patent_ids_identical": true, + "counts_identical": true, + "decisions_identical": true, + "decision_reasons_identical": true, + "candidate_metrics_identical": true, + "family_metrics_identical": true, + "authors": [ + { + "author_id": "A5111380960", + "label": "Thomas Kaiser A5111380960", + "before_median_ms": 19864.066399997682, + "after_median_ms": 13506.049799994798, + "improvement": 0.32007628609233935, + "patent_ids_identical": true, + "counts_identical": true, + "before_query_average": { + "openalex": 91.66666666666667, + "elasticsearch": 171.66666666666666, + "epo": 67.0, + "uspto": 1.0, + "institution_alias": 0.3333333333333333, + "coauthor": 88.33333333333333, + "shared_work": 0.0, + "family": 67.0 + }, + "after_query_average": { + "openalex": 91.66666666666667, + "elasticsearch": 107.66666666666667, + "epo": 3.0, + "uspto": 1.0, + "institution_alias": 0.3333333333333333, + "coauthor": 88.33333333333333, + "shared_work": 0.0, + "family": 2.0 + } + }, + { + "author_id": "A5071644998", + "label": "Thomas Kaiser A5071644998", + "before_median_ms": 26417.263499999535, + "after_median_ms": 12691.947600003914, + "improvement": 0.5195585795627872, + "patent_ids_identical": true, + "counts_identical": true, + "before_query_average": { + "openalex": 97.33333333333333, + "elasticsearch": 177.33333333333334, + "epo": 67.0, + "uspto": 1.0, + "institution_alias": 12.666666666666666, + "coauthor": 81.0, + "shared_work": 0.6666666666666666, + "family": 67.0 + }, + "after_query_average": { + "openalex": 97.33333333333333, + "elasticsearch": 113.33333333333333, + "epo": 3.0, + "uspto": 1.0, + "institution_alias": 12.666666666666666, + "coauthor": 81.0, + "shared_work": 0.6666666666666666, + "family": 2.0 + } + }, + { + "author_id": "A5034365278", + "label": "Dirk Schadendorf", + "before_median_ms": 5107.349099998828, + "after_median_ms": 3784.8194999969564, + "improvement": 0.25894638766756223, + "patent_ids_identical": true, + "counts_identical": true, + "before_query_average": { + "openalex": 72.0, + "elasticsearch": 86.0, + "epo": 7.0, + "uspto": 1.0, + "institution_alias": 60.666666666666664, + "coauthor": 8.333333333333334, + "shared_work": 0.0, + "family": 7.0 + }, + "after_query_average": { + "openalex": 72.0, + "elasticsearch": 81.0, + "epo": 2.0, + "uspto": 1.0, + "institution_alias": 60.666666666666664, + "coauthor": 8.333333333333334, + "shared_work": 0.0, + "family": 1.0 + } + }, + { + "author_id": "A5100603203", + "label": "Christian Weber", + "before_median_ms": 32228.38679999404, + "after_median_ms": 15214.901899991673, + "improvement": 0.5279037081683999, + "patent_ids_identical": true, + "counts_identical": true, + "before_query_average": { + "openalex": 201.66666666666666, + "elasticsearch": 277.6666666666667, + "epo": 64.0, + "uspto": 1.0, + "institution_alias": 81.66666666666667, + "coauthor": 116.0, + "shared_work": 1.0, + "family": 64.0 + }, + "after_query_average": { + "openalex": 201.33333333333334, + "elasticsearch": 216.33333333333334, + "epo": 3.0, + "uspto": 1.0, + "institution_alias": 81.66666666666667, + "coauthor": 116.0, + "shared_work": 0.6666666666666666, + "family": 2.0 + } + }, + { + "author_id": "A5100373745", + "label": "Xiaohong Chen", + "before_median_ms": 23180.76750000182, + "after_median_ms": 22966.470500003197, + "improvement": 0.009244603311715484, + "patent_ids_identical": true, + "counts_identical": true, + "before_query_average": { + "openalex": 725.3333333333334, + "elasticsearch": 755.3333333333334, + "epo": 20.0, + "uspto": 1.0, + "institution_alias": 684.0, + "coauthor": 36.333333333333336, + "shared_work": 2.0, + "family": 20.0 + }, + "after_query_average": { + "openalex": 725.0, + "elasticsearch": 738.0, + "epo": 3.0, + "uspto": 1.0, + "institution_alias": 684.0, + "coauthor": 36.333333333333336, + "shared_work": 1.6666666666666667, + "family": 1.0 + } + }, + { + "author_id": "A5023982706", + "label": "Richard Smith", + "before_median_ms": 27000.009199997294, + "after_median_ms": 20023.3070999966, + "improvement": 0.25839628602798376, + "patent_ids_identical": true, + "counts_identical": true, + "before_query_average": { + "openalex": 152.66666666666666, + "elasticsearch": 237.66666666666666, + "epo": 67.0, + "uspto": 10.0, + "institution_alias": 38.333333333333336, + "coauthor": 111.0, + "shared_work": 0.3333333333333333, + "family": 67.0 + }, + "after_query_average": { + "openalex": 152.66666666666666, + "elasticsearch": 173.66666666666666, + "epo": 3.0, + "uspto": 10.0, + "institution_alias": 38.333333333333336, + "coauthor": 111.0, + "shared_work": 0.3333333333333333, + "family": 2.0 + } + }, + { + "author_id": "A5023752156", + "label": "Albert Sickmann", + "before_median_ms": 2354.960199998459, + "after_median_ms": 1572.8591000079177, + "improvement": 0.332107990611074, + "patent_ids_identical": true, + "counts_identical": true, + "before_query_average": { + "openalex": 11.666666666666666, + "elasticsearch": 22.666666666666668, + "epo": 4.0, + "uspto": 1.0, + "institution_alias": 5.333333333333333, + "coauthor": 3.3333333333333335, + "shared_work": 0.0, + "family": 4.0 + }, + "after_query_average": { + "openalex": 11.666666666666666, + "elasticsearch": 20.666666666666668, + "epo": 2.0, + "uspto": 1.0, + "institution_alias": 5.333333333333333, + "coauthor": 3.3333333333333335, + "shared_work": 0.0, + "family": 1.0 + } + }, + { + "author_id": "A5011059806", + "label": "James Fulcher", + "before_median_ms": 2787.5115999922855, + "after_median_ms": 1352.909199995338, + "improvement": 0.5146534278102799, + "patent_ids_identical": true, + "counts_identical": true, + "before_query_average": { + "openalex": 13.333333333333334, + "elasticsearch": 24.333333333333332, + "epo": 4.0, + "uspto": 1.0, + "institution_alias": 1.0, + "coauthor": 8.666666666666666, + "shared_work": 0.6666666666666666, + "family": 4.0 + }, + "after_query_average": { + "openalex": 3.0, + "elasticsearch": 12.0, + "epo": 2.0, + "uspto": 1.0, + "institution_alias": 0.0, + "coauthor": 0.0, + "shared_work": 0.0, + "family": 1.0 + } + } + ], + "average_query_count_before": { + "openalex": 170.70833333333334, + "elasticsearch": 219.08333333333334, + "epo": 37.5, + "uspto": 2.125, + "institution_alias": 110.5, + "coauthor": 56.625, + "shared_work": 0.5833333333333334, + "family": 37.5 + }, + "average_query_count_after": { + "openalex": 169.33333333333334, + "elasticsearch": 182.83333333333334, + "epo": 2.625, + "uspto": 2.125, + "institution_alias": 110.375, + "coauthor": 55.541666666666664, + "shared_work": 0.4166666666666667, + "family": 1.5 + } +} diff --git a/service/src/main/inse/patents/authors/ambiguous_author_identity_guard_v2.py b/service/src/main/inse/patents/authors/ambiguous_author_identity_guard_v2.py index 749c9535..7d1be2ee 100644 --- a/service/src/main/inse/patents/authors/ambiguous_author_identity_guard_v2.py +++ b/service/src/main/inse/patents/authors/ambiguous_author_identity_guard_v2.py @@ -10,6 +10,7 @@ Helper library for the final identity guard. Not a runtime entry point. """ from __future__ import annotations +import asyncio import logging import re from dataclasses import dataclass @@ -952,6 +953,7 @@ async def load_openalex_works_coauthor_names( already_full_surnames.add(normalize_name_part(parsed_known.last_name)) queried_surnames: set[str] = set() + surnames_to_query: list[str] = [] for inventor in inventor_hints: parsed = parse_inventor_name(strip_titles_anywhere(inventor)) last = parsed.last_name if parsed is not None else inventor @@ -961,6 +963,9 @@ async def load_openalex_works_coauthor_names( if last_norm in already_full_surnames or last_norm in queried_surnames: continue queried_surnames.add(last_norm) + surnames_to_query.append(last) + + async def _lookup_surname(last: str) -> list[str]: body = { "size": 8, "_source": ["authorships.author.display_name", "authorships.author.id"], @@ -983,6 +988,7 @@ async def load_openalex_works_coauthor_names( } }, } + found: list[str] = [] try: response = await elasticsearch.search( index=ESIndex.OPENALEX_WORKS_WILDCARD, @@ -999,9 +1005,23 @@ async def load_openalex_works_coauthor_names( continue if normalize_name_part(other.last_name) != normalize_name_part(last): continue - names.append(name) + found.append(name) except Exception: logger.exception("OpenAlex targeted coauthor lookup failed for %s / %s", key, last) + return found + + if surnames_to_query: + semaphore = asyncio.Semaphore(8) + + async def _limited(last: str) -> list[str]: + async with semaphore: + return await _lookup_surname(last) + + extra_groups = await asyncio.gather( + *(_limited(last) for last in surnames_to_query) + ) + for extra_names in extra_groups: + names.extend(extra_names) store_openalex_works_coauthors(key, names) return cached_openalex_works_coauthors(key) @@ -1048,11 +1068,25 @@ async def load_author_institution_aliases(author: Author) -> dict[str, Instituti if inst is not None: institutions.append(inst) seen: set[str] = set() + keys_and_ids: list[tuple[str, str]] = [] for institution in institutions: inst_id = getattr(institution, "id", None) key = _author_id_key(inst_id) if not key or key in seen: continue seen.add(key) - mapping[key] = await load_institution_alias_record(inst_id) + keys_and_ids.append((key, inst_id)) + if not keys_and_ids: + return mapping + semaphore = asyncio.Semaphore(8) + + async def _load(inst_id: str) -> InstitutionAliasRecord: + async with semaphore: + return await load_institution_alias_record(inst_id) + + records = await asyncio.gather( + *(_load(inst_id) for _key, inst_id in keys_and_ids) + ) + for (key, _inst_id), record in zip(keys_and_ids, records): + mapping[key] = record return mapping diff --git a/service/src/main/inse/patents/authors/final_ambiguous_author_identity_guard.py b/service/src/main/inse/patents/authors/final_ambiguous_author_identity_guard.py index ae32dd6a..88448671 100644 --- a/service/src/main/inse/patents/authors/final_ambiguous_author_identity_guard.py +++ b/service/src/main/inse/patents/authors/final_ambiguous_author_identity_guard.py @@ -42,6 +42,7 @@ Enable: ``ENABLE_AMBIGUOUS_AUTHOR_IDENTITY_GUARD``. """ from __future__ import annotations +import asyncio import logging import re from dataclasses import dataclass, field @@ -156,6 +157,24 @@ def is_final_identity_guard_enabled() -> bool: return bool(getattr(settings, "enable_ambiguous_author_identity_guard", False)) +def identity_evidence_io_required( + *, + is_ambiguous: bool, + production_kept: Sequence[TopicFilterResult], + combined_kept: Sequence[TopicFilterResult], +) -> bool: + """True only when identity queries can change the returned patent set. + + Unique authors keep every combined keep. Production KEEP is never dropped. + Identity I/O is therefore needed only for ambiguous authors that have + semantic additions to confirm or reject. + """ + if not is_ambiguous: + return False + production_keys = {patent_map_key(item.patent) for item in production_kept} + return any(patent_map_key(item.patent) not in production_keys for item in combined_kept) + + def reset_identity_guard_query_stats() -> None: for key in _QUERY_STATS: _QUERY_STATS[key] = 0 @@ -906,28 +925,67 @@ async def load_author_institution_aliases(author: Author) -> dict[str, Instituti return await _load_author_institution_aliases_v2(author) +def _patent_needs_shared_works_lookup( + patent: model.PatentEntry, + author: Author, + coauthor_names: Sequence[str], + alias_by_id: Mapping[str, InstitutionAliasRecord] | None = None, +) -> bool: + """Mirrors evaluate()'s second loop: shared works are consulted only then.""" + extras = inventor_unattested_extra_given_names_v2(patent, author) + if extras: + return False + confirmed = _confirmed_coauthors( + patent, author.display_name or "", coauthor_names + ) + if len(confirmed) != 1: + return False + if _personal_identity_supported(patent, author, extras): + return False + inst = classify_robust_institution_match_final( + patent, author, alias_by_id=alias_by_id + ) + if _institution_is_strong(inst): + return False + return True + + async def prefetch_shared_works_for_identity_guard( author_id: str, patents: Sequence[model.PatentEntry], author: Author, coauthor_names: Sequence[str], + *, + institution_alias_by_id: Mapping[str, InstitutionAliasRecord] | None = None, ) -> dict[str, CoauthorWorkContext]: - """Load shared-work context once per confirmed coauthor. Cached per author.""" - display = author.display_name or "" + """Load shared-work context once per confirmed coauthor that evaluate() would look up.""" mapping: dict[str, CoauthorWorkContext] = {} + names: list[str] = [] seen: set[str] = set() for patent in patents: - if inventor_unattested_extra_given_names_v2(patent, author): - continue - confirmed = _confirmed_coauthors(patent, display, coauthor_names) - if len(confirmed) != 1: + if not _patent_needs_shared_works_lookup( + patent, + author, + coauthor_names, + alias_by_id=institution_alias_by_id, + ): continue + confirmed = _confirmed_coauthors( + patent, author.display_name or "", coauthor_names + ) name = confirmed[0] folded = name.casefold() if folded in seen: continue seen.add(folded) - mapping[name] = await load_shared_works_context(author_id, name) + names.append(name) + if not names: + return mapping + contexts = await asyncio.gather( + *(load_shared_works_context(author_id, name) for name in names) + ) + for name, context in zip(names, contexts): + mapping[name] = context return mapping diff --git a/service/src/main/inse/patents/authors/logic.py b/service/src/main/inse/patents/authors/logic.py index 3c67243d..71ef53ca 100644 --- a/service/src/main/inse/patents/authors/logic.py +++ b/service/src/main/inse/patents/authors/logic.py @@ -1,4 +1,5 @@ """Business logic for patent lookup by inventor.""" +import asyncio import logging import httpx @@ -12,11 +13,13 @@ from inse.patents.authors.name_variants import parse_person_name from inse.patents.authors.search_pagination import search_author_patents_adaptive from inse.patents.authors.final_ambiguous_author_identity_guard import ( apply_production_with_semantic_fallback_v1_and_final_identity_guard, + identity_evidence_io_required, is_final_identity_guard_enabled, load_author_institution_aliases, load_openalex_works_coauthor_names, prefetch_shared_works_for_identity_guard, ) +from inse.patents.authors.pipeline_perf import mark_zero, stage from inse.patents.authors.semantic_topic_fallback import ( apply_production_with_semantic_fallback_v1, is_semantic_topic_fallback_enabled, @@ -37,6 +40,29 @@ from inse.persons import logic as person_logic logger = logging.getLogger(__name__) +_IDENTITY_STAGES = ( + "identity_coauthor_loading", + "identity_institution_loading", + "identity_shared_works", + "final_identity_guard", +) + + +def _inventor_hints_from_patents(patents: list[model.PatentEntry]) -> list[str]: + hints: list[str] = [] + seen: set[str] = set() + for patent in patents: + for inventor in patent.inventors or []: + if not inventor: + continue + folded = inventor.casefold() + if folded in seen: + continue + seen.add(folded) + hints.append(inventor) + return hints + + async def get_patents_by_author_id( author_id: str, client: PatentSearchClient | None = None, @@ -45,171 +71,229 @@ async def get_patents_by_author_id( search_client = client or PatentSearchClient() ipc_search_client = ipc_client or IpcSearchClient() - author = await _get_author(author_id) - if not author: - return model.PatentsByAuthorResponse( - author_id=author_id, - author_name=None, - patent_count=0, - patents=[], - ) - - author_name = author.display_name - if not author_name or not author_name.strip(): - return model.PatentsByAuthorResponse( - author_id=author_id, - author_name=author_name, - patent_count=0, - patents=[], - ) - - try: - search_result = await search_author_patents_adaptive( - search_client, author_name - ) - except MissingApiKeyError as exc: - raise HTTPException( - status_code=HTTP_503_SERVICE_UNAVAILABLE, - detail="Patent search is not configured.", - ) from exc - except httpx.HTTPError as exc: - raise HTTPException( - status_code=HTTP_502_BAD_GATEWAY, - detail="Patent search request failed.", - ) from exc - - all_patents = search_result.patents - patent_hit_count = len(all_patents) - if search_result.completeness.value == "truncated_inconclusive": - # Unread ES hits remain; zero UI patents must not be treated as proof - # that the author has no patents in the index. - logger.warning( - "search_completeness=%s for author %s (%s): epo_scanned=%d/%d " - "uspto_scanned=%d/%d stop=%s/%s strong_matches=%d/%d", - search_result.completeness.value, - author_id, - author_name, - search_result.epo.hits_scanned, - search_result.epo.total_hits, - search_result.uspto.hits_scanned, - search_result.uspto.total_hits, - search_result.epo.stop_reason, - search_result.uspto.stop_reason, - search_result.epo.strong_name_match_count, - search_result.uspto.strong_name_match_count, - ) - matched_patents = filter_patents_by_author_name(all_patents, author_name) - try: - matched_patents = await expand_matched_epo_application_families( - matched_patents, - search_client, - ) - except Exception: - logger.exception( - "EPO family expansion failed for %s; continuing with name-matched patents only", - author_name, - ) - - if not matched_patents: - return model.PatentsByAuthorResponse( - author_id=author_id, - author_name=author_name, - patent_count=0, - patents=[], - ) - - await enrich_patents_classifications(matched_patents, ipc_search_client) - - full_name_count = await person_logic.count_authors_by_display_name(author_name) - parsed_for_last = parse_person_name(author_name) - last_name_count: int | None = None - if parsed_for_last and not parsed_for_last.is_single_token: - last_name_count = await person_logic.count_authors_by_last_name( - parsed_for_last.last_name - ) - is_ambiguous = is_ambiguous_name( - author_name, - patent_hit_count=patent_hit_count, - openalex_full_name_count=full_name_count, - openalex_last_name_count=last_name_count, - ) - - patent_topic_map = None - try: - resolver = PatentOpenAlexMappingResolver() - patent_topic_map = await resolver.resolve_topics_for_patents(matched_patents) - except Exception: - logger.exception( - "OpenAlex topic resolution failed for %s; falling back to legacy mapping", - author_name, - ) - - production_kept = filter_patents_by_ipc_topic_mapping( - matched_patents, - author, - is_ambiguous=is_ambiguous, - patent_topic_map=patent_topic_map, - ) - filtered = production_kept - if is_semantic_topic_fallback_enabled(): - filtered = apply_production_with_semantic_fallback_v1( - name_matched_patents=matched_patents, - production_kept=production_kept, - author=author, - patent_topic_map=patent_topic_map, - ) - if is_final_identity_guard_enabled(): - coauthors: tuple[str, ...] = () - aliases: dict = {} - shared = None - if is_ambiguous: - inventor_hints = [] - seen_inventors: set[str] = set() - for patent in matched_patents: - for inventor in patent.inventors or []: - if not inventor: - continue - folded = inventor.casefold() - if folded in seen_inventors: - continue - seen_inventors.add(folded) - inventor_hints.append(inventor) - coauthors = await load_openalex_works_coauthor_names( - author_id, - inventor_hints=inventor_hints, + with stage("total"): + with stage("author_load"): + author = await _get_author(author_id) + if not author: + mark_zero( + "patent_search", + "name_matching", + "family_expansion", + "classification_enrichment", + "production_filter", + "semantic_fallback", + *_IDENTITY_STAGES, + "response_build", ) - aliases = await load_author_institution_aliases(author) - shared = await prefetch_shared_works_for_identity_guard( + return model.PatentsByAuthorResponse( + author_id=author_id, + author_name=None, + patent_count=0, + patents=[], + ) + + author_name = author.display_name + if not author_name or not author_name.strip(): + mark_zero( + "patent_search", + "name_matching", + "family_expansion", + "classification_enrichment", + "production_filter", + "semantic_fallback", + *_IDENTITY_STAGES, + "response_build", + ) + return model.PatentsByAuthorResponse( + author_id=author_id, + author_name=author_name, + patent_count=0, + patents=[], + ) + + try: + with stage("patent_search"): + search_result = await search_author_patents_adaptive( + search_client, author_name + ) + except MissingApiKeyError as exc: + raise HTTPException( + status_code=HTTP_503_SERVICE_UNAVAILABLE, + detail="Patent search is not configured.", + ) from exc + except httpx.HTTPError as exc: + raise HTTPException( + status_code=HTTP_502_BAD_GATEWAY, + detail="Patent search request failed.", + ) from exc + + all_patents = search_result.patents + patent_hit_count = len(all_patents) + if search_result.completeness.value == "truncated_inconclusive": + # Unread ES hits remain; zero UI patents must not be treated as proof + # that the author has no patents in the index. + logger.warning( + "search_completeness=%s for author %s (%s): epo_scanned=%d/%d " + "uspto_scanned=%d/%d stop=%s/%s strong_matches=%d/%d", + search_result.completeness.value, author_id, + author_name, + search_result.epo.hits_scanned, + search_result.epo.total_hits, + search_result.uspto.hits_scanned, + search_result.uspto.total_hits, + search_result.epo.stop_reason, + search_result.uspto.stop_reason, + search_result.epo.strong_name_match_count, + search_result.uspto.strong_name_match_count, + ) + with stage("name_matching"): + matched_patents = filter_patents_by_author_name(all_patents, author_name) + try: + with stage("family_expansion"): + matched_patents = await expand_matched_epo_application_families( + matched_patents, + search_client, + ) + except Exception: + logger.exception( + "EPO family expansion failed for %s; continuing with name-matched patents only", + author_name, + ) + + if not matched_patents: + mark_zero( + "classification_enrichment", + "production_filter", + "semantic_fallback", + *_IDENTITY_STAGES, + "response_build", + ) + return model.PatentsByAuthorResponse( + author_id=author_id, + author_name=author_name, + patent_count=0, + patents=[], + ) + + async def _enrich_classifications() -> None: + with stage("classification_enrichment"): + await enrich_patents_classifications(matched_patents, ipc_search_client) + + async def _count_last_name() -> int | None: + parsed_for_last = parse_person_name(author_name) + if parsed_for_last and not parsed_for_last.is_single_token: + return await person_logic.count_authors_by_last_name( + parsed_for_last.last_name + ) + return None + + async def _resolve_topics(): + try: + resolver = PatentOpenAlexMappingResolver() + return await resolver.resolve_topics_for_patents(matched_patents) + except Exception: + logger.exception( + "OpenAlex topic resolution failed for %s; falling back to legacy mapping", + author_name, + ) + return None + + _, full_name_count, last_name_count, patent_topic_map = await asyncio.gather( + _enrich_classifications(), + person_logic.count_authors_by_display_name(author_name), + _count_last_name(), + _resolve_topics(), + ) + + with stage("production_filter"): + is_ambiguous = is_ambiguous_name( + author_name, + patent_hit_count=patent_hit_count, + openalex_full_name_count=full_name_count, + openalex_last_name_count=last_name_count, + ) + production_kept = filter_patents_by_ipc_topic_mapping( matched_patents, author, - coauthors, + is_ambiguous=is_ambiguous, + patent_topic_map=patent_topic_map, ) - filtered = apply_production_with_semantic_fallback_v1_and_final_identity_guard( - name_matched_patents=matched_patents, - production_kept=production_kept, - combined_kept=filtered, - author=author, - is_ambiguous=is_ambiguous, - openalex_coauthor_names=coauthors, - institution_alias_by_id=aliases, - shared_works_by_coauthor=shared, + filtered = production_kept + with stage("semantic_fallback"): + if is_semantic_topic_fallback_enabled(): + filtered = apply_production_with_semantic_fallback_v1( + name_matched_patents=matched_patents, + production_kept=production_kept, + author=author, + patent_topic_map=patent_topic_map, + ) + if is_final_identity_guard_enabled(): + coauthors: tuple[str, ...] = () + aliases: dict = {} + shared = None + if identity_evidence_io_required( + is_ambiguous=is_ambiguous, + production_kept=production_kept, + combined_kept=filtered, + ): + inventor_hints = _inventor_hints_from_patents(matched_patents) + + async def _load_coauthors() -> tuple[str, ...]: + with stage("identity_coauthor_loading"): + return await load_openalex_works_coauthor_names( + author_id, + inventor_hints=inventor_hints, + ) + + async def _load_aliases(): + with stage("identity_institution_loading"): + return await load_author_institution_aliases(author) + + coauthors, aliases = await asyncio.gather( + _load_coauthors(), + _load_aliases(), + ) + with stage("identity_shared_works"): + shared = await prefetch_shared_works_for_identity_guard( + author_id, + matched_patents, + author, + coauthors, + institution_alias_by_id=aliases, + ) + with stage("final_identity_guard"): + filtered = apply_production_with_semantic_fallback_v1_and_final_identity_guard( + name_matched_patents=matched_patents, + production_kept=production_kept, + combined_kept=filtered, + author=author, + is_ambiguous=is_ambiguous, + openalex_coauthor_names=coauthors, + institution_alias_by_id=aliases, + shared_works_by_coauthor=shared, + ) + else: + mark_zero(*_IDENTITY_STAGES) + else: + mark_zero(*_IDENTITY_STAGES) + + logger.info( + "patents_openalex_keywords mapping for %s: ambiguous=%s, %d name-matched, %d after topic filter", + author_name, + is_ambiguous, + len(matched_patents), + len(filtered), ) - logger.info( - "patents_openalex_keywords mapping for %s: ambiguous=%s, %d name-matched, %d after topic filter", - author_name, - is_ambiguous, - len(matched_patents), - len(filtered), - ) - - return model.PatentsByAuthorResponse( - author_id=author_id, - author_name=author_name, - patent_count=len(filtered), - patents=[item.patent for item in filtered], - ) + with stage("response_build"): + response = model.PatentsByAuthorResponse( + author_id=author_id, + author_name=author_name, + patent_count=len(filtered), + patents=[item.patent for item in filtered], + ) + return response async def _get_author(author_id: str) -> Author | None: short_id = author_id.replace("https://openalex.org/", "") diff --git a/service/src/main/inse/patents/authors/pipeline_perf.py b/service/src/main/inse/patents/authors/pipeline_perf.py new file mode 100644 index 00000000..02ffc8af --- /dev/null +++ b/service/src/main/inse/patents/authors/pipeline_perf.py @@ -0,0 +1,71 @@ +"""Request-scoped pipeline timing/query counters for benchmarks. + +Inactive unless a benchmark (or test) enters ``capture_pipeline_perf``. +Does not appear in API responses. +""" +from __future__ import annotations + +import time +from contextlib import contextmanager +from contextvars import ContextVar +from dataclasses import dataclass, field +from typing import Iterator + + +@dataclass +class PipelinePerf: + timings_ms: dict[str, float] = field(default_factory=dict) + queries: dict[str, int] = field(default_factory=dict) + cache_hits: dict[str, int] = field(default_factory=dict) + extras: dict[str, object] = field(default_factory=dict) + + def add_query(self, kind: str, n: int = 1) -> None: + self.queries[kind] = int(self.queries.get(kind, 0)) + n + + def add_cache_hit(self, kind: str, n: int = 1) -> None: + self.cache_hits[kind] = int(self.cache_hits.get(kind, 0)) + n + + +_PERF: ContextVar[PipelinePerf | None] = ContextVar("author_patent_pipeline_perf", default=None) + + +def current_perf() -> PipelinePerf | None: + return _PERF.get() + + +@contextmanager +def capture_pipeline_perf() -> Iterator[PipelinePerf]: + perf = PipelinePerf() + token = _PERF.set(perf) + try: + yield perf + finally: + _PERF.reset(token) + + +def mark_zero(*names: str) -> None: + perf = current_perf() + if perf is None: + return + for name in names: + perf.timings_ms.setdefault(name, 0.0) + + +class StageTimer: + def __init__(self, name: str) -> None: + self.name = name + self._t0 = 0.0 + + def __enter__(self) -> StageTimer: + self._t0 = time.perf_counter() + return self + + def __exit__(self, *args: object) -> None: + perf = current_perf() + if perf is None: + return + perf.timings_ms[self.name] = (time.perf_counter() - self._t0) * 1000.0 + + +def stage(name: str) -> StageTimer: + return StageTimer(name) diff --git a/service/src/main/inse/patents/authors/search_queries.py b/service/src/main/inse/patents/authors/search_queries.py index 436169b2..26937c20 100644 --- a/service/src/main/inse/patents/authors/search_queries.py +++ b/service/src/main/inse/patents/authors/search_queries.py @@ -1,5 +1,5 @@ """Elasticsearch query builders for inventor-based patent search.""" -from typing import Any +from typing import Any, Sequence from inse.patents.authors.name_matching import ( inventor_search_phrases, @@ -203,17 +203,31 @@ class InventorSearchQueries: application_number: str, size: int = 20, ) -> dict[str, Any]: - variants = _application_number_variants(application_number) - if not variants: + return self.epo_query_by_application_numbers([application_number], size_per_number=size) + + def epo_query_by_application_numbers( + self, + application_numbers: Sequence[str], + size_per_number: int = 20, + ) -> dict[str, Any]: + should: list[dict[str, Any]] = [] + seen: set[str] = set() + numbers = [str(number).strip() for number in application_numbers if str(number).strip()] + for number in numbers: + for variant in _application_number_variants(number): + if variant in seen: + continue + seen.add(variant) + should.append({"term": {"application_number": variant}}) + if not should: return {"size": 0, "query": {"match_none": {}}} - should = [{"term": {"application_number": variant}} for variant in variants] query: dict[str, Any] = ( should[0] if len(should) == 1 else {"bool": {"should": should, "minimum_should_match": 1}} ) - + size = min(max(size_per_number * max(len(numbers), 1), size_per_number), 5000) return { "size": size, "track_total_hits": True, @@ -310,3 +324,9 @@ def _application_number_variants(application_number: str) -> list[str]: if cleaned.upper().startswith("EP"): _add(cleaned[2:]) return variants + + +def application_numbers_equivalent(left: str | None, right: str | None) -> bool: + if not left or not right: + return False + return bool(set(_application_number_variants(left)) & set(_application_number_variants(right))) diff --git a/service/src/main/inse/patents/authors/semantic_topic_fallback.py b/service/src/main/inse/patents/authors/semantic_topic_fallback.py index 9424a258..6ef90f9d 100644 --- a/service/src/main/inse/patents/authors/semantic_topic_fallback.py +++ b/service/src/main/inse/patents/authors/semantic_topic_fallback.py @@ -36,7 +36,9 @@ from inse.patents.authors.semantic_topic_fallback_v1_frozen import ( SEMANTIC_FALLBACK_DEFAULT_THRESHOLD, SEMANTIC_FALLBACK_MODEL_NAME, _build_semantic_vectors, + _exact_topic_or_subfield_match, _pairwise_best_semantic_similarity, + _semantic_domain_conflict, decide_semantic_topic_fallback_v1, ) from inse.patents.authors.topic_filter import TopicFilterResult @@ -129,7 +131,14 @@ def _semantic_fallback_keeps( vectors: dict[str, Any] = {} if similarity_fn is None: - vectors = _build_semantic_vectors([cand for _patent, cand in candidates]) + need_similarity = [ + cand + for _patent, cand in candidates + if not _exact_topic_or_subfield_match(cand) + and not _semantic_domain_conflict(cand)[0] + ] + if need_similarity: + vectors = _build_semantic_vectors(need_similarity) keeps: list[TopicFilterResult] = [] for patent, cand in candidates: diff --git a/service/src/main/inse/patents/authors/test_final_ambiguous_author_identity_guard.py b/service/src/main/inse/patents/authors/test_final_ambiguous_author_identity_guard.py index 7b786346..b2dd44b3 100644 --- a/service/src/main/inse/patents/authors/test_final_ambiguous_author_identity_guard.py +++ b/service/src/main/inse/patents/authors/test_final_ambiguous_author_identity_guard.py @@ -768,3 +768,83 @@ def test_topic_signals_are_not_identity_evidence() -> None: source_mod = inspect.getsource(guard_final) assert "semantic_similarity" not in source_mod assert "evaluation_field" not in source_mod + + +def test_identity_io_required_only_for_ambiguous_semantic_additions() -> None: + production_patent = _patent("EP-PROD") + semantic_patent = _patent("EP-SEM") + production = [_keep(production_patent, "strict_topic_match")] + combined = [ + _keep(production_patent, "strict_topic_match"), + _keep(semantic_patent, "semantic_topic_fallback_v1"), + ] + assert ( + guard_final.identity_evidence_io_required( + is_ambiguous=False, + production_kept=production, + combined_kept=combined, + ) + is False + ) + assert ( + guard_final.identity_evidence_io_required( + is_ambiguous=True, + production_kept=production, + combined_kept=production, + ) + is False + ) + assert ( + guard_final.identity_evidence_io_required( + is_ambiguous=True, + production_kept=production, + combined_kept=combined, + ) + is True + ) + + +def test_prefetch_skips_patents_evaluate_would_not_lookup(monkeypatch) -> None: + import asyncio + + calls: list[str] = [] + + async def fake_load(author_id: str, name: str): + calls.append(name) + return CoauthorWorkContext( + coauthor_name=name, + shared_work_count=4, + distinct_years=(2010, 2012), + institution_names=("University of Example",), + ) + + monkeypatch.setattr(guard_final, "load_shared_works_context", fake_load) + author = _author(last_known=["University of Duisburg-Essen"]) + strong = _patent( + "EP-STRONG", + inventors=["Hale, Jordan", "Herzinger, Stefan"], + assignees=["Universität Duisburg-Essen"], + ) + weak = _patent( + "EP-WEAK", + inventors=["Hale, Jordan", "Herzinger, Stefan"], + assignees=[], + ) + asyncio.run( + guard_final.prefetch_shared_works_for_identity_guard( + "A100", + [strong], + author, + ["Stefan Herzinger"], + ) + ) + assert calls == [] + asyncio.run( + guard_final.prefetch_shared_works_for_identity_guard( + "A100", + [weak], + author, + ["Stefan Herzinger"], + ) + ) + assert calls == ["Herzinger, Stefan"] diff --git a/service/src/main/inse/patents/authors/test_semantic_topic_fallback.py b/service/src/main/inse/patents/authors/test_semantic_topic_fallback.py index 63f8302e..5373ea4f 100644 --- a/service/src/main/inse/patents/authors/test_semantic_topic_fallback.py +++ b/service/src/main/inse/patents/authors/test_semantic_topic_fallback.py @@ -185,3 +185,36 @@ def test_encode_failure_returns_production_keeps() -> None: similarity_fn=boom, ) assert [item.patent.patent_id for item in combined] == ["EP-KEEP"] + + +def test_exact_overlap_does_not_build_semantic_vectors(monkeypatch) -> None: + patent = _patent("EP-EXACT") + mapped = MappedOpenAlexTopic( + topic_id="https://openalex.org/T10001", + topic_display_name="Organic synthesis methods", + subfield_id="https://openalex.org/subfields/1605", + subfield_name="Organic Chemistry", + field_id="https://openalex.org/fields/16", + field_name="Chemistry", + domain_id="https://openalex.org/domains/3", + domain_name="Physical Sciences", + ) + called = {"n": 0} + + def boom(_candidates): + called["n"] += 1 + return {} + + monkeypatch.setattr( + "inse.patents.authors.semantic_topic_fallback._build_semantic_vectors", + boom, + ) + combined = apply_production_with_semantic_fallback_v1( + name_matched_patents=[patent], + production_kept=[], + author=_chemistry_author(), + patent_topic_map={patent_map_key(patent): [mapped]}, + ) + assert called["n"] == 0 + assert [item.patent.patent_id for item in combined] == ["EP-EXACT"] + assert combined[0].keep_reason == "semantic_topic_fallback_v1" diff --git a/service/src/main/inse/patents/common/parsing.py b/service/src/main/inse/patents/common/parsing.py index 6489e9ab..7513ba19 100644 --- a/service/src/main/inse/patents/common/parsing.py +++ b/service/src/main/inse/patents/common/parsing.py @@ -112,6 +112,20 @@ def patent_map_key(patent: model.PatentEntry) -> str: return f"{source}:{patent_id}:{publication_date}:{stage}" +def _application_numbers_equivalent(left: str | None, right: str | None) -> bool: + if not left or not right: + return False + left_n = left.strip() + right_n = right.strip() + if not left_n or not right_n: + return False + if left_n == right_n: + return True + left_core = left_n[2:] if left_n.upper().startswith("EP") else left_n + right_core = right_n[2:] if right_n.upper().startswith("EP") else right_n + return left_n == right_core or right_n == left_core or left_core == right_core + + async def expand_matched_epo_application_families( matched_patents: list[model.PatentEntry], search_client, @@ -136,6 +150,7 @@ async def expand_matched_epo_application_families( existing_keys = {patent_dedup_key(patent) for patent in matched_patents} extra: list[model.PatentEntry] = [] + family_batch_size = 40 async def _fetch_family(application_number: str) -> list[model.PatentEntry]: try: @@ -151,17 +166,54 @@ async def expand_matched_epo_application_families( return [] return parse_epo_hits(data) - family_results = await asyncio.gather( - *(_fetch_family(application_number) for application_number in application_numbers) - ) - for family_patents in family_results: - for patent in family_patents: + async def _fetch_family_batch(numbers: list[str]) -> list[model.PatentEntry]: + if ( + len(numbers) == 1 + or not hasattr(search_client, "epo_query_by_application_numbers") + ): + groups = await asyncio.gather( + *(_fetch_family(number) for number in numbers) + ) + return [patent for group in groups for patent in group] + try: + data = await search_client.search_epo( + search_client.epo_query_by_application_numbers(numbers) + ) + except (MissingApiKeyError, httpx.HTTPError) as exc: + logger.warning( + "EPO family expansion batch failed for %d applications: %s", + len(numbers), + exc, + ) + return [] + return parse_epo_hits(data) + + def _append_unique(patents: list[model.PatentEntry]) -> None: + for patent in patents: key = patent_dedup_key(patent) if key in existing_keys: continue existing_keys.add(key) extra.append(patent) + for start in range(0, len(application_numbers), family_batch_size): + chunk = application_numbers[start : start + family_batch_size] + family_patents = await _fetch_family_batch(chunk) + by_requested: dict[str, list[model.PatentEntry]] = {number: [] for number in chunk} + unmatched: list[model.PatentEntry] = [] + for patent in family_patents: + placed = False + for requested in chunk: + if _application_numbers_equivalent(patent.application_number, requested): + by_requested[requested].append(patent) + placed = True + break + if not placed: + unmatched.append(patent) + for requested in chunk: + _append_unique(by_requested[requested]) + _append_unique(unmatched) + if not extra: return matched_patents diff --git a/service/src/main/inse/patents/test_elastic_search_client.py b/service/src/main/inse/patents/test_elastic_search_client.py index e388f1c5..f0f94755 100644 --- a/service/src/main/inse/patents/test_elastic_search_client.py +++ b/service/src/main/inse/patents/test_elastic_search_client.py @@ -85,6 +85,17 @@ def test_epo_query_by_application_number_uses_term_filter(): assert "application_number" in payload["_source"] +def test_epo_query_by_application_numbers_batches_term_filters(): + client = PatentSearchClient(api_key="test-key") + payload = client.epo_query_by_application_numbers(["12743403.3", "13818713.3"]) + + assert payload["query"]["bool"]["minimum_should_match"] == 1 + terms = payload["query"]["bool"]["should"] + assert {"term": {"application_number": "12743403.3"}} in terms + assert {"term": {"application_number": "13818713.3"}} in terms + assert payload["size"] == 40 + + def test_epo_query_by_applicant_uses_applicants_name_field(): client = PatentSearchClient(api_key="test-key") payload = client.epo_query_by_applicant( diff --git a/service/src/main/inse/patents/test_logic.py b/service/src/main/inse/patents/test_logic.py index 9e5f8744..4d6bea0d 100644 --- a/service/src/main/inse/patents/test_logic.py +++ b/service/src/main/inse/patents/test_logic.py @@ -161,6 +161,67 @@ def test_expand_matched_epo_application_families_adds_grant_stage() -> None: assert {patent.kind for patent in expanded} == {"A1", "B1"} +def test_expand_matched_epo_application_families_batches_unique_numbers() -> None: + first = _epo_patent(publication_date="20150506", kind="A1") + first.application_number = "12743403.3" + second = _epo_patent(publication_date="20160101", kind="A1") + second.application_number = "13818713.3" + second.patent_id = "EP9990001" + + captured: list[list[str]] = [] + + class _FakeBatchClient: + async def search_epo(self, payload): + return { + "hits": { + "hits": [ + { + "_id": "2867692", + "_source": { + "doc_number": "2867692", + "kind": "B1", + "date_publication": "20180411", + "application_number": "12743403.3", + "title_en": "METHOD FOR GENERATING AND USING A MAP", + "inventors_name": ["MARRÓN, Pedro José"], + "applicants_name": ["Universität Duisburg-Essen"], + "ipc": ["G01S 5/02"], + }, + }, + { + "_id": "9990002", + "_source": { + "doc_number": "9990002", + "kind": "B1", + "date_publication": "20190101", + "application_number": "13818713.3", + "title_en": "OTHER", + "inventors_name": ["WEBER, Christian"], + "applicants_name": ["Universität Duisburg-Essen"], + "ipc": ["G01S 5/02"], + }, + }, + ] + } + } + + def epo_query_by_application_numbers(self, application_numbers, size_per_number=20): + captured.append(list(application_numbers)) + return {"query": {"terms": {"application_number": list(application_numbers)}}} + + def epo_query_by_application_number(self, application_number: str): + raise AssertionError("single-number family query should not run for a batch") + + import asyncio + + expanded = asyncio.run( + expand_matched_epo_application_families([first, second], _FakeBatchClient()) + ) + assert captured == [["12743403.3", "13818713.3"]] + assert {patent.kind for patent in expanded} >= {"A1", "B1"} + assert len(expanded) == 4 + + def test_assignee_matches_institution_name_accepts_alternative_names() -> None: from inse.patents.name_matching import assignee_matches_institution_name -- 2.56.1 From cf10f8460624464c5019e35ced15b0be78ba8926 Mon Sep 17 00:00:00 2001 From: Khuder Khalti Date: Mon, 7 Sep 2026 13:09:00 +0200 Subject: [PATCH 2/2] fix(patents) --- .../institution-patents/institution-patents.component.html | 2 +- .../institution-patents/institution-patents.component.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/webapp/src/app/modules/institution-patents/institution-patents.component.html b/webapp/src/app/modules/institution-patents/institution-patents.component.html index 7644456b..adc6a4c3 100644 --- a/webapp/src/app/modules/institution-patents/institution-patents.component.html +++ b/webapp/src/app/modules/institution-patents/institution-patents.component.html @@ -66,7 +66,7 @@ [total]="totalPatents" queryParamPageKey="page" queryParamSizeKey="size" - [pageSizeOptions]="[10, 20, 50]" + [pageSizeOptions]="[10, 25, 50]" (handlePageChange)="onPatentPageChange($event)" /> diff --git a/webapp/src/app/modules/institution-patents/institution-patents.component.ts b/webapp/src/app/modules/institution-patents/institution-patents.component.ts index 1adc76f8..3dd14c81 100644 --- a/webapp/src/app/modules/institution-patents/institution-patents.component.ts +++ b/webapp/src/app/modules/institution-patents/institution-patents.component.ts @@ -73,7 +73,7 @@ export class InstitutionPatentsComponent implements OnInit { sortDirection: SortDirection = 'desc'; pageIndex = 0; - pageSize = 20; + pageSize = 10; totalPatents = 0; ngOnInit(): void { @@ -250,7 +250,7 @@ export class InstitutionPatentsComponent implements OnInit { private parsePageSizeParam(value: string | null): number { const parsed = Number(value); - return Number.isInteger(parsed) && parsed > 0 ? parsed : 20; + return Number.isInteger(parsed) && parsed > 0 ? parsed : 10; } private isValidFilter(value: string | null): value is SourceFilter { -- 2.56.1