离线生存助手——本地 LLM 与 Kiwix,从 U 盘运行
Offline survival assistant – local LLM and Kiwix, runs from a USB stick

原始链接: https://github.com/sdalberto/ia-da-sobrevivencia/blob/main/README.en.md

**Survival Kit IA** 是一款离线、跨平台(Windows/Linux/macOS)的生存助手,完全在本地运行,无需联网。它包含葡萄牙语、英语和西班牙语的实用指南(水、火、避难所、食物、急救、医药、卫生、酒精、太阳能、无线电、工具、心理健康、检查清单),本地 AI(llama.cpp/Ollama)以自然语言回答问题并附带引用来源,以及可被 AI 搜索的 Kiwix 离线知识库(医学 Wikipedia、手册、iFixit 等)。基于浏览器的 Web 界面可在本地使用并可通过 Wi-Fi 共享;无 AI 模式下仅需 Python 仍可搜索指南。 设置:克隆仓库,运行一次准备器(需联网)以选择 AI 模型大小、Kiwix 知识库包、目标操作系统和可移植 Python,然后使用提供的脚本启动;浏览器会打开 http://127.0.0.1:8090。大文件不会提交——每个用户自行构建自己的套件。整个文件夹可复制到 exFAT USB 驱动器。CLI 命令支持 chat、ask、search、status 和网络共享。最低需要 Python 3.8+;AI 模式需要 4–8 GB RAM 和 AVX2/ARM64 CPU。代码采用 MIT 许可,指南采用 CC BY-SA 4.0;仅用于教育,不能替代应急服务。

HN 上的一篇帖子分享了一款离线生存助手,它可通过 USB 闪存盘运行本地 LLM 和 Kiwix。评论者建议将其做成 USB 死信箱,指出它可能之前发过,并围绕实用性展开争论:它需要电脑和电源,而其他人反驳说发电机或太阳能可以支持它。
相关文章

原文

A survival assistant that works 100% without internet — on Windows, Linux and macOS.

🇧🇷 Português · 🇺🇸 English · 🇪🇸 Español

If the internet, power and services go down, this kit keeps working on a laptop or USB drive:

  • 📚 Practical guides with cited sources (EN, PT, ES): water, fire, shelter, food, gardening and livestock, foraging/fishing/hunting, first aid and medicine, hygiene and homemade soap, alcohol (fermentation, distillation, antiseptic and fuel), solar power, radio and navigation, tools and knots, mental health and community, and checklists for 72 hours and 1 year.
  • 🤖 Local AI that answers any question in natural language, citing its sources — it runs on your own computer (llama.cpp or Ollama); nothing goes to the internet.
  • 🌐 Kiwix offline libraries: medical Wikipedia, post-disaster manuals, Where There Is No Doctor, wikiHow, iFixit and more — the AI searches them too.
  • 📱 Web interface in your browser, shareable over the local network (other phones connect via Wi-Fi, even with no internet).
  • 🔍 No-AI mode: even without a model, guide search works on any PC with Python.

⚠️ Disclaimer: educational content. It does not replace doctors, firefighters or emergency services. Health guidance follows public guidelines (WHO, Red Cross/IFRC, AHA, CDC, Hesperian…) cited in each section.


 Question ──► search kit guides (BM25) ──────┐
          └─► search Kiwix (.zim files) ──────┼─► local language model ──► answer with [1] [2] sources
                                              └─► (no model? shows the most relevant passages)
Part What it is Where
sobrevivencia.py + app/ The AI (Python standard library only, no pip install) repository
`knowledge/pt en es/`
knowledge/extra/ Your .md/.txt documents (searched and cited by the AI) repository
runtime/llama.cpp/ Engine that runs the AI model downloaded by the preparer
models/*.gguf Language model (1–5 GB) downloaded by the preparer
runtime/kiwix-tools/ + zim/*.zim Kiwix server and libraries downloaded by the preparer
runtime/python/ Portable Python (for PCs without Python) downloaded by the preparer

Large files are not committed to git (see .gitignore): the repository stays small and everyone builds their own kit with the preparer.


git clone https://github.com/sdalberto/ia-da-sobrevivencia.git
cd ia-da-sobrevivencia

2. Prepare the kit (online, once)

System How to run
Windows double-click preparar-kit.bat
macOS double-click preparar-kit.command (first time: right-click › Open)
Linux ./preparar-kit.sh --lang en

The preparer asks for:

  1. AI model: leve (light, 1 GB, 4 GB RAM), padrao (default, 2 GB, 8 GB RAM — recommended), forte (strong, 4.7 GB, 16 GB RAM).
  2. Kiwix libraries: minimo (~3–5 GB), recomendado (~25–40 GB) or completo (100+ GB, full Wikipedia).
  3. Systems: this computer only, or Windows + Linux + macOS (universal USB kit).
  4. Portable Python: so the kit opens on computers without Python.

Non-interactive:

python sobrevivencia.py --lang en prepare --model padrao --zims recomendado --os all --python
System How to open
Windows iniciar.bat --lang en (or double-click iniciar.bat and press EN)
macOS iniciar.command
Linux ./iniciar.sh --lang en

Your browser opens http://127.0.0.1:8090. Switch language anytime with the PT/EN/ES buttons. To make English the default, create config/settings.local.json with { "language": "en" }.

4. Carry it on a USB drive

Copy the whole folder to a USB drive or external disk formatted as exFAT (works on all three systems and supports files over 4 GB).


python sobrevivencia.py --lang en chat                   # terminal chat
python sobrevivencia.py --lang en ask "how do I make oral rehydration solution?"
python sobrevivencia.py --lang en search burn
python sobrevivencia.py status
python sobrevivencia.py start --host 0.0.0.0             # share on the local network
python sobrevivencia.py prepare --search survival        # find more Kiwix libraries

Ollama: if you use Ollama, run ollama pull qwen2.5:3b — it is detected automatically. Any local OpenAI-compatible server (LM Studio, llamafile, KoboldCpp, Jan) also works: set llm_url.

Kiwix Desktop: Kiwix Desktop can open the .zim files in zim/. To let the AI use its Local Kiwix Server, set { "kiwix_url": "http://127.0.0.1:<port>" } in config/settings.local.json. The Windows Kiwix Desktop package (~150 MB) exceeds GitHub's 100 MB per-file limit — publish it as a Release asset instead of committing it.

Drop .md or .txt files in knowledge/extra/ (family recipes, local maps, contacts, equipment manuals). They are indexed and cited by the AI.

  • Minimum (search only): any PC with Python 3.8+.
  • With AI: 4 GB RAM (light model), 8 GB recommended; x86-64 CPU with AVX2 or Apple Silicon/ARM64. No GPU needed.
  • Disk: 3 GB (minimal kit) to 100+ GB (full kit).
python -m unittest discover -s tests

Code: MIT. Guides in knowledge/: CC BY-SA 4.0. Models, Kiwix, llama.cpp and ZIM files downloaded by the preparer have their own licenses. The default model (Qwen2.5 3B) uses the Qwen Research License; for commercial use choose leve or forte (Apache 2.0).

联系我们 contact @ memedata.com