Skip to main content

LociSimiles is a Python package for finding intertextual links in Latin literature using pre-trained language models.

Project description

Loci Similes

LociSimiles is a Python package for finding intertextual links in Latin literature using pre-trained language models.

Basic Usage

# Load example query and source documents
query_doc = Document("../data/hieronymus_samples.csv")
source_doc = Document("../data/vergil_samples.csv")

# Load the pipeline with pre-trained models
pipeline = ClassificationPipelineWithCandidategeneration(
    classification_name="...",
    embedding_model_name="...",
    device="cpu",
)

# Run the pipeline with the query and source documents
results = pipeline.run(
    query=query_doc,    # Query document
    source=source_doc,  # Source document
    top_k=3             # Number of top similar candidates to classify
)

pretty_print(results)

Command-Line Interface

LociSimiles provides a command-line tool for running the pipeline directly from the terminal:

Basic Usage

locisimiles query.csv source.csv -o results.csv

Advanced Usage

locisimiles query.csv source.csv -o results.csv \
  --classification-model julian-schelb/PhilBerta-class-latin-intertext-v1 \
  --embedding-model julian-schelb/SPhilBerta-emb-lat-intertext-v1 \
  --top-k 20 \
  --threshold 0.7 \
  --device cuda \
  --verbose

Options

  • Input/Output:

    • query: Path to query document CSV file (columns: seg_id, text)
    • source: Path to source document CSV file (columns: seg_id, text)
    • -o, --output: Path to output CSV file for results (required)
  • Models:

    • --classification-model: HuggingFace model for classification (default: PhilBerta-class-latin-intertext-v1)
    • --embedding-model: HuggingFace model for embeddings (default: SPhilBerta-emb-lat-intertext-v1)
  • Pipeline Parameters:

    • -k, --top-k: Number of top candidates to retrieve per query segment (default: 10)
    • -t, --threshold: Classification probability threshold for filtering results (default: 0.5)
  • Device:

    • --device: Choose auto, cuda, mps, or cpu (default: auto-detect)
  • Other:

    • -v, --verbose: Enable detailed progress output
    • -h, --help: Show help message

Output Format

The CLI saves results to a CSV file with the following columns:

  • query_id: Query segment identifier
  • query_text: Query text content
  • source_id: Source segment identifier
  • source_text: Source text content
  • similarity: Cosine similarity score (0-1)
  • probability: Classification confidence (0-1)
  • above_threshold: "Yes" if probability ≥ threshold, otherwise "No"

Optional Gradio GUI

Install the optional GUI extra to experiment with a minimal Gradio front end:

pip install locisimiles[gui]

Launch the interface from the command line:

locisimiles-gui

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

locisimiles-0.2.8.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

locisimiles-0.2.8-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file locisimiles-0.2.8.tar.gz.

File metadata

  • Download URL: locisimiles-0.2.8.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/24.6.0

File hashes

Hashes for locisimiles-0.2.8.tar.gz
Algorithm Hash digest
SHA256 4f1458a5db44643e452624d06d9859a2c7ce03af8fd785d0085a7c222b675f43
MD5 413a265ed589a3fca4bb2aa7c7753705
BLAKE2b-256 85fad3f631b328121c519a0630082438a6acdaf135b265fa48ce30f10cf47c3d

See more details on using hashes here.

File details

Details for the file locisimiles-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: locisimiles-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/24.6.0

File hashes

Hashes for locisimiles-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 89cc02caa16ab46abd32ed1c42994b6ba4173a969e1e3c007c0d032f74f115df
MD5 e425a9e5f9c4f48d78f670a43926902b
BLAKE2b-256 18e4093447bc81e1937e4b297ce5dd6f3689f97dbcc4bc399d76c20ff4b5a76f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page