Spaces:
Sleeping
Sleeping
Add README
Browse files
README.md
CHANGED
|
@@ -1,10 +1,67 @@
|
|
| 1 |
---
|
| 2 |
title: Modular Detector V2
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Modular Detector V2
|
| 3 |
+
emoji: 🧭
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
short_description: Modular addition helper.
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Local run:
|
| 13 |
+
|
| 14 |
+
```bash
|
| 15 |
+
python -m venv .venv
|
| 16 |
+
source .venv/bin/activate
|
| 17 |
+
pip install -r requirements.txt
|
| 18 |
+
uvicorn app.main:app --reload
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
Open http://127.0.0.1:8000
|
| 22 |
+
|
| 23 |
+
Default embedding model: `Qwen/Qwen3-Embedding-0.6B`
|
| 24 |
+
Default dataset: `Molbap/modular-detector-embeddings`
|
| 25 |
+
|
| 26 |
+
Note: The embedding model and the index must match. If you change the model, you must rebuild and re-upload the index.
|
| 27 |
+
|
| 28 |
+
Rebuild method index (from repo root, expects transformers clone at `./transformers` or `./transformers_repo`):
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
python scripts/build_index.py
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
Quick inference (curl):
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
curl -s http://127.0.0.1:8000/api/analyze \
|
| 38 |
+
-H "Content-Type: application/json" \
|
| 39 |
+
-d '{
|
| 40 |
+
"code": "class Foo:\n def forward(self,x):\n return x\n",
|
| 41 |
+
"top_k": 5,
|
| 42 |
+
"granularity": "method",
|
| 43 |
+
"precision": "float32"
|
| 44 |
+
}' | jq
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Push app to Space:
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
hf upload --repo-type space Molbap/modular-detector-v2 . \
|
| 51 |
+
--include "Dockerfile" \
|
| 52 |
+
--include "requirements.txt" \
|
| 53 |
+
--include "README.md" \
|
| 54 |
+
--include "app/**" \
|
| 55 |
+
--include "static/**" \
|
| 56 |
+
--commit-message "Update app"
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
Push method index to dataset:
|
| 60 |
+
|
| 61 |
+
```bash
|
| 62 |
+
hf upload --repo-type dataset Molbap/modular-detector-embeddings . \
|
| 63 |
+
--include "embeddings_methods.safetensors" \
|
| 64 |
+
--include "code_index_map_methods.json" \
|
| 65 |
+
--include "code_index_tokens_methods.json" \
|
| 66 |
+
--commit-message "Update method index"
|
| 67 |
+
```
|