caelum0x 174222bcaa feat: Builder-Track named-user tools, bio + evidence-intelligence platform, Apache-2.0
Builds PaperTrail from the base skeleton into a full evidence-verification platform
for the "Built with Claude: Life Sciences" hackathon (Builder Track).

New named-user features (Build Beyond the Bench):
- Lab Notebook Companion — rough bench notes -> structured, searchable, grounded
  experiment records (lib/labNotebook, /console/lab-notebook, migration 0059)
- Clinical Trial Matcher — de-identified patient notes -> ranked eligible
  ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning
  (lib/trialMatcher, /console/trial-matcher, migrations 0060)

Platform:
- Deterministic verification moat (biostats recompute, exact-span grounding)
- 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar,
  PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier)
- Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise
  governance (RBAC, /api/v1 gateway, metering, audit chain, retention)
- 17 OSS projects assimilated into native TypeScript on our stack (backend/engines
  retained + credited in NOTICE)
- Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site
- Next.js 16 upgrade, benchmark harness (honest smoke-test caveat)

Licensing: Apache-2.0 (LICENSE + NOTICE).
2026-07-10 16:23:13 +03:00

51 lines
2.2 KiB
Python

"""Example for backfill representations."""
from pykeen.datasets import get_dataset
from pykeen.nn import BackfillRepresentation, Embedding, init
from pykeen.pipeline import pipeline
# Here we simulate going from a smaller dataset to a larger one
# by starting with a large dataset and narrowing it down.
dataset_large = get_dataset(dataset="nations")
dataset = dataset_large.restrict(entities=["burma", "china", "india", "indonesia"])
# You can take a look at the datasets via `dataset.summarize()``
# Now we train a model on the small dataset.
embedding_dim = 32
result = pipeline(
dataset=dataset,
interaction="distmult",
dimensions={"d": embedding_dim},
)
# We want to re-use the entity representations for known entities, without further training them.
old_repr: Embedding = result.model.entity_representations[0]
initializer = init.PretrainedInitializer(tensor=old_repr())
# The known IDs are the entity IDs of known entities *in the new entity to ID mapping*.
# Here, we look them up via their (unique) label.
known_ids = dataset_large.training.entities_to_ids(dataset.entity_to_id)
base_repr = Embedding(max_id=len(known_ids), shape=(embedding_dim,), initializer=initializer, trainable=False)
# Next, we directly create representations for the new entities using the backfill representation.
# To do this, we need to create an iterable (e.g., a set) of all of the entity IDs that are in the base
# representation. Then, the assignments to the base representation and an auxillary representation are
# automatically generated for the base class.
entity_repr = BackfillRepresentation(base_ids=known_ids, max_id=dataset_large.num_entities, base=base_repr)
# You can see the composition by printing the module.
print(entity_repr)
# Note: For simplify, we train new relation representations from scratch.
# You could also re-use the relation representations (if the set of relations stayed the same),
# or apply the same backfill method from above.
# The combined representation can now be used as any other representation, e.g., to train a model with
# distmult interaction:
result = pipeline(
dataset=dataset_large,
interaction="distmult",
dimensions={"d": embedding_dim},
model_kwargs={"entity_representations": entity_repr},
)