Skip to main content

ClinGuard

Safety-first building blocks for clinical voice AI in low-resource languages and dialects.

Mainstream speech and translation tools work poorly for many of the world's languages and dialects. In healthcare, a misunderstood symptom can become a wrong note, and a wrong note can harm a patient. ClinGuard gives developers the safety layer around their AI: a native-speaker lexicon that grounds meaning, rule-based danger-sign checks that never depend on the AI, clear confidence levels, and a human-reviewed learning loop.

ClinGuard is model-agnostic. It does not call any AI provider. Plug in any speech recogniser, translator or note generator as plain Python functions.

pip install clinguard

Why

Problem What ClinGuard does
Speech recognition writes dialect speech with varying tone marks and spellings Normalises tone marks and accents; tolerant, length-aware fuzzy matching
A short phrase like "it hurts" can hide inside an unrelated question Coverage-aware scoring: a phrase that explains only part of what was said scores lower; matches must share a distinctive word, not just "my" or "me"
General translators misread dialect phrases Lexicon first: meaning comes from a glossary curated by native speakers
AI output can look confident when it is wrong Every result carries a confidence level: high (lexicon), low (fallback), none
Emergencies must never be missed because of an AI error Rule-based danger-sign check, independent of any model
Lexicons are never complete Human-in-the-loop learning: users suggest, a trusted reviewer approves, with a full audit trail

Quick start

from clinguard import ClinGuard, DangerRules, Lexicon

lexicon = Lexicon.from_file("my_lexicon.json", language="yo")

guard = ClinGuard(
    lexicon,
    DangerRules(local_keywords={"yo": ["warapa"]}),   # rules reviewed by your clinicians
    language="yo",
    translate=my_translate,      # optional: your model, used only when the lexicon has no match
    write_note=my_note_writer,   # optional: your note generator
)

a = guard.assess("Orí mi ń fọ́ mi")      # text from any speech recogniser
a.confidence      # "high"
a.clinical_term   # "Headache"
a.danger          # False
a.needs_review    # False
a.banners()       # [] or e.g. ["URGENT - possible danger sign ...", "LOW CONFIDENCE ..."]

See examples/quickstart.py for a runnable demo.

Lexicon format

JSON (a list of objects) or CSV with a header row:

field required meaning
phrase yes what the patient says, in the local language or dialect
meaning yes plain-English meaning
clinical_term yes the term a clinician would record
language no language code, e.g. yo, ha, sw
department no context, e.g. Antenatal
danger no true if this phrase is a danger sign

Check a lexicon for clashing entries before deploying:

clinguard validate my_lexicon.json
clinguard check my_lexicon.json "Mi ò le mí" --language yo

Human-in-the-loop learning

from clinguard import SuggestionStore

store = SuggestionStore("lexicon_reviews/")
sid = store.submit("Ese mi n wu", "My leg is swelling", "Leg swelling (edema)", language="yo")
store.review(sid, approve=True, reviewer="Native-speaker reviewer")   # reviewer name is required
lexicon = lexicon.extend(store.approved_entries("yo"))

Suggestions and decisions are stored in append-only JSON Lines files, so every change to the lexicon can be traced to a person and a time.

Used in

  • BeaGrace Health: ClinGuard grew out of, and now powers the safety and lexicon layer of, BeaGrace Health, a voice app that turns Ekiti Yoruba patient speech into structured nurse handoff notes, being piloted with nurses in Nigeria (AI Ventures Accelerator · Technovation & UNICEF Generation Unlimited). ClinGuard packages its safety and lexicon methods so any team can use them for any language.

Using ClinGuard in your project? Please open an issue to tell us. It helps guide the roadmap.

Safety notice

ClinGuard is a toolkit, not a medical device. The built-in English danger keywords are a starter list for illustration only. Every deployment must have its lexicon and danger rules reviewed and approved by qualified clinicians, and a clinician must review AI-assisted output before it is used in care. The example lexicon is illustrative and not clinically validated.

Contributing

Issues and pull requests are welcome, especially lexicons and danger-sign rules for new languages, reviewed by native speakers and clinicians.

Changelog

  • 0.1.2: Fewer false matches. A short lexicon phrase found inside a longer utterance is scored by how much of the utterance it explains, and (in lexicons of 10+ entries) a match must share a distinctive word. On a 60-entry Ekiti Yoruba lexicon, leave-one-out wrong-term matches fell from 32 to 2, with recall on noisy variants of lexicon phrases at 176/179 (was 178/179). Source files restored to the repository.
  • 0.1.1: First public release.

License

Apache License 2.0. Created by Shalini Sivasamy.

Metadata

Release files for clinguard 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clinguard 0.1.2
File Size Uploaded Provenance Actions
clinguard-0.1.2.tar.gz 17.0 kB Without provenance Details for clinguard-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clinguard 0.1.2
File Interpreter ABI Platform Actions
clinguard-0.1.2-py3-none-any.whl Python 3 none any Details for clinguard-0.1.2-py3-none-any.whl

Total release size: 34.6 kB

Release files / clinguard-0.1.2.tar.gz

Download URL clinguard-0.1.2.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
eb8c9e3d7aaccc04ef1f4fbef12ac8d00bd6d5db4ef6344a134062c64b886797
BLAKE2b-256 checksum
How to use checksums
ebce375cdffab86c65b8ff60fbb70ce09a17e3cec81468da058d04591c45df2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.4

Release files / clinguard-0.1.2-py3-none-any.whl

Download URL clinguard-0.1.2-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12698b326f77e8c9d653bf709023e166f08de88758fa0e574f67ae907f55c047
BLAKE2b-256 checksum
How to use checksums
523878960fbcf1bef562d980099851f1c8d0237042a5682a64b8acac23861792
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.4

Security for clinguard 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page