Thinking global, living local

How to use ship2shore_rag: offline answers from open maritime reports

October 18, 2026

ship2shore_rag lets you ask plain-English questions of open maritime literature and accident reports, with cited passages, on a shore server or offline on a ship.

Open-source tools · How-to · Maritime knowledge search

How to use ship2shore_rag: offline answers from open maritime reports

Skip to article content
Text Size

Revised · v1.0.0 · what changed

131documents in the demo corpus
1,884text chunks searched
0.76 to 0.82recall@5 without and with reranking (17 test queries)
0API keys used in the demo

Code: github.com/herrrickshaw/ship2shore_rag

Watch the walkthrough

Watch on YouTube: youtu.be/VeQHhoIb9F0

What it is for

ship2shore_rag is a search tool for maritime knowledge. It collects open sources (arXiv papers, Wikipedia, UK MAIB and US NTSB accident reports, plus any PDF or Word file you add), splits them into passages, and finds the passages that best match a question. Every result names its source, so you can check it.

It runs in two ways. On shore it uses Postgres with the pgvector add-on. On a vessel it uses one SQLite file, with no server and no internet. Both use the same search method: meaning-based search combined with keyword search, then a reranking step. Writing a final answer with Claude is optional. Without a key, the tool simply shows you the ranked passages.

The repository also has an operations module (vessel, crew, logbook, maintenance, fuel and incident records). This post covers the search side only.

Who it is for

  • Ship officers and superintendents who want to look up past incidents and definitions offline
  • Researchers and students studying maritime accidents, freight and regulation
  • Engineers who want a working example of offline hybrid search (RAG) with citations
Not for.
  • Replacing statutory logs or official records (the README says so)
  • Multi-vessel fleet software, or syncing a ship with the shore office (not built)
  • Legal, safety-critical or class decisions. Check the cited source every time

What you need

RequirementWhyHow to get it
Python 3 with pipruns the command-line toolpython.org, or brew install python. Python 3.10 or newer is a safe choice (the repo does not state a minimum)
About 1 GB of disk and some RAMinstalls sentence-transformers (which pulls in PyTorch) and two small local modelsThe embedding model is about 90 MB and runs on CPU. A GPU is not needed. Models download once on first use
A corpus filesomething to searchThe repo ships snapshots/ship2shore.sqlite3 (125 documents, 1,571 chunks, 7 MiB). The demo used a larger local file with 131 documents
Postgres with pgvectoronly for shore-side ingestion of new documentsbrew install postgresql@17 pgvector (see the README). Not needed to search the SQLite snapshot
ANTHROPIC_API_KEYoptional: lets ask write a cited answer instead of listing passagesconsole.anthropic.com. Skip it and use --no-generate
Internet accessonly for first-time model download and for ingesting new sourcesNot needed to search once the models are cached

Get the code and an AI assistant

You do not have to be a programmer. Get the repository, give it to an AI assistant, and ask in plain language. Any of these routes works:

ToolWhat you needBest for
GitHubFree account to fork or star; git to clone, or the green Code button, then Download ZIP, or open in CodespacesGetting the code and keeping up with updates
Claude CodeClaude subscription or API key; run claude inside the cloned folderLetting the AI read and run the whole repo
Gemini CLIGoogle account; run gemini inside the cloned folderThe same hands-on workflow with Gemini
Claude.ai, Gemini or ChatGPT in the browserA chat account; upload README.md and the files you care about (or paste the output of git ls-files)Understanding the project and asking questions without installing anything
Other tools (Copilot Chat, Cursor, Codex CLI)Open the cloned folder in the tool and point it at README.md firstEditing and extending the code
git clone https://github.com/herrrickshaw/ship2shore_rag.git
cd ship2shore_rag
claude      # or: gemini

Install

  1. Clone the repo and create a virtual environment.
    git clone https://github.com/herrrickshaw/ship2shore_rag.git
    cd ship2shore_rag
    python3 -m venv .venv
    source .venv/bin/activate
  2. Install the dependencies. This is the full list in requirements.txt, so it takes a few minutes.
    pip install -r requirements.txt
  3. Copy the settings file. For offline use, edit .env so it contains the two lines shown.
    cp .env.example .env
    # in .env set:
    # STORAGE_BACKEND=sqlite
    # SQLITE_PATH=snapshots/ship2shore.sqlite3
  4. Optional, shore side only: install Postgres and pgvector, then create the schema. Skip this if you only want to search the snapshot.
    brew install postgresql@17 pgvector
    # start Postgres on port 5433 and run createdb as in the README, then:
    python3 cli.py init-db

Quick start: commands and what you should see

Ask a question and get ranked passages only (no API key).

python3 cli.py ask "What are the main causes of engine room fires on cargo ships?" --no-generate

A numbered Sources list, each with a title, URL and a short excerpt. In the demo the top hits were NTSB and arXiv items about an engine failure and an engine room fire, plus a Wikipedia page on container ships. The demo author noted these were only loosely related, because the corpus is small.

Ask a definition question and limit the number of results.

python3 cli.py ask "What is a bill of lading and what does it do?" --no-generate --top-k 3

Three passages. The first two came from the Wikipedia article on the bill of lading and the third from the article on charterparties.

Build a hazard brief for a job.

python3 cli.py hazard-brief "Hot work welding in engine room near fuel oil tanks" --top-k 3

A list of similar past incidents and guidance, each with a link. In the demo it returned an NTSB engine failure report and the Dali bridge contact report. It is retrieval only, not a risk score.

Measure retrieval quality on the 17 test questions in eval/queries.yaml.

python3 cli.py eval

Two summary lines. Rerank off: recall@5 = 0.76 and MRR = 0.706. Rerank on: recall@5 = 0.82 and MRR = 0.824. Questions that found nothing are listed as MISS.

Ways to use it

MethodHow it works
Command linepython3 cli.py ask, hazard-brief, eval, ingest and export-sqlite. This is the main interface.
Your own documentspython3 cli.py ingest --source file --path "./docs/**/*" adds PDF, text, Markdown, HTML, Word, Excel and PowerPoint files. Files stay on your machine.
Shore to vesselIngest on shore with Postgres, run python3 cli.py export-sqlite, copy the single file aboard, and set STORAGE_BACKEND=sqlite.
Reportsask --export briefing.html (or .txt) writes a small report you can attach to an email.
Web page and APIpython3 cli.py serve starts a small read-only web app on 127.0.0.1:8020. The repo also has a REST API (api.py) for the operations records.
Through an AI assistantOpen the cloned folder in Claude Code or Gemini CLI and ask it to run the commands above and explain the results.

Sample prompts for your AI assistant

Copy, paste and edit the parts in [brackets].

  • Read README.md and ARCHITECTURE.md in this repo and explain in plain English how a question becomes a list of cited passages.
  • Set this repo up to run offline from snapshots/ship2shore.sqlite3 and run one question with --no-generate. Tell me each command before you run it.
  • I have a folder of [my PDF reports]. Show me how to ingest them with --source file and then ask a question about [topic].
  • Run cli.py eval and explain recall@5 and MRR to me as if I had never seen them. Which questions missed, and why might they have?
  • Add three questions about [my topic] to eval/queries.yaml with the source I expect each to find, then re-run the eval.
  • What would break if I put this on a ship with no internet? List what needs to be downloaded first.

Limits and honest caveats

  • The corpus is small. In the demo, questions about engine room fires and hot work returned only loosely related reports.
  • The eval has 17 queries, so treat 0.76 and 0.82 as indicative, not as a benchmark. Three questions still missed with reranking on, including man overboard on a bulk carrier and the growth of maritime trade in 2023.
  • The committed snapshot holds 125 documents. The demo used a local file with 131 documents, so your counts and results will differ slightly.
  • It is not multi-vessel fleet software, and nothing syncs a vessel with the shore office (README).
  • It is not a replacement for statutory logs (README).
  • The web API still allows requests from any origin (CORS is open to all, README). Keep it on localhost.
  • Without an API key, ask only returns passages. Generated answers were not tested in the demo. Check any generated answer against the cited sources.
  • The demo ran every command with --no-generate and with models loaded from the local cache in offline mode.

Sources: the ship2shore_rag README, ARCHITECTURE.md, requirements.txt, .env.example and snapshots/README.md, and the demo run of 18 October 2026.

Revision history.
  • v1.0.0 — 18 October 2026 — first published.

About this article: Researched, written and edited by Umashankar Triplicane Dwarakanathan, with AI research assistance; every figure is meant to trace to the primary source cited. See the Editorial Policy for how sourcing, AI use and corrections work.

Umashankar Triplicane Dwarakanathan
Contact Us
Umashankar Triplicane Dwarakanathan
Investment Promotion & Energy-Sector Leader · Chennai, Tamil Nadu, India
LinkedIn → GitHub → Email +91 78273 81696
How this site works

Data-led analysis of India's trade, currency and industrial policy. Every article is built from primary official sources, and every figure links back to the release, table or filing it came from.

Sources. DGCI&S TradeStat (imports/exports, HSN-wise) · PIB (government press releases, January 2017 to today, refreshed daily) · RBI (circulars, balance of payments) · MoSPI (CPI/WPI, IIP) · PARIVESH (environmental clearances) · CCIL (bond yields) · BIS (policy rates) · SEBI, NSE/BSE and SEC filings for company data.

Interpretation. Figures carry their vintage and retrieval date; estimates and press-reported numbers are labelled as such; where sources disagree, both are shown. Corrections are made visibly, never silently. Articles are written with AI assistance from the cited sources — AI-generated text can misstate figures even when working from real material, so verify any number that matters to a decision against the linked primary source.

footer

Browse all articles by topic

Every piece on this blog, grouped. Or read the full index.

Agriculture & FertilisersAI ToolsChemicalsClimate & CarbonEnergy & FuelsGas & LNGImport SubstitutionIndustrial PolicyMarkets & FinanceMobility & EVPrices & InflationTextilesTrade & Tariffs

Each topic is a live archive page that updates itself as pieces are labelled. It replaces a hand-kept list that had fallen 18 articles behind.