How shreya0119/old-kannada-restorer works
Purpose and Entry Point
This is a Streamlit application for restoring one masked word in transliterated Old Kannada inscriptions and predicting dynasty/date ranges. app.py is the interactive entry point, exposing verified evaluation mode, free-text mode, and precomputed evaluation results.
Curated Corpus Boundary
The application is driven by a small, committed reference corpus rather than a database or trained model. data/curated_inscriptions.json contains verified inscription text plus dynasty and date metadata. Runtime behavior treats this corpus as the in-context example pool; changes require regenerating results/eval_results.json.
Restoration Pipeline
Masked-inscription restoration is orchestrated in src/restore.py. It accepts text containing a marked gap, selects supplied reference examples, builds a constrained LLM request through src/prompts.py, and parses ranked JSON candidates from the response. The output supports up to three candidates and associated reasoning.
Dynasty and Date Attribution
src/dynasty.py runs a parallel inference path for dynasty and date-range prediction. It uses the same curated examples and prompt-based reference pattern, but targets historical attribution rather than missing-word recovery. Restoration and attribution are separate model tasks surfaced together by app.py.
Prompt and Model Boundary
src/prompts.py defines the structured few-shot and zero-shot prompt contracts, including strict JSON-oriented response expectations. src/llm_client.py is the provider boundary: it reads API credentials from environment variables and performs multi-provider Gemini/Groq failover. No local model training, OCR pipeline, or persistent service is required at runtime.
Evaluation and Baseline
scripts/evaluate.py performs leave-one-out testing over the curated corpus: it masks a selected eligible word, compares frequency baseline, zero-shot LLM, and few-shot LLM outputs, then writes aggregate metrics to results/eval_results.json. src/baseline.py supplies the context-free word-frequency comparator. Text normalization and matching behavior are centralized in src/text_utils.py.
Primary Control Flows
In verified mode, app.py chooses an inscription, masks an eligible token, retains ground truth, calls restoration and dynasty prediction with the remaining corpus as examples, and scores/display results. In free-text mode, user-provided masked text is sent to the same inference layers using all curated entries as references; outputs are explicitly unverified. The external dependencies are Streamlit, Gemini/Groq APIs, and locally committed corpus/results artifacts.
Main entry points: evaluate.py Leave-one-out evaluation · restore.py Restoration orchestration · curated_inscriptions.json Curated inscriptions · app.py Streamlit app
Components 11
Streamlit UI
- Streamlit app · Provides verified, free-text, and results views.
app.py
Reference Data
- Curated inscriptions · Verified text with dynasty and date metadata.
data/curated_inscriptions.json
LLM Inference
- Restoration orchestration · Selects examples and returns ranked missing-word candidates.
src/restore.py - Dynasty/date inference · Predicts dynasty and date range independently of restoration.
src/dynasty.py - Prompt contracts · Builds constrained structured JSON requests.
src/prompts.py - Provider client · Uses environment credentials with Gemini/Groq failover.
src/llm_client.py - Gemini / Groq APIs
- Text normalization · Centralizes normalization and comparison behavior.
src/text_utils.py
Evaluation
- Leave-one-out evaluation · Masks eligible words and compares restoration approaches.
scripts/evaluate.py - Frequency baseline
src/baseline.py - Evaluation results · Regenerated when the curated corpus changes.
results/eval_results.json
Connections 18
- Streamlit app → Curated inscriptions: loads entries
- Streamlit app → Restoration orchestration: restores masked text
- Streamlit app → Dynasty/date inference: attributes history
- Streamlit app → Evaluation results: displays metrics
- Restoration orchestration → Curated inscriptions: selects references
- Restoration orchestration → Prompt contracts: builds request
- Restoration orchestration → Text normalization: normalizes candidates
- Dynasty/date inference → Curated inscriptions: uses references
- Dynasty/date inference → Prompt contracts: builds request
- Prompt contracts → Provider client: structured request
- Provider client → Gemini / Groq APIs: provider failover
- Leave-one-out evaluation → Curated inscriptions: leave-one-out inputs
- Leave-one-out evaluation → Restoration orchestration: few-shot comparison
- Leave-one-out evaluation → Frequency baseline: frequency comparison
- Leave-one-out evaluation → Prompt contracts: zero-shot comparison
- Leave-one-out evaluation → Text normalization: scores matches
- Leave-one-out evaluation → Evaluation results: writes metrics
- Curated inscriptions → Evaluation results: changes require regeneration