File size: 1,543 Bytes
c987363
 
fd80067
c987363
 
 
 
 
 
 
 
fd80067
 
 
 
 
 
 
 
 
 
 
430f700
 
 
 
 
fd80067
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430f700
fd80067
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
title: Modular Detector V2
emoji: 🧭
colorFrom: indigo
colorTo: blue
sdk: docker
pinned: false
license: mit
short_description: Modular addition helper.
---

Local run:

```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload
```

Open http://127.0.0.1:8000

Default embedding model: `Qwen/Qwen3-Embedding-0.6B`
Default dataset: `Molbap/modular-detector-embeddings`

Note: The embedding model and the index must match. If you change the model, you must rebuild and re-upload the index.

Rebuild method index (from repo root, expects transformers clone at `./transformers` or `./transformers_repo`):

```bash
python scripts/build_index.py
```

Quick inference (curl):

```bash
curl -s http://127.0.0.1:8000/api/analyze \
  -H "Content-Type: application/json" \
  -d '{
    "code": "class Foo:\n    def forward(self,x):\n        return x\n",
    "top_k": 5,
    "granularity": "method",
    "precision": "float32"
  }' | jq
```

Push app to Space:

```bash
hf upload --repo-type space Molbap/modular-detector-v2 . \
  --include "Dockerfile" \
  --include "requirements.txt" \
  --include "README.md" \
  --include "app/**" \
  --include "static/**" \
  --commit-message "Update app"
```

Push method index to dataset:

```bash
hf upload --repo-type dataset Molbap/modular-detector-embeddings . \
  --include "embeddings_methods.safetensors" \
  --include "code_index_map_methods.json" \
  --include "code_index_tokens_methods.json" \
  --commit-message "Update method index"
```