File size: 1,712 Bytes
fca1de6
fda8fb3
 
 
 
fca1de6
fda8fb3
 
fca1de6
fda8fb3
2620860
fca1de6
 
fda8fb3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
title: Thought Anchors
emoji: 🧠
colorFrom: blue
colorTo: red
sdk: docker
app_port: 7860
hf_oauth: true
pinned: false
models:
  - sapientinc/HRM-Text-1B
---

# Thought Anchors

Thought Anchors generates visible reasoning traces from open-weight models and
computes sentence-to-sentence influence with gradient x attention attribution.

Current product shape:

- Hugging Face `Docker Space` first
- Hugging Face OAuth sign-in
- web UI + API
- per-user ephemeral sessions
- JSON / CSV export
- adaptive CPU / MPS / CUDA loading

## Quick Start

Install deps:

```bash
uv sync --extra dev
```

Run API:

```bash
uv run python -m app.cli.run_api
```

Run CLI:

```bash
uv run python -m app.cli.run_prototype "Explain why the derivative of x^2 is 2x"
```

Run tests:

```bash
uv run python -m pytest -q
```

## Main Endpoints

- `GET /healthz`
- `GET /api/me`
- `POST /api/warmup`
- `POST /api/analyze`
- `GET /api/sessions`
- `POST /api/sessions`
- `GET /api/sessions/{id}`
- `GET /api/sessions/{id}/result`
- `GET /api/sessions/{id}/export.json`
- `GET /api/sessions/{id}/export.csv`

## Docs

- [Hugging Face deployment](./docs/deploy-huggingface.md)
- [Runtime and model support](./docs/runtime.md)
- [API and product behavior](./docs/api.md)
- [Notebook usage](./docs/notebook.md)

## Notebook

Colab / Kaggle smoke-test notebook:

- [notebooks/hf_space_demo.ipynb](/Users/vibhorkumar/Desktop/codes/cot-anc/notebooks/hf_space_demo.ipynb)

## Key Constraints

- Attribution needs `attn_implementation="eager"`.
- Model must expose supported decoder layers and attention modules.
- Long traces stay capped because analysis uses full backward pass.
- Space disk is ephemeral; export results you want to keep.