WINTER4000 commited on
Commit
031d78f
Β·
verified Β·
1 Parent(s): 050c4cd

Bootstrap: README.md

Browse files
Files changed (1) hide show
  1. README.md +101 -8
README.md CHANGED
@@ -1,15 +1,108 @@
1
  ---
2
- title: Turingdna Assistant
3
- emoji: πŸƒ
4
  colorFrom: gray
5
- colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 6.14.0
8
- python_version: '3.12'
9
  app_file: app.py
10
  pinned: false
11
- license: mit
12
- short_description: Biomedical LLM backend for TuringDNA
 
 
13
  ---
14
 
15
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)