code wiki / (root) / nx_concept_embedding.nx

nx_concept_embedding.nx

buildroot/runtime/nx_concept_embedding.nx

12294 B377 linesdepth 9pulls 17 transitivereach 1 importersview sourcekind librarytopic concept
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tier.nx nx_image_feature_extract.nx nx_cosine_similarity.nx nx_concept_embedding.nx nx_concept_embedding_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_image_feature_extract.nxnx_cosine_similarity.nx

imported by: nx_concept_embedding_test.nx

structs

84struct ConceptEmbedding

consts

66const NX_CE_SCHEMA_VERSION: nx_int = 1
67const NX_CE_HASH_BYTES: nx_int = 32 // sha256 = 32 bytes
68const NX_CE_Q: nx_int = 1024
72const NX_CE_NAME_MAX: nx_int = 128
77const NX_CE_BAND_DISTINCT: nx_int = 0
78const NX_CE_BAND_LOOSE: nx_int = 1
79const NX_CE_BAND_RELATED: nx_int = 2
80const NX_CE_BAND_NEAR_DUPLICATE: nx_int = 3
81const NX_CE_BAND_IDENTICAL: nx_int = 4
82const NX_CE_N_BANDS: nx_int = 5

functions

102func nx_concept_embedding_build(
called by 1: main
142func _ce_write_byte(buf: *u8, max: nx_int, pos: nx_int, b: u8) -> nx_int
148func _ce_write_bytes(buf: *u8, max: nx_int, pos: nx_int, src: *u8, n: nx_int) -> nx_int
161func _ce_write_int(buf: *u8, max: nx_int, pos: nx_int, v: nx_int) -> nx_int
197func _ce_hex_nibble(b: u8) -> u8
202func _ce_write_hex(buf: *u8, max: nx_int, pos: nx_int, src: *u8, n: nx_int) -> nx_int
calls 1: _ce_hex_nibble
217func nx_concept_embedding_canonical_bytes(
358func nx_concept_embedding_compare(a: *ConceptEmbedding, b: *ConceptEmbedding) -> nx_int
called by 1: main calls 1: nx_cosine_similarity
365func nx_concept_embedding_classify(similarity_q10: nx_int) -> nx_int
called by 1: main
373func nx_concept_embedding_band_is_valid(band: nx_int) -> nx_int
called by 1: main