Bootstrap: README.md
Browse files
README.md
CHANGED
|
@@ -1,15 +1,108 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: gray
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.12'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
-
license:
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: TuringDNA Assistant
|
| 3 |
+
emoji: π§¬
|
| 4 |
colorFrom: gray
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.0
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
hardware: zero-a10g
|
| 12 |
+
short_description: Protein biology Q&A backend for the TuringDNA engine.
|
| 13 |
+
suggested_hardware: zero-a10g
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# TuringDNA Assistant
|
| 17 |
+
|
| 18 |
+
Self-hosted biomedical LLM that powers the in-app chat panel on
|
| 19 |
+
[turingdna.com/app](https://turingdna.com/app). Loads **BioMistral-7B**
|
| 20 |
+
(an open-source Mistral fine-tuned on biomedical corpora) on a
|
| 21 |
+
ZeroGPU-shared NVIDIA A100, exposes a Gradio `ChatInterface` for direct
|
| 22 |
+
testing, and an auto-generated `/run/predict` API the Flask app calls
|
| 23 |
+
via `gradio_client`.
|
| 24 |
+
|
| 25 |
+
## Architecture
|
| 26 |
+
|
| 27 |
+
```
|
| 28 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 29 |
+
β winter4000/syntheogenesis (Flask + vanilla JS, CPU) β
|
| 30 |
+
β βββ dee/server.py /api/chat β
|
| 31 |
+
β βββ gradio_client.predict() βββββββββββββββββββββββββββ β
|
| 32 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββΌβββββββ
|
| 33 |
+
βΌ
|
| 34 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 35 |
+
β winter4000/turingdna-assistant (Gradio, ZeroGPU) β
|
| 36 |
+
β βββ app.py Gradio ChatInterface β
|
| 37 |
+
β βββ llm.py BioMistral-7B in bf16, @spaces.GPU(duration=60) β
|
| 38 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
Two-Space split so the existing Flask engine doesn't need a rewrite and
|
| 42 |
+
the model lives where the GPU does.
|
| 43 |
+
|
| 44 |
+
## Why ZeroGPU?
|
| 45 |
+
|
| 46 |
+
ZeroGPU gives shared A100 access to HF PRO subscribers at no per-hour
|
| 47 |
+
cost (just the $9/mo subscription). The decorator pattern:
|
| 48 |
+
- Model loads on CPU at import (~14 GB in bf16, fits comfortably in
|
| 49 |
+
ZeroGPU's 60 GB host RAM)
|
| 50 |
+
- `@spaces.GPU(duration=60)` moves the model to GPU only during a
|
| 51 |
+
generation call, then releases β so we share the A100 efficiently
|
| 52 |
+
with other ZeroGPU Spaces
|
| 53 |
+
|
| 54 |
+
First call after the Space wakes up: ~10β30 s (cold-start + GPU acquire).
|
| 55 |
+
Subsequent calls: ~25β80 tokens/sec.
|
| 56 |
+
|
| 57 |
+
## Model
|
| 58 |
+
|
| 59 |
+
[BioMistral/BioMistral-7B](https://huggingface.co/BioMistral/BioMistral-7B)
|
| 60 |
+
β Apache-2.0, biomedical-domain fine-tune of Mistral-7B-Instruct-v0.1.
|
| 61 |
+
Knows enzyme mechanisms, active sites, conserved domains, codon
|
| 62 |
+
optimization, expression systems, and cloning vocab better than vanilla
|
| 63 |
+
Mistral. Same Mistral instruct template (`[INST] ... [/INST]`).
|
| 64 |
+
|
| 65 |
+
Fallback if BioMistral fetch fails: `mistralai/Mistral-7B-Instruct-v0.2`.
|
| 66 |
+
|
| 67 |
+
## System prompt
|
| 68 |
+
|
| 69 |
+
Baked into `llm.py`. The assistant is told it's the chat backend for
|
| 70 |
+
TuringDNA, knows the codebase's ΞLL sign convention (positive ΞLL =
|
| 71 |
+
mutation is MORE likely than WT under ESM-2, i.e. more tolerated;
|
| 72 |
+
negative = less likely, i.e. disruptive), and is instructed to be
|
| 73 |
+
concise + not hallucinate domain boundaries.
|
| 74 |
+
|
| 75 |
+
## Local development
|
| 76 |
+
|
| 77 |
+
```bash
|
| 78 |
+
pip install -r requirements.txt
|
| 79 |
+
python app.py
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
Local runs use CPU-only fp16 (~2 tok/s on Mac M1, ~1 tok/s on Intel
|
| 83 |
+
Mac). Production runs on ZeroGPU A100. The `@spaces.GPU` decorator
|
| 84 |
+
is a no-op locally so the same code works in both contexts.
|
| 85 |
+
|
| 86 |
+
## Calling from outside
|
| 87 |
+
|
| 88 |
+
```python
|
| 89 |
+
from gradio_client import Client
|
| 90 |
+
|
| 91 |
+
client = Client("winter4000/turingdna-assistant")
|
| 92 |
+
response = client.predict(
|
| 93 |
+
message="What does a ΞLL of +1.2 for V8L mean?",
|
| 94 |
+
history=[],
|
| 95 |
+
api_name="/chat",
|
| 96 |
+
)
|
| 97 |
+
print(response)
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
## Files
|
| 101 |
+
|
| 102 |
+
- `app.py` β Gradio app entry (ChatInterface + Gradio launches its own
|
| 103 |
+
API endpoints)
|
| 104 |
+
- `llm.py` β model loading + Mistral prompt formatting + ZeroGPU
|
| 105 |
+
inference function
|
| 106 |
+
- `requirements.txt` β Gradio, transformers, spaces, torch, accelerate
|
| 107 |
+
- `README.md` β this file (also the HF Space metadata via YAML
|
| 108 |
+
frontmatter at the top)
|