API Reference¶
This section provides detailed documentation for the LociSimiles Python API, auto-generated from source code docstrings.
Core Modules¶
Document Module¶
The Document module provides classes for representing and loading text collections:
TextSegment- Individual text unit with ID and contentDocument- Container for text segmentsGroundTruthEntry- One labeled query/source relationshipGroundTruth- Container for labeled query/source pairs
Pipeline Module¶
The Pipelines module provides the main processing pipelines:
Pipeline- Generic composer: combine any generator + judgeRetrievalPipeline- Semantic similarity retrievalClassificationPipeline- Text pair classificationClassificationPipelineWithCandidateGeneration- Two-stage retrieval + classificationRuleBasedPipeline- Lexical matching + linguistic filtersWord2VecRetrievalPipeline- Burns-style Word2Vec bigram retrievalLatinBertRetrievalPipeline/LatinBertTwoStagePipeline- Gong-style contextual BERT retrievalTfidfRetrievalPipeline/BM25RetrievalPipeline- Lexical TF-IDF/BM25 retrievalBM25TwoStagePipeline- BM25 + classification ("best combined")BM25LexicalTwoStagePipeline- BM25 + trained lexical classifier ("best non-neural")
Generators Module¶
The Generators module provides candidate-generation components:
EmbeddingCandidateGenerator- Semantic embedding similarityExhaustiveCandidateGenerator- All-pairs (no filtering)RuleBasedCandidateGenerator- Lexical matching + linguistic filtersWord2VecCandidateGenerator- Burns-style Word2Vec bigram similarityLatinBertContextualCandidateGenerator- Gong-style contextual token similarityTfidfCandidateGenerator- TF-IDF cosine similarityBM25CandidateGenerator- Okapi BM25 retrieval
Judges Module¶
The Judges module provides scoring/classification components:
ClassificationJudge- Transformer-based sequence classificationLexicalClassifierJudge- Trained LogReg/GBDT lexical classification (no neural model)ThresholdJudge- Binary decisions from candidate scoresIdentityJudge- Pass-through (judgment_score = 1.0)
Evaluator Module¶
The Evaluator module provides tools for assessing detection quality:
IntertextEvaluator- Main evaluation class
Training Module¶
The Training module provides trainers for every trainable approach in the benchmark:
TrainingData- Bundles a query/sourceDocumentpair with aGroundTruth, with negative-sampling methodsLexicalClassifierTrainer- Trains the LogReg/GBDT lexical classifierWord2VecTrainer- Trains the Burns-style Word2Vec retrieval modelClassificationTrainer- Fine-tunes the transformer sequence classifier, plus threshold tuning/application and optional best-checkpoint/early-stopping selectionEmbeddingTrainer- Fine-tunes the SentenceTransformer bi-encoder, plus optional best-checkpoint/early-stopping selectioncross_validate- Reproduces the paper's mean±std-across-folds evaluation protocol
Quick Reference¶
Loading Documents¶
Saving Results¶
# Save from a pipeline instance
results = pipeline.run(query=query_doc, source=source_doc, top_k=10)
pipeline.to_csv("results.csv")
pipeline.to_json("results.json")
# Or use standalone functions
from locisimiles.pipeline import results_to_csv, results_to_json
results_to_csv(results, "results.csv")
results_to_json(results, "results.json")