superinstance-embedder 0.2.0__cp38-abi3-win_amd64.whl
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.
- superinstance_embedder/__init__.py +5 -0
- superinstance_embedder/superinstance_embedder.pyd +0 -0
- superinstance_embedder-0.2.0.dist-info/METADATA +135 -0
- superinstance_embedder-0.2.0.dist-info/RECORD +7 -0
- superinstance_embedder-0.2.0.dist-info/WHEEL +4 -0
- superinstance_embedder-0.2.0.dist-info/licenses/LICENSE +21 -0
- superinstance_embedder-0.2.0.dist-info/sboms/superinstance-embedder.cyclonedx.json +16917 -0
|
Binary file
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: superinstance-embedder
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: 3
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
8
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Summary: SuperInstance ecosystem semantic embedder — local transformer embeddings with GPU acceleration, hybrid domain+semantic vectors, Qdrant integration
|
|
11
|
+
Author-email: SuperInstance <dev@superinstance.io>
|
|
12
|
+
License: MIT OR Apache-2.0
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
15
|
+
|
|
16
|
+
# SuperInstance Embedder
|
|
17
|
+
|
|
18
|
+
**SuperInstance Embedder** generates 32-dimensional embeddings from crate metadata, encoding each project's position in a 32-domain knowledge space. These "crate DNA" vectors seed Cloudflare Vectorize for semantic search across the SuperInstance ecosystem, enabling queries like "find crates related to ternary GPU computation."
|
|
19
|
+
|
|
20
|
+
## Why It Matters
|
|
21
|
+
|
|
22
|
+
With 100+ crates in the SuperInstance ecosystem, discovering relevant code requires more than keyword search — it requires semantic understanding. The embedder encodes each crate's identity across 32 orthogonal dimensions (ternary-math, agent-coordination, GPU compilation, crypto, distributed-systems, etc.), producing a compact fingerprint that captures cross-domain relationships. A crate at the intersection of "ternary-ml" and "agent-music" is semantically near both, even if its name contains neither word. These embeddings power the crate search engine, dependency recommendations, and fleet synergy detection — automatically identifying which crates could collaborate.
|
|
23
|
+
|
|
24
|
+
## How It Works
|
|
25
|
+
|
|
26
|
+
### Domain Space
|
|
27
|
+
|
|
28
|
+
The 32 dimensions represent orthogonal knowledge domains:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
[ternary-math, ternary-ml, ternary-gpu, ternary-compression,
|
|
32
|
+
agent-coordination, agent-music, agent-cognition, agent-timing,
|
|
33
|
+
oxide-stack, cuda-compiler, character-building, education,
|
|
34
|
+
compression, signal-processing, crypto, distributed,
|
|
35
|
+
testing, formal-verification, creative-writing, physics,
|
|
36
|
+
ecology, game-theory, scheduling, data-structure,
|
|
37
|
+
compiler, runtime, iot, web,
|
|
38
|
+
experimental, meta-cognition, scaling, synergy]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Encoding Rules
|
|
42
|
+
|
|
43
|
+
The embedding is generated from crate metadata (name, description, domain tag, test count, LOC) using heuristic pattern-matching:
|
|
44
|
+
|
|
45
|
+
1. **Domain one-hot**: The declared domain sets that dimension to 1.0
|
|
46
|
+
2. **Cross-domain signals**: Name patterns trigger related dimensions:
|
|
47
|
+
- `"ternary" + "kernel"` → ternary-math (0.7) + ternary-gpu (0.8)
|
|
48
|
+
- `"agent" + "music"` → agent-music (0.8) + agent-cognition (0.5)
|
|
49
|
+
- `"schedule" + "sync"` → agent-timing (0.8) + scheduling (0.5)
|
|
50
|
+
3. **Quality signal**: Test density maps to the testing dimension:
|
|
51
|
+
```
|
|
52
|
+
testing_score = min(1.0, test_count / 30.0)
|
|
53
|
+
```
|
|
54
|
+
4. **LOC signal**: Code volume modulates the relevant domain dimensions
|
|
55
|
+
|
|
56
|
+
All values are clamped to [0, 1], producing a sparse vector with most dimensions at 0.
|
|
57
|
+
|
|
58
|
+
### Similarity Metric
|
|
59
|
+
|
|
60
|
+
Cosine similarity between crate embeddings identifies related projects:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
similarity(A, B) = (A · B) / (||A|| · ||B||)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Complexity: O(d) = O(32) per comparison. For 1000 crates, brute-force search is O(1000 × 32) = 32K multiply-adds — sub-millisecond on any modern CPU. Cloudflare Vectorize accelerates this with ANN (Approximate Nearest Neighbor) indexing.
|
|
67
|
+
|
|
68
|
+
### Embedding Example
|
|
69
|
+
|
|
70
|
+
```rust
|
|
71
|
+
pub struct Embedding {
|
|
72
|
+
pub name: String,
|
|
73
|
+
pub vector: [f64; 32],
|
|
74
|
+
pub metadata: CrateInfo,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ternary-viterbi would produce:
|
|
78
|
+
// vector = [0.7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
79
|
+
// 0, 0.5, 0, 0, 0.3, 0, 0, 0,
|
|
80
|
+
// 0, 0.6, 0, 0, 0, 0, 0, 0,
|
|
81
|
+
// 0, 0.8, 0, 0]
|
|
82
|
+
// (ternary-math: 0.7, signal-processing: 0.5, testing: 0.3, game-theory: 0.6, meta-cognition: 0.8)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Quick Start
|
|
86
|
+
|
|
87
|
+
```rust
|
|
88
|
+
use superinstance_embedder::{CrateInfo, Embedding};
|
|
89
|
+
|
|
90
|
+
fn main() {
|
|
91
|
+
let info = CrateInfo {
|
|
92
|
+
name: "ternary-viterbi".into(),
|
|
93
|
+
tests: 12,
|
|
94
|
+
loc: 350,
|
|
95
|
+
domain: "ternary-math".into(),
|
|
96
|
+
wave: 3,
|
|
97
|
+
model: "glm".into(),
|
|
98
|
+
description: "Viterbi decoder for ternary state sequences".into(),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
let embedding = Embedding::from_crate(info);
|
|
102
|
+
println!("Vector: {:?}", &embedding.vector[..8]);
|
|
103
|
+
println!("Non-zero dimensions: {}",
|
|
104
|
+
embedding.vector.iter().filter(|&&v| v > 0.0).count());
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cargo build
|
|
110
|
+
cargo test
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## API
|
|
114
|
+
|
|
115
|
+
| Type | Method | Description |
|
|
116
|
+
|------|--------|-------------|
|
|
117
|
+
| `CrateInfo` | — | Input metadata (name, tests, LOC, domain, wave) |
|
|
118
|
+
| `Embedding` | `from_crate(info)` | Generate 32-dim vector from metadata |
|
|
119
|
+
| `Embedding` | `vector: [f64; 32]` | The embedding itself |
|
|
120
|
+
| `DOMAINS` | `const [&str; 32]` | Domain labels |
|
|
121
|
+
|
|
122
|
+
## Architecture Notes
|
|
123
|
+
|
|
124
|
+
SuperInstance Embedder is the semantic indexing layer — it maps the fleet's output into a searchable knowledge space. Each crate's embedding captures its γ (constructive purpose: what it builds) and its cross-domain connections (synergy potential). The 32-dimensional space is coarse by design — it captures *relationships*, not fine-grained code semantics. Vectorize provides the ANN search that makes this practical at scale. In the γ + η = C framework, the embedder measures the diversity dimension of C: how broadly the fleet's competence spans. See [ARCHITECTURE.md](https://github.com/SuperInstance/SuperInstance/blob/main/ARCHITECTURE.md).
|
|
125
|
+
|
|
126
|
+
## References
|
|
127
|
+
|
|
128
|
+
1. Mikolov, T., et al. (2013). "Distributed Representations of Words and Phrases and their Compositionality." *NeurIPS*. — Word2vec: the inspiration for semantic embeddings.
|
|
129
|
+
2. Johnson, J., Douze, M., & Jégou, H. (2019). "Billion-scale similarity search with GPUs." *IEEE Big Data*. — FAISS and ANN indexing.
|
|
130
|
+
3. Pennington, J., Socher, R., & Manning, C. D. (2014). "GloVe: Global Vectors for Word Representation." *EMNLP*.
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|
|
135
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
superinstance_embedder/__init__.py,sha256=6rUmkY8tC4e-B8hl7f8hpDYYg6jK1LNxBKfKjz5YwX8,171
|
|
2
|
+
superinstance_embedder/superinstance_embedder.pyd,sha256=B1AeELvb9Qzg0_xNdb6yRCoGZ0uAggpacMI-GmDvHfg,7079424
|
|
3
|
+
superinstance_embedder-0.2.0.dist-info/METADATA,sha256=HAjIApbr8KpSysA7SbU9pR8gV3mH83OS7S-r1mVt4yU,6098
|
|
4
|
+
superinstance_embedder-0.2.0.dist-info/WHEEL,sha256=RD58zsFMg5Xm6opfRt5qGok5PcA30CAhknyKFSihcu8,95
|
|
5
|
+
superinstance_embedder-0.2.0.dist-info/licenses/LICENSE,sha256=Jr1c5KU_IVbnO9O1iIlJwEEYMP9vZoh2QveroB4G16w,1089
|
|
6
|
+
superinstance_embedder-0.2.0.dist-info/sboms/superinstance-embedder.cyclonedx.json,sha256=Hzj3qsG-s6LuJb2WgiiIiNJ1PxHdkIItLECImeSuJng,556410
|
|
7
|
+
superinstance_embedder-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 SuperInstance
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|