nx_concept_embedding.nx
buildroot/runtime/nx_concept_embedding.nx
about
nx_concept_embedding.nx -- typed concept manifest + storage contract.
Closes the STORAGE half of the image-ingestion loop:
nx_image_feature_extract N images -> N feature vectors
nx_image_feature_centroid N vectors -> centroid (concept signature)
nx_concept_embedding centroid + provenance -> manifest
<nishi-library writer> manifest -> content-addressed storage
nx_cosine_similarity new image vs stored concept -> match
nx_render_target_match rendered vs target -> verdict
USE CASES (all three of user 2026-05-15's verticals):
RETAIL VIRTUAL TRY-ON:
name = "lingerie_velvet_red_xs"
centroid = mean(features across 5 photos of the product)
source_hashes = sha256 of each product photo
n_examples = 5
Later prompt: "model wearing [concept:lingerie_velvet_red_xs]"
-> blend stored centroid into prompt embedding (IP-adapter path)
-> render with the actual product visualized
VIDEO-GAME ASSET CATALOG:
name = "weapon_runic_greatsword"
centroid = mean(concept art frames)
-> in-engine asset gen conditioned on the concept
STORY-CHARACTER REFERENCE:
name = "char_elara"
centroid = mean(prior renders the user approved)
-> future story renders condition on this concept for identity
stability across the arc
MANIFEST STRUCTURE (canonical-bytes-serializable, content-addressable):
schema_version v1 forever; new version = new struct kind
name_buf + name_len concept's human-readable handle
centroid NX_IMAGE_FEATURE_LEN nx_int (Q10) cells
n_examples how many images contributed to the centroid
fidelity_q10 mean fidelity across the N source extracts
source_hash_buf 32 * n_examples bytes (sha256 per source img)
dependencies 4 imports · 1 importers
imports: nx_syscalls.nxnx_tier.nxnx_image_feature_extract.nxnx_cosine_similarity.nx
imported by: nx_concept_embedding_test.nx
structs
| 84 | struct ConceptEmbedding |
consts
| 66 | const NX_CE_SCHEMA_VERSION: nx_int = 1 |
| 67 | const NX_CE_HASH_BYTES: nx_int = 32 // sha256 = 32 bytes |
| 68 | const NX_CE_Q: nx_int = 1024 |
| 72 | const NX_CE_NAME_MAX: nx_int = 128 |
| 77 | const NX_CE_BAND_DISTINCT: nx_int = 0 |
| 78 | const NX_CE_BAND_LOOSE: nx_int = 1 |
| 79 | const NX_CE_BAND_RELATED: nx_int = 2 |
| 80 | const NX_CE_BAND_NEAR_DUPLICATE: nx_int = 3 |
| 81 | const NX_CE_BAND_IDENTICAL: nx_int = 4 |
| 82 | const NX_CE_N_BANDS: nx_int = 5 |
functions
| 102 | func nx_concept_embedding_build( called by 1: main |
| 142 | func _ce_write_byte(buf: *u8, max: nx_int, pos: nx_int, b: u8) -> nx_int |
| 148 | func _ce_write_bytes(buf: *u8, max: nx_int, pos: nx_int, src: *u8, n: nx_int) -> nx_int called by 1: nx_concept_embedding_canonical_bytes |
| 161 | func _ce_write_int(buf: *u8, max: nx_int, pos: nx_int, v: nx_int) -> nx_int |
| 197 | func _ce_hex_nibble(b: u8) -> u8 |
| 202 | func _ce_write_hex(buf: *u8, max: nx_int, pos: nx_int, src: *u8, n: nx_int) -> nx_int calls 1: _ce_hex_nibble |
| 217 | func nx_concept_embedding_canonical_bytes( |
| 358 | func nx_concept_embedding_compare(a: *ConceptEmbedding, b: *ConceptEmbedding) -> nx_int |
| 365 | func nx_concept_embedding_classify(similarity_q10: nx_int) -> nx_int called by 1: main |
| 373 | func nx_concept_embedding_band_is_valid(band: nx_int) -> nx_int called by 1: main |