mi-crow 0.1.1.post12__tar.gz → 0.1.1.post13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.cursor/plans/dokumentacja-implementacji-modu-w-i-automatyzacji-83a10087.plan.md +5 -5
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.cursor/plans/server-sae-full-metadata_b869cacf.plan.md +9 -9
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.github/workflows/tests.yml +4 -3
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.gitignore +3 -2
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/PKG-INFO +2 -2
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/README.md +1 -1
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/docs/api/datasets.md +1 -1
- mi_crow-0.1.1.post13/docs/api/hooks.md +26 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/docs/api/index.md +3 -3
- mi_crow-0.1.1.post13/docs/api/language_model.md +24 -0
- mi_crow-0.1.1.post13/docs/api/sae.md +34 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/docs/api/store.md +1 -1
- mi_crow-0.1.1.post13/docs/api.md +7 -0
- mi_crow-0.1.1.post13/docs/index.md +5 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/mkdocs.yml +1 -1
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/pyproject.toml +3 -3
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/raport_implementacji.md +32 -32
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/__init__.py +2 -2
- mi_crow-0.1.1.post13/src/mi_crow/datasets/__init__.py +11 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/datasets/base_dataset.py +2 -2
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/datasets/classification_dataset.py +3 -3
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/datasets/text_dataset.py +3 -3
- mi_crow-0.1.1.post13/src/mi_crow/hooks/__init__.py +20 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/hooks/controller.py +3 -3
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/hooks/detector.py +2 -2
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/hooks/hook.py +1 -1
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/hooks/implementations/function_controller.py +2 -2
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/hooks/implementations/layer_activation_detector.py +3 -3
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/hooks/implementations/model_input_detector.py +2 -2
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/hooks/implementations/model_output_detector.py +2 -2
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/hooks/utils.py +1 -1
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/activations.py +9 -9
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/context.py +3 -3
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/hook_metadata.py +1 -1
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/inference.py +7 -7
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/initialization.py +3 -3
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/language_model.py +11 -11
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/layers.py +4 -4
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/persistence.py +7 -7
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/tokenizer.py +1 -1
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/autoencoder_context.py +1 -1
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/concepts/autoencoder_concepts.py +8 -8
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/concepts/concept_dictionary.py +1 -1
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/concepts/input_tracker.py +2 -2
- mi_crow-0.1.1.post13/src/mi_crow/mechanistic/sae/modules/__init__.py +5 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/modules/l1_sae.py +17 -17
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/modules/topk_sae.py +18 -18
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/sae.py +9 -9
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/sae_trainer.py +7 -7
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/training/wandb_logger.py +2 -2
- mi_crow-0.1.1.post13/src/mi_crow/store/__init__.py +5 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/store/local_store.py +1 -1
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/store/store_dataloader.py +2 -2
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/utils.py +1 -1
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/src/mi_crow.egg-info/PKG-INFO +2 -2
- mi_crow-0.1.1.post13/src/mi_crow.egg-info/SOURCES.txt +79 -0
- mi_crow-0.1.1.post13/src/mi_crow.egg-info/top_level.txt +1 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/uv.lock +105 -105
- mi_crow-0.1.1.post12/docs/api/hooks.md +0 -26
- mi_crow-0.1.1.post12/docs/api/language_model.md +0 -24
- mi_crow-0.1.1.post12/docs/api/sae.md +0 -34
- mi_crow-0.1.1.post12/docs/api.md +0 -7
- mi_crow-0.1.1.post12/docs/index.md +0 -5
- mi_crow-0.1.1.post12/src/amber/datasets/__init__.py +0 -11
- mi_crow-0.1.1.post12/src/amber/hooks/__init__.py +0 -20
- mi_crow-0.1.1.post12/src/amber/mechanistic/sae/modules/__init__.py +0 -5
- mi_crow-0.1.1.post12/src/amber/store/__init__.py +0 -5
- mi_crow-0.1.1.post12/src/mi_crow.egg-info/SOURCES.txt +0 -79
- mi_crow-0.1.1.post12/src/mi_crow.egg-info/top_level.txt +0 -1
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.cursor/commands/fix-and-add-unit-tests.md +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.cursor/commands/refactor-given-code.md +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.cursor/rules/coding-rules.mdc +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.cursor/rules/comments.mdc +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.github/workflows/docs.yml +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.github/workflows/publish.yml +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.pre-commit-config.yaml +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.python-version +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/.run/Unit tests.run.xml +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/MANIFEST.in +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/setup.cfg +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/datasets/loading_strategy.py +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/hooks/implementations/__init__.py +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/__init__.py +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/contracts.py +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/language_model/utils.py +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/__init__.py +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/__init__.py +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/concepts/__init__.py +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/mechanistic/sae/concepts/concept_models.py +0 -0
- {mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/store/store.py +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/src/mi_crow.egg-info/dependency_links.txt +0 -0
- {mi_crow-0.1.1.post12 → mi_crow-0.1.1.post13}/src/mi_crow.egg-info/requires.txt +0 -0
|
@@ -69,14 +69,14 @@ Jeden plik Markdown (np. `raport.md` lub `raport_implementacji.md`) w katalogu g
|
|
|
69
69
|
|
|
70
70
|
## 2. Implementacja modułów
|
|
71
71
|
|
|
72
|
-
### 2.1 Moduł `
|
|
72
|
+
### 2.1 Moduł `mi_crow.datasets`
|
|
73
73
|
|
|
74
74
|
- **BaseDataset**: Klasa abstrakcyjna z LoadingStrategy (MEMORY, DYNAMIC_LOAD, ITERABLE_ONLY)
|
|
75
75
|
- **TextDataset**: Dataset tekstowy z parametrem `text_field`
|
|
76
76
|
- **ClassificationDataset**: Dataset z kategoriami, parametry `text_field`, `category_field` (single/multiple)
|
|
77
77
|
- **LoadingStrategy**: Enum z trzema strategiami ładowania
|
|
78
78
|
|
|
79
|
-
### 2.2 Moduł `
|
|
79
|
+
### 2.2 Moduł `mi_crow.hooks`
|
|
80
80
|
|
|
81
81
|
- **Hook**: Klasa abstrakcyjna, parametry: `layer_signature`, `hook_type` (FORWARD/PRE_FORWARD), `hook_id`
|
|
82
82
|
- **Detector**: Hook do wykrywania/zapisywania aktywacji
|
|
@@ -84,7 +84,7 @@ Jeden plik Markdown (np. `raport.md` lub `raport_implementacji.md`) w katalogu g
|
|
|
84
84
|
- **LayerActivationDetector**: Implementacja zapisywania aktywacji warstw
|
|
85
85
|
- **FunctionController**: Implementacja kontrolera funkcji
|
|
86
86
|
|
|
87
|
-
### 2.3 Moduł `
|
|
87
|
+
### 2.3 Moduł `mi_crow.language_model`
|
|
88
88
|
|
|
89
89
|
- **LanguageModel**: Główna klasa wrappera modelu
|
|
90
90
|
- Parametry inicjalizacji: `model`, `tokenizer`, `store`, `model_id`
|
|
@@ -95,7 +95,7 @@ Jeden plik Markdown (np. `raport.md` lub `raport_implementacji.md`) w katalogu g
|
|
|
95
95
|
- **LanguageModelTokenizer**: Wrapper tokenizera
|
|
96
96
|
- **InferenceEngine**: Silnik inferencji z parametrami `autocast`, `autocast_dtype`, `with_controllers`
|
|
97
97
|
|
|
98
|
-
### 2.4 Moduł `
|
|
98
|
+
### 2.4 Moduł `mi_crow.mechanistic.sae` (moduły uczenia maszynowego)
|
|
99
99
|
|
|
100
100
|
- **Sae**: Klasa abstrakcyjna SAE
|
|
101
101
|
- Parametry: `n_latents`, `n_inputs`, `hook_id`, `device`, `store`
|
|
@@ -111,7 +111,7 @@ Jeden plik Markdown (np. `raport.md` lub `raport_implementacji.md`) w katalogu g
|
|
|
111
111
|
- **AutoencoderContext**: Kontekst SAE z parametrami: `n_latents`, `n_inputs`, `device`, `text_tracking_enabled`, `text_tracking_k`
|
|
112
112
|
- **AutoencoderConcepts**: Zarządzanie konceptami (multiplication, bias)
|
|
113
113
|
|
|
114
|
-
### 2.5 Moduł `
|
|
114
|
+
### 2.5 Moduł `mi_crow.store`
|
|
115
115
|
|
|
116
116
|
- **Store**: Klasa abstrakcyjna do przechowywania tensorów
|
|
117
117
|
- Parametry: `base_path`, `runs_prefix`, `dataset_prefix`, `model_prefix`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: server-sae-full-metadata
|
|
3
|
-
overview: "Wire server to
|
|
3
|
+
overview: "Wire server to mi_crow SAE without touching core library: LocalStore-based activations, real SAE training/inference, concept application, and enriched responses."
|
|
4
4
|
todos: []
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -10,21 +10,21 @@ todos: []
|
|
|
10
10
|
|
|
11
11
|
b
|
|
12
12
|
|
|
13
|
-
- Only modify server code; reuse
|
|
13
|
+
- Only modify server code; reuse mi_crow APIs as-is.
|
|
14
14
|
- Use LocalStore for activations, real SaeTrainer for training, and Sae hook for inference/top-texts.
|
|
15
|
-
- Concept handling via existing
|
|
15
|
+
- Concept handling via existing mi_crow concept classes; no edits to mi_crow package.
|
|
16
16
|
|
|
17
17
|
## Plan
|
|
18
18
|
|
|
19
19
|
1) **Activation Pipeline → LocalStore**
|
|
20
20
|
|
|
21
|
-
- Update `/sae/activations/save` to write activations into `
|
|
21
|
+
- Update `/sae/activations/save` to write activations into `mi_crow.store.LocalStore` under `artifact_base_path` using `run_id`/batch/layer keys.
|
|
22
22
|
- Keep manifest with run_id, layers, dataset info, token counts, batch indices.
|
|
23
23
|
- Add layer-existence check (already present) and bounds on batch/sample size.
|
|
24
24
|
|
|
25
25
|
2) **SAE Training (real)**
|
|
26
26
|
|
|
27
|
-
- In `/sae/train`, load LocalStore with run_id/layer from manifest; build `SaeTrainingConfig` from payload; call `SaeTrainer.train` on the selected SAE class (chosen by payload or default) without modifying
|
|
27
|
+
- In `/sae/train`, load LocalStore with run_id/layer from manifest; build `SaeTrainingConfig` from payload; call `SaeTrainer.train` on the selected SAE class (chosen by payload or default) without modifying mi_crow code.
|
|
28
28
|
- Save SAE checkpoint via its `save` method alongside training metadata (history, config, metrics) in `artifact_base_path/sae/<model>/<run>/`.
|
|
29
29
|
- Return sae_id/sae_path/metadata_path from the job result.
|
|
30
30
|
|
|
@@ -36,9 +36,9 @@ b
|
|
|
36
36
|
|
|
37
37
|
4) **Concepts Integration**
|
|
38
38
|
|
|
39
|
-
- `/sae/concepts/load`: parse user file into
|
|
39
|
+
- `/sae/concepts/load`: parse user file into mi_crow concepts/dictionary; validate against SAE dims; persist normalized concept file under concepts dir.
|
|
40
40
|
- `/sae/concepts/manipulate`: accept weights/edits; build a concept-config mapping to neuron weights; persist config.
|
|
41
|
-
- `/sae/infer` accepts concept_config to adjust activations/decoder via SAE hook before generation (no
|
|
41
|
+
- `/sae/infer` accepts concept_config to adjust activations/decoder via SAE hook before generation (no mi_crow code changes—use available hook points).
|
|
42
42
|
|
|
43
43
|
5) **Jobs & Observability**
|
|
44
44
|
|
|
@@ -46,10 +46,10 @@ b
|
|
|
46
46
|
|
|
47
47
|
6) **Testing & Docs**
|
|
48
48
|
|
|
49
|
-
- Extend server tests with small dummy SAE class implementing `save/load/encode/decode` to cover training/inference flows without touching
|
|
49
|
+
- Extend server tests with small dummy SAE class implementing `save/load/encode/decode` to cover training/inference flows without touching mi_crow; mock LocalStore I/O.
|
|
50
50
|
- Update README with new expectations: activations in LocalStore, real training path, concept flow, top-text outputs, and job responses.
|
|
51
51
|
|
|
52
52
|
## Notes
|
|
53
53
|
|
|
54
|
-
- No changes to
|
|
54
|
+
- No changes to mi_crow core; all integrations via its public classes (LocalStore, SaeTrainer, Sae, concepts).
|
|
55
55
|
- Keep payload schemas mostly stable; only enrich responses with sae/metadata paths and top-text summaries.
|
|
@@ -34,9 +34,10 @@ jobs:
|
|
|
34
34
|
|
|
35
35
|
- name: Verify package installation
|
|
36
36
|
run: |
|
|
37
|
-
python -c "import
|
|
38
|
-
python -c "import
|
|
39
|
-
python -c "
|
|
37
|
+
python -c "import mi_crow; print('✓ mi_crow package found')"
|
|
38
|
+
python -c "import sys; import os; import mi_crow; print('mi_crow location:', mi_crow.__file__); print('mi_crow.__path__:', getattr(mi_crow, '__path__', 'NOT SET')); store_dir = os.path.join(os.path.dirname(mi_crow.__file__), 'store'); print('store dir exists:', os.path.exists(store_dir)); print('store/__init__.py exists:', os.path.exists(os.path.join(store_dir, '__init__.py')))"
|
|
39
|
+
python -c "import mi_crow.store; print('✓ mi_crow.store package found')"
|
|
40
|
+
python -c "from mi_crow.store.store import Store; print('✓ Store import successful')"
|
|
40
41
|
|
|
41
42
|
- name: Run tests with coverage threshold
|
|
42
43
|
run: |
|
|
@@ -92,7 +92,8 @@ outputs
|
|
|
92
92
|
# experiments
|
|
93
93
|
.llm_context/
|
|
94
94
|
results/
|
|
95
|
-
store/
|
|
95
|
+
# Exclude data store directories but NOT src/mi_crow/store/ (package code)
|
|
96
|
+
/experiments/*/store/
|
|
96
97
|
|
|
97
98
|
# frontend
|
|
98
99
|
src/frontend/node_modules/
|
|
@@ -100,4 +101,4 @@ src/frontend/dist/
|
|
|
100
101
|
src/frontend/build/
|
|
101
102
|
src/frontend/.next/
|
|
102
103
|
|
|
103
|
-
|
|
104
|
+
mi_crow_server
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mi-crow
|
|
3
|
-
Version: 0.1.1.
|
|
3
|
+
Version: 0.1.1.post13
|
|
4
4
|
Summary: Engineer Thesis: Explaining and modifying LLM responses using SAE and concepts.
|
|
5
5
|
Author-email: Hubert Kowalski <your.email@example.com>, Adam Kaniasty <adam.kaniasty@gmail.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -96,7 +96,7 @@ uv run --group server pytest tests/server/test_api.py --cov=server --cov-fail-un
|
|
|
96
96
|
|
|
97
97
|
### SAE API usage
|
|
98
98
|
|
|
99
|
-
- Configure artifact location (optional): `export SERVER_ARTIFACT_BASE_PATH=/path/to/
|
|
99
|
+
- Configure artifact location (optional): `export SERVER_ARTIFACT_BASE_PATH=/path/to/mi_crow_artifacts` (defaults to `~/.cache/mi_crow_server`)
|
|
100
100
|
- Load a model: `curl -X POST http://localhost:8000/models/load -H "Content-Type: application/json" -d '{"model_id":"bielik"}'`
|
|
101
101
|
- Save activations from dataset (stored in `LocalStore` under `activations/<model>/<run_id>`):
|
|
102
102
|
- HF dataset: `{"dataset":{"type":"hf","name":"ag_news","split":"train","text_field":"text"}}`
|
|
@@ -58,7 +58,7 @@ uv run --group server pytest tests/server/test_api.py --cov=server --cov-fail-un
|
|
|
58
58
|
|
|
59
59
|
### SAE API usage
|
|
60
60
|
|
|
61
|
-
- Configure artifact location (optional): `export SERVER_ARTIFACT_BASE_PATH=/path/to/
|
|
61
|
+
- Configure artifact location (optional): `export SERVER_ARTIFACT_BASE_PATH=/path/to/mi_crow_artifacts` (defaults to `~/.cache/mi_crow_server`)
|
|
62
62
|
- Load a model: `curl -X POST http://localhost:8000/models/load -H "Content-Type: application/json" -d '{"model_id":"bielik"}'`
|
|
63
63
|
- Save activations from dataset (stored in `LocalStore` under `activations/<model>/<run_id>`):
|
|
64
64
|
- HF dataset: `{"dataset":{"type":"hf","name":"ag_news","split":"train","text_field":"text"}}`
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Hooks API
|
|
2
|
+
|
|
3
|
+
Hook system for intercepting and managing model activations during inference.
|
|
4
|
+
|
|
5
|
+
## Core Hook Classes
|
|
6
|
+
|
|
7
|
+
::: mi_crow.hooks.hook.Hook
|
|
8
|
+
|
|
9
|
+
::: mi_crow.hooks.detector.Detector
|
|
10
|
+
|
|
11
|
+
::: mi_crow.hooks.controller.Controller
|
|
12
|
+
|
|
13
|
+
## Implementations
|
|
14
|
+
|
|
15
|
+
::: mi_crow.hooks.implementations.layer_activation_detector.LayerActivationDetector
|
|
16
|
+
|
|
17
|
+
::: mi_crow.hooks.implementations.model_input_detector.ModelInputDetector
|
|
18
|
+
|
|
19
|
+
::: mi_crow.hooks.implementations.model_output_detector.ModelOutputDetector
|
|
20
|
+
|
|
21
|
+
::: mi_crow.hooks.implementations.function_controller.FunctionController
|
|
22
|
+
|
|
23
|
+
## Utilities
|
|
24
|
+
|
|
25
|
+
::: mi_crow.hooks.utils
|
|
26
|
+
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# API Reference
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
mi_crow's public Python API is documented automatically from docstrings.
|
|
4
4
|
|
|
5
|
-
The top-level `
|
|
5
|
+
The top-level `mi_crow` package is intentionally minimal (it only exports things
|
|
6
6
|
like `ping`). The real functionality lives in subpackages, which are documented
|
|
7
7
|
in the sections below.
|
|
8
8
|
|
|
@@ -16,5 +16,5 @@ in the sections below.
|
|
|
16
16
|
|
|
17
17
|
## Top-level Package
|
|
18
18
|
|
|
19
|
-
:::
|
|
19
|
+
::: mi_crow
|
|
20
20
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Language Model API
|
|
2
|
+
|
|
3
|
+
Core language model functionality for loading models, running inference, and managing activations.
|
|
4
|
+
|
|
5
|
+
## Main Classes
|
|
6
|
+
|
|
7
|
+
::: mi_crow.language_model.language_model.LanguageModel
|
|
8
|
+
|
|
9
|
+
::: mi_crow.language_model.context.LanguageModelContext
|
|
10
|
+
|
|
11
|
+
::: mi_crow.language_model.layers.LanguageModelLayers
|
|
12
|
+
|
|
13
|
+
::: mi_crow.language_model.tokenizer.LanguageModelTokenizer
|
|
14
|
+
|
|
15
|
+
::: mi_crow.language_model.activations.LanguageModelActivations
|
|
16
|
+
|
|
17
|
+
::: mi_crow.language_model.inference.InferenceEngine
|
|
18
|
+
|
|
19
|
+
## Utilities
|
|
20
|
+
|
|
21
|
+
::: mi_crow.language_model.initialization
|
|
22
|
+
|
|
23
|
+
::: mi_crow.language_model.persistence
|
|
24
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Sparse Autoencoder (SAE) API
|
|
2
|
+
|
|
3
|
+
Sparse Autoencoders, training, concepts, and related modules for mechanistic interpretability.
|
|
4
|
+
|
|
5
|
+
## Core SAE Classes
|
|
6
|
+
|
|
7
|
+
::: mi_crow.mechanistic.sae.sae.Sae
|
|
8
|
+
|
|
9
|
+
::: mi_crow.mechanistic.sae.modules.topk_sae.TopKSae
|
|
10
|
+
|
|
11
|
+
::: mi_crow.mechanistic.sae.autoencoder_context.AutoencoderContext
|
|
12
|
+
|
|
13
|
+
## Training
|
|
14
|
+
|
|
15
|
+
::: mi_crow.mechanistic.sae.sae_trainer.SaeTrainer
|
|
16
|
+
|
|
17
|
+
::: mi_crow.mechanistic.sae.sae_trainer.SaeTrainingConfig
|
|
18
|
+
|
|
19
|
+
::: mi_crow.mechanistic.sae.modules.topk_sae.TopKSaeTrainingConfig
|
|
20
|
+
|
|
21
|
+
## Concepts
|
|
22
|
+
|
|
23
|
+
::: mi_crow.mechanistic.sae.concepts.autoencoder_concepts.AutoencoderConcepts
|
|
24
|
+
|
|
25
|
+
::: mi_crow.mechanistic.sae.concepts.concept_dictionary.ConceptDictionary
|
|
26
|
+
|
|
27
|
+
::: mi_crow.mechanistic.sae.concepts.concept_models
|
|
28
|
+
|
|
29
|
+
::: mi_crow.mechanistic.sae.concepts.input_tracker.InputTracker
|
|
30
|
+
|
|
31
|
+
## Training Utilities
|
|
32
|
+
|
|
33
|
+
::: mi_crow.mechanistic.sae.training.wandb_logger.WandbLogger
|
|
34
|
+
|
|
@@ -50,13 +50,13 @@ docs = [
|
|
|
50
50
|
]
|
|
51
51
|
|
|
52
52
|
[tool.pytest.ini_options]
|
|
53
|
-
addopts = "--maxfail=1 -q --cov=
|
|
53
|
+
addopts = "--maxfail=1 -q --cov=mi_crow --cov-report=term-missing --cov-report=xml --cov-fail-under=85"
|
|
54
54
|
testpaths = ["tests"]
|
|
55
55
|
pythonpath = ["src"]
|
|
56
56
|
|
|
57
57
|
[tool.coverage.run]
|
|
58
58
|
branch = true
|
|
59
|
-
source = ["
|
|
59
|
+
source = ["mi_crow"]
|
|
60
60
|
parallel = true
|
|
61
61
|
|
|
62
62
|
[tool.coverage.report]
|
|
@@ -72,7 +72,7 @@ directory = "htmlcov"
|
|
|
72
72
|
|
|
73
73
|
[tool.setuptools.packages.find]
|
|
74
74
|
where = ["src"]
|
|
75
|
-
include = ["
|
|
75
|
+
include = ["mi_crow*"]
|
|
76
76
|
exclude = ["server*", "frontend*"]
|
|
77
77
|
|
|
78
78
|
[tool.setuptools_scm]
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
### 1.4 Testy i coverage (pytest)
|
|
46
46
|
|
|
47
47
|
**Konfiguracja**: Sekcja `[tool.pytest.ini_options]` w `pyproject.toml`:
|
|
48
|
-
- `addopts = "--maxfail=1 -q --cov=
|
|
48
|
+
- `addopts = "--maxfail=1 -q --cov=mi_crow --cov-report=term-missing --cov-report=xml --cov-fail-under=90"`
|
|
49
49
|
- `testpaths = ["tests"]`
|
|
50
50
|
- `pythonpath = ["src"]`
|
|
51
51
|
|
|
@@ -96,9 +96,9 @@
|
|
|
96
96
|
|
|
97
97
|
## 2. Implementacja modułów
|
|
98
98
|
|
|
99
|
-
### 2.1 Moduł
|
|
99
|
+
### 2.1 Moduł mi_crow.datasets
|
|
100
100
|
|
|
101
|
-
**BaseDataset** (`src/
|
|
101
|
+
**BaseDataset** (`src/mi_crow/datasets/base_dataset.py`):
|
|
102
102
|
- Klasa abstrakcyjna bazowa dla wszystkich datasetów
|
|
103
103
|
- Parametry inicjalizacji:
|
|
104
104
|
- `ds`: `Dataset | IterableDataset` - dataset HuggingFace
|
|
@@ -106,13 +106,13 @@
|
|
|
106
106
|
- `loading_strategy`: `LoadingStrategy` - strategia ładowania (domyślnie `MEMORY`)
|
|
107
107
|
- Metody abstrakcyjne: `__getitem__()`, `__len__()`, `__iter__()`
|
|
108
108
|
|
|
109
|
-
**LoadingStrategy** (`src/
|
|
109
|
+
**LoadingStrategy** (`src/mi_crow/datasets/loading_strategy.py`):
|
|
110
110
|
- Enum z trzema strategiami:
|
|
111
111
|
- `MEMORY`: Ładowanie całego datasetu do pamięci (najszybszy dostęp, najwyższe użycie pamięci)
|
|
112
112
|
- `DYNAMIC_LOAD`: Zapis na dysk, odczyt dynamiczny przez memory-mapped Arrow files (obsługuje len/getitem, niższe użycie pamięci)
|
|
113
113
|
- `ITERABLE_ONLY`: Prawdziwy streaming używając IterableDataset (najniższe użycie pamięci, brak wsparcia dla len/getitem)
|
|
114
114
|
|
|
115
|
-
**TextDataset** (`src/
|
|
115
|
+
**TextDataset** (`src/mi_crow/datasets/text_dataset.py`):
|
|
116
116
|
- Dataset tekstowy dziedziczący z `BaseDataset`
|
|
117
117
|
- Parametry:
|
|
118
118
|
- `ds`: `Dataset | IterableDataset`
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
- `loading_strategy`: `LoadingStrategy` (domyślnie `MEMORY`)
|
|
121
121
|
- `text_field`: `str` - nazwa kolumny z tekstem (domyślnie `"text"`)
|
|
122
122
|
|
|
123
|
-
**ClassificationDataset** (`src/
|
|
123
|
+
**ClassificationDataset** (`src/mi_crow/datasets/classification_dataset.py`):
|
|
124
124
|
- Dataset z kategoriami dziedziczący z `BaseDataset`
|
|
125
125
|
- Parametry:
|
|
126
126
|
- `ds`: `Dataset | IterableDataset`
|
|
@@ -129,9 +129,9 @@
|
|
|
129
129
|
- `text_field`: `str` - nazwa kolumny z tekstem (domyślnie `"text"`)
|
|
130
130
|
- `category_field`: `Union[str, List[str]]` - nazwa kolumny(ów) z kategorią/etykietą (domyślnie `"category"`), obsługuje pojedyncze lub wielokrotne etykiety
|
|
131
131
|
|
|
132
|
-
### 2.2 Moduł
|
|
132
|
+
### 2.2 Moduł mi_crow.hooks
|
|
133
133
|
|
|
134
|
-
**Hook** (`src/
|
|
134
|
+
**Hook** (`src/mi_crow/hooks/hook.py`):
|
|
135
135
|
- Klasa abstrakcyjna bazowa dla wszystkich hooków
|
|
136
136
|
- Parametry inicjalizacji:
|
|
137
137
|
- `layer_signature`: `str | int | None` - nazwa lub indeks warstwy do podpięcia hooka
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
- `hook_id`: `str | None` - unikalny identyfikator (auto-generowany jeśli nie podany)
|
|
140
140
|
- `HookType` Enum: `FORWARD`, `PRE_FORWARD`
|
|
141
141
|
|
|
142
|
-
**Detector** (`src/
|
|
142
|
+
**Detector** (`src/mi_crow/hooks/detector.py`):
|
|
143
143
|
- Klasa abstrakcyjna dziedzicząca z `Hook` do wykrywania/zapisywania aktywacji
|
|
144
144
|
- Parametry:
|
|
145
145
|
- `hook_type`: `HookType | str` (domyślnie `HookType.FORWARD`)
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
- `layer_signature`: `str | int | None`
|
|
149
149
|
- Atrybuty: `metadata: Dict[str, Any]`, `tensor_metadata: Dict[str, torch.Tensor]`
|
|
150
150
|
|
|
151
|
-
**Controller** (`src/
|
|
151
|
+
**Controller** (`src/mi_crow/hooks/controller.py`):
|
|
152
152
|
- Klasa abstrakcyjna dziedzicząca z `Hook` do modyfikacji aktywacji
|
|
153
153
|
- Parametry:
|
|
154
154
|
- `hook_type`: `HookType | str` (domyślnie `HookType.FORWARD`)
|
|
@@ -156,17 +156,17 @@
|
|
|
156
156
|
- `layer_signature`: `str | int | None`
|
|
157
157
|
- Może modyfikować wejścia (pre_forward) lub wyjścia (forward) warstw
|
|
158
158
|
|
|
159
|
-
**LayerActivationDetector** (`src/
|
|
159
|
+
**LayerActivationDetector** (`src/mi_crow/hooks/implementations/activation_saver.py`):
|
|
160
160
|
- Implementacja `Detector` do zapisywania aktywacji warstw
|
|
161
161
|
- Zapisuje aktywacje do Store podczas forward pass
|
|
162
162
|
|
|
163
|
-
**FunctionController** (`src/
|
|
163
|
+
**FunctionController** (`src/mi_crow/hooks/implementations/function_controller.py`):
|
|
164
164
|
- Implementacja `Controller` do kontroli funkcji
|
|
165
165
|
- Pozwala na modyfikację aktywacji przez funkcję użytkownika
|
|
166
166
|
|
|
167
|
-
### 2.3 Moduł
|
|
167
|
+
### 2.3 Moduł mi_crow.language_model
|
|
168
168
|
|
|
169
|
-
**LanguageModel** (`src/
|
|
169
|
+
**LanguageModel** (`src/mi_crow/language_model/language_model.py`):
|
|
170
170
|
- Główna klasa wrappera modelu językowego
|
|
171
171
|
- Parametry inicjalizacji:
|
|
172
172
|
- `model`: `nn.Module` - model PyTorch
|
|
@@ -183,19 +183,19 @@
|
|
|
183
183
|
- `from_local_torch(model_path, tokenizer_path, store)` - ładowanie z lokalnych ścieżek HuggingFace
|
|
184
184
|
- `from_local(saved_path, store, model_id)` - ładowanie z zapisanego pliku
|
|
185
185
|
|
|
186
|
-
**LanguageModelLayers** (`src/
|
|
186
|
+
**LanguageModelLayers** (`src/mi_crow/language_model/layers.py`):
|
|
187
187
|
- Zarządzanie warstwami i hookami
|
|
188
188
|
- Metody do rejestracji/odrejestracji hooków na warstwach
|
|
189
189
|
|
|
190
|
-
**LanguageModelActivations** (`src/
|
|
190
|
+
**LanguageModelActivations** (`src/mi_crow/language_model/activations.py`):
|
|
191
191
|
- Zarządzanie aktywacjami modelu
|
|
192
192
|
- Dostęp do zapisanych aktywacji z Store
|
|
193
193
|
|
|
194
|
-
**LanguageModelTokenizer** (`src/
|
|
194
|
+
**LanguageModelTokenizer** (`src/mi_crow/language_model/tokenizer.py`):
|
|
195
195
|
- Wrapper tokenizera
|
|
196
196
|
- Ujednolicony interfejs do operacji tokenizacji
|
|
197
197
|
|
|
198
|
-
**InferenceEngine** (`src/
|
|
198
|
+
**InferenceEngine** (`src/mi_crow/language_model/inference.py`):
|
|
199
199
|
- Silnik inferencji dla LanguageModel
|
|
200
200
|
- Parametry metody `execute_inference()`:
|
|
201
201
|
- `texts`: `Sequence[str]` - sekwencja tekstów wejściowych
|
|
@@ -204,13 +204,13 @@
|
|
|
204
204
|
- `autocast_dtype`: `torch.dtype | None` - opcjonalny dtype dla autocast
|
|
205
205
|
- `with_controllers`: `bool` - użycie controllerów podczas inferencji (domyślnie `True`)
|
|
206
206
|
|
|
207
|
-
**LanguageModelContext** (`src/
|
|
207
|
+
**LanguageModelContext** (`src/mi_crow/language_model/context.py`):
|
|
208
208
|
- Dataclass z kontekstem współdzielonym dla LanguageModel i jego komponentów
|
|
209
209
|
- Zawiera: `model`, `tokenizer`, `model_id`, `store`, `device`, `dtype`, rejestry hooków
|
|
210
210
|
|
|
211
|
-
### 2.4 Moduł
|
|
211
|
+
### 2.4 Moduł mi_crow.mechanistic.sae (moduły uczenia maszynowego)
|
|
212
212
|
|
|
213
|
-
**Sae** (`src/
|
|
213
|
+
**Sae** (`src/mi_crow/mechanistic/sae/sae.py`):
|
|
214
214
|
- Klasa abstrakcyjna dziedzicząca z `Controller` i `Detector`
|
|
215
215
|
- Parametry inicjalizacji:
|
|
216
216
|
- `n_latents`: `int` - liczba neuronów latentnych
|
|
@@ -225,19 +225,19 @@
|
|
|
225
225
|
- `modify_activations(module, inputs, output) -> torch.Tensor | None` - modyfikacja aktywacji (Controller)
|
|
226
226
|
- `save(name: str)` - zapis modelu
|
|
227
227
|
|
|
228
|
-
**TopKSae** (`src/
|
|
228
|
+
**TopKSae** (`src/mi_crow/mechanistic/sae/modules/topk_sae.py`):
|
|
229
229
|
- Implementacja TopK SAE dziedzicząca z `Sae`
|
|
230
230
|
- Dodatkowy parametr: `k: int` - liczba aktywnych neuronów (TopK)
|
|
231
231
|
- Metody:
|
|
232
232
|
- `train(store, run_id, layer_signature, config)` - trening SAE używając aktywacji z Store
|
|
233
|
-
- `save(name, path)` - zapis modelu (overcomplete state dict + metadata
|
|
233
|
+
- `save(name, path)` - zapis modelu (overcomplete state dict + metadata mi_crow)
|
|
234
234
|
- `load(path)` - statyczna metoda do ładowania TopKSae z pliku
|
|
235
235
|
|
|
236
|
-
**SaeTrainer** (`src/
|
|
236
|
+
**SaeTrainer** (`src/mi_crow/mechanistic/sae/sae_trainer.py`):
|
|
237
237
|
- Klasa trenująca SAE używając funkcji z biblioteki `overcomplete`
|
|
238
238
|
- Metoda `train(store, run_id, layer_signature, config)` - główna metoda treningu
|
|
239
239
|
|
|
240
|
-
**SaeTrainingConfig** (`src/
|
|
240
|
+
**SaeTrainingConfig** (`src/mi_crow/mechanistic/sae/sae_trainer.py`):
|
|
241
241
|
- Dataclass z konfiguracją treningu SAE
|
|
242
242
|
- Parametry treningu:
|
|
243
243
|
- `epochs`: `int` (domyślnie 1)
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
- `wandb_mode`: `str` - tryb wandb: "online", "offline", "disabled" (domyślnie "online")
|
|
266
266
|
- `wandb_slow_metrics_frequency`: `int` - częstotliwość logowania wolnych metryk (L0, dead features) (domyślnie 50)
|
|
267
267
|
|
|
268
|
-
**AutoencoderContext** (`src/
|
|
268
|
+
**AutoencoderContext** (`src/mi_crow/mechanistic/sae/autoencoder_context.py`):
|
|
269
269
|
- Dataclass z kontekstem SAE
|
|
270
270
|
- Parametry:
|
|
271
271
|
- `autoencoder`: `Sae` - instancja SAE
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
- `bias_init`: `float` (domyślnie 0.0)
|
|
286
286
|
- `init_method`: `str` (domyślnie "kaiming")
|
|
287
287
|
|
|
288
|
-
**AutoencoderConcepts** (`src/
|
|
288
|
+
**AutoencoderConcepts** (`src/mi_crow/mechanistic/sae/concepts/autoencoder_concepts.py`):
|
|
289
289
|
- Zarządzanie konceptami SAE
|
|
290
290
|
- Parametry manipulacji konceptami:
|
|
291
291
|
- `multiplication`: `nn.Parameter` - mnożnik dla każdego neuronu (domyślnie ones)
|
|
@@ -295,12 +295,12 @@
|
|
|
295
295
|
- `disable_text_tracking()` - wyłączenie śledzenia tekstów
|
|
296
296
|
- Atrybut: `dictionary: ConceptDictionary | None` - słownik konceptów
|
|
297
297
|
|
|
298
|
-
**ConceptDictionary** (`src/
|
|
298
|
+
**ConceptDictionary** (`src/mi_crow/mechanistic/sae/concepts/concept_dictionary.py`):
|
|
299
299
|
- Słownik konceptów z neuronami i ich tekstami
|
|
300
300
|
|
|
301
|
-
### 2.5 Moduł
|
|
301
|
+
### 2.5 Moduł mi_crow.store
|
|
302
302
|
|
|
303
|
-
**Store** (`src/
|
|
303
|
+
**Store** (`src/mi_crow/store/store.py`):
|
|
304
304
|
- Klasa abstrakcyjna do przechowywania tensorów
|
|
305
305
|
- Parametry inicjalizacji:
|
|
306
306
|
- `base_path`: `Path | str` - bazowa ścieżka katalogu (domyślnie "")
|
|
@@ -319,14 +319,14 @@
|
|
|
319
319
|
- `get_detector_metadata(run_id, batch_index)` - odczyt metadanych detektora
|
|
320
320
|
- `get_detector_metadata_by_layer_by_key(run_id, batch_index, layer, key)` - odczyt konkretnego tensora
|
|
321
321
|
|
|
322
|
-
**LocalStore** (`src/
|
|
322
|
+
**LocalStore** (`src/mi_crow/store/local_store.py`):
|
|
323
323
|
- Implementacja lokalnego przechowywania dziedzicząca z `Store`
|
|
324
324
|
- Używa `safetensors.torch` do zapisu tensorów
|
|
325
325
|
- Metadane zapisywane jako pliki JSON
|
|
326
326
|
- Tensory zapisywane jako pliki safetensors
|
|
327
327
|
- Struktura katalogów: `base_path/runs_prefix/run_id/batch_index/layer_signature/`
|
|
328
328
|
|
|
329
|
-
**StoreDataloader** (`src/
|
|
329
|
+
**StoreDataloader** (`src/mi_crow/store/store_dataloader.py`):
|
|
330
330
|
- DataLoader-like klasa do iteracji po aktywacjach w Store
|
|
331
331
|
- Parametry:
|
|
332
332
|
- `store`: `Store` - instancja Store
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""mi_crow: helper package for the Engineer Thesis project.
|
|
2
2
|
|
|
3
3
|
This module is intentionally minimal. It exists to define the top-level package
|
|
4
4
|
and to enable code coverage to include the package. Importing it should succeed
|
|
@@ -6,7 +6,7 @@ without side effects.
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
# A tiny bit of executable code to make the package measurable by coverage.
|
|
9
|
-
PACKAGE_NAME = "
|
|
9
|
+
PACKAGE_NAME = "mi_crow"
|
|
10
10
|
__version__ = "0.0.0"
|
|
11
11
|
|
|
12
12
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from mi_crow.datasets.base_dataset import BaseDataset
|
|
2
|
+
from mi_crow.datasets.text_dataset import TextDataset
|
|
3
|
+
from mi_crow.datasets.classification_dataset import ClassificationDataset
|
|
4
|
+
from mi_crow.datasets.loading_strategy import LoadingStrategy
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"BaseDataset",
|
|
8
|
+
"TextDataset",
|
|
9
|
+
"ClassificationDataset",
|
|
10
|
+
"LoadingStrategy",
|
|
11
|
+
]
|
{mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/datasets/base_dataset.py
RENAMED
|
@@ -9,8 +9,8 @@ from typing import Any, Dict, Iterator, List, Optional, Union
|
|
|
9
9
|
|
|
10
10
|
from datasets import Dataset, IterableDataset, load_dataset, load_from_disk
|
|
11
11
|
|
|
12
|
-
from
|
|
13
|
-
from
|
|
12
|
+
from mi_crow.datasets.loading_strategy import IndexLike, LoadingStrategy
|
|
13
|
+
from mi_crow.store.store import Store
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class BaseDataset(ABC):
|
|
@@ -5,9 +5,9 @@ from typing import Any, Dict, Iterator, List, Optional, Sequence, Union
|
|
|
5
5
|
|
|
6
6
|
from datasets import Dataset, IterableDataset, load_dataset
|
|
7
7
|
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
8
|
+
from mi_crow.datasets.base_dataset import BaseDataset
|
|
9
|
+
from mi_crow.datasets.loading_strategy import IndexLike, LoadingStrategy
|
|
10
|
+
from mi_crow.store.store import Store
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class ClassificationDataset(BaseDataset):
|
{mi_crow-0.1.1.post12/src/amber → mi_crow-0.1.1.post13/src/mi_crow}/datasets/text_dataset.py
RENAMED
|
@@ -5,9 +5,9 @@ from typing import Any, Dict, Iterator, List, Optional, Sequence, Union
|
|
|
5
5
|
|
|
6
6
|
from datasets import Dataset, IterableDataset, load_dataset
|
|
7
7
|
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
8
|
+
from mi_crow.datasets.base_dataset import BaseDataset
|
|
9
|
+
from mi_crow.datasets.loading_strategy import IndexLike, LoadingStrategy
|
|
10
|
+
from mi_crow.store.store import Store
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class TextDataset(BaseDataset):
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from mi_crow.hooks.hook import Hook, HookType, HookError
|
|
2
|
+
from mi_crow.hooks.detector import Detector
|
|
3
|
+
from mi_crow.hooks.controller import Controller
|
|
4
|
+
from mi_crow.hooks.implementations.layer_activation_detector import LayerActivationDetector
|
|
5
|
+
from mi_crow.hooks.implementations.model_input_detector import ModelInputDetector
|
|
6
|
+
from mi_crow.hooks.implementations.model_output_detector import ModelOutputDetector
|
|
7
|
+
from mi_crow.hooks.implementations.function_controller import FunctionController
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"Hook",
|
|
11
|
+
"HookType",
|
|
12
|
+
"HookError",
|
|
13
|
+
"Detector",
|
|
14
|
+
"Controller",
|
|
15
|
+
"LayerActivationDetector",
|
|
16
|
+
"ModelInputDetector",
|
|
17
|
+
"ModelOutputDetector",
|
|
18
|
+
"FunctionController",
|
|
19
|
+
]
|
|
20
|
+
|
|
@@ -6,9 +6,9 @@ from typing import TYPE_CHECKING
|
|
|
6
6
|
import torch
|
|
7
7
|
import torch.nn as nn
|
|
8
8
|
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
9
|
+
from mi_crow.hooks.hook import Hook, HookType, HOOK_FUNCTION_INPUT, HOOK_FUNCTION_OUTPUT
|
|
10
|
+
from mi_crow.hooks.utils import extract_tensor_from_input, extract_tensor_from_output
|
|
11
|
+
from mi_crow.utils import get_logger
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
14
|
pass
|