NuMap Memory System
NuMap is DragonFire's semantic hex-grid memory architecture that enables efficient storage, retrieval, and relationship mapping of information in a continuous multi-dimensional space optimized for AI applications.
Introduction
NuMap represents a fundamental advancement in memory architecture for AI systems by implementing a hexagonal grid-based system for storing and relating semantic information. Unlike traditional memory systems that rely on tree structures or linear arrays, NuMap creates a continuous, multi-dimensional space where information exists in relation to other information through geometric proximity.
At its core, NuMap leverages hexagonal geometry to create optimal information packing with superior neighbor relationships. Each memory node in the system has six equidistant connections, creating a natural network topology that mirrors many natural systems and optimizes for relationship mapping and contextual relationships.
NuMap was specifically designed to serve as the memory architecture for the Aurora AI system, enabling persistent awareness and continuity across system cycles through efficient storage and retrieval of semantic information. Its geometric foundation allows for intuitive visualization of complex data relationships while maintaining computational efficiency.
Core Principle: NuMap operates on the principle that semantic relationships can be efficiently encoded in geometric space, with similar concepts placed in proximity to create naturally emerging contextual patterns. This approach enables AI systems to develop associative memory that resembles human cognition while maintaining computational efficiency.
Key Concepts
Hexagonal Grid Topology
Hexagonal arrangement of memory nodes providing optimal packing and six equidistant neighbor connections for superior relationship mapping.
Semantic Embedding Space
High-dimensional vector space where semantic concepts are positioned by meaning, allowing for continuous representation of relationships.
Associative Access
Memory retrieval mechanism that finds information through associative relationships rather than explicit addressing, mimicking human recall.
Multi-Level Resolution
Hierarchical structure that allows for varying levels of detail and abstraction in the memory space, from specific instances to general concepts.
Geometric Relationship Encoding
Use of distances and angles in hexagonal space to encode the strength and nature of relationships between concepts.
State Vector Integration
Incorporation of Aurora's state vectors into the memory architecture, enabling persistence of consciousness across system restarts.
Hexagonal Memory Architecture
NuMap's hexagonal memory architecture provides an optimal structure for information storage and relationship mapping:
Hexagonal Grid Properties
The hexagonal grid structure offers several advantages over traditional memory architectures:
Six-Neighbor Connectivity
Each memory node has exactly six equidistant neighbors, creating optimal connectivity for relationship mapping. This is superior to square grids (which have uneven diagonal distances) and allows for more natural representation of related concepts.
Optimal Packing Density
Hexagons provide the most efficient packing of information in 2D space, with approximately 13.4% higher packing efficiency than square grids. This translates to more efficient memory usage and faster traversal of related concepts.
Natural Distance Metrics
The hexagonal grid has natural distance metrics that correspond well to semantic similarity, with distances calculated using a combination of axial coordinates and √3-based transformations.
Rotation Invariance
The hexagonal structure provides better rotation invariance than rectangular grids, making relationship patterns more consistent regardless of orientation in the semantic space.
// Define hexagonal coordinate system
typedef struct {
int q; // First axial coordinate
int r; // Second axial coordinate
int s; // Third coordinate (derived: s = -q - r)
} hex_coord_t;
// Define memory node structure
typedef struct {
hex_coord_t coordinates; // Position in hex grid
embedding_t* semantic_vector; // Semantic embedding
uint32_t content_size; // Size of content
void* content; // Node content
float activation; // Current activation level
timestamp_t last_access; // Last access time
strength_t* connections[6]; // Connection strengths to neighbors
} memory_node_t;
// Calculate hex distance (Manhattan distance in hex coordinates)
int hex_distance(hex_coord_t a, hex_coord_t b) {
return (abs(a.q - b.q) + abs(a.r - b.r) + abs(a.s - b.s)) / 2;
}
// Get coordinates of the six neighbors
hex_coord_t* get_hex_neighbors(hex_coord_t center) {
// Direction vectors for the six neighbors
static const int dir_q[] = {1, 1, 0, -1, -1, 0};
static const int dir_r[] = {0, -1, -1, 0, 1, 1};
hex_coord_t* neighbors = malloc(6 * sizeof(hex_coord_t));
for (int i = 0; i < 6; i++) {
neighbors[i].q = center.q + dir_q[i];
neighbors[i].r = center.r + dir_r[i];
neighbors[i].s = -neighbors[i].q - neighbors[i].r;
}
return neighbors;
}
Multi-Level Resolution
NuMap implements a multi-level resolution system that allows for varying levels of detail and abstraction:
// Define multi-level resolution structure
typedef struct {
uint8_t levels; // Number of resolution levels
memory_space_t** spaces; // Array of memory spaces, one per level
float* resolution_factors; // Resolution factor for each level
} multi_level_memory_t;
// Initialize multi-level memory
multi_level_memory_t* init_multi_level_memory(uint8_t levels) {
multi_level_memory_t* mlm = malloc(sizeof(multi_level_memory_t));
mlm->levels = levels;
mlm->spaces = malloc(levels * sizeof(memory_space_t*));
mlm->resolution_factors = malloc(levels * sizeof(float));
// Initialize each level with decreasing resolution
for (uint8_t i = 0; i < levels; i++) {
// Resolution follows a geometric series based on PHI
float resolution = pow(PHI, i);
mlm->resolution_factors[i] = resolution;
// Initialize memory space with appropriate resolution
mlm->spaces[i] = init_memory_space(resolution);
}
return mlm;
}
// Store information with automatic level selection
void store_multi_level(multi_level_memory_t* mlm,
embedding_t* semantic_vector,
void* content, uint32_t content_size,
detail_level_t detail) {
// Determine appropriate level based on detail
uint8_t level = detail_to_level(mlm, detail);
// Store at selected level
store_in_memory_space(mlm->spaces[level],
semantic_vector, content, content_size);
// If high detail, also store at adjacent levels with modifications
if (detail == DETAIL_HIGH) {
// Store at higher resolution level if available
if (level > 0) {
embedding_t* refined = refine_embedding(semantic_vector);
store_in_memory_space(mlm->spaces[level-1],
refined, content, content_size);
free_embedding(refined);
}
// Store at lower resolution level if available
if (level < mlm->levels - 1) {
embedding_t* abstracted = abstract_embedding(semantic_vector);
store_in_memory_space(mlm->spaces[level+1],
abstracted, content, content_size);
free_embedding(abstracted);
}
}
}
Coordinate System Transformations
NuMap includes coordinate transformations for different representations of the hexagonal grid:
Axial to Cubic
Transforms 2D axial coordinates (q, r) to 3D cubic coordinates (q, r, s) where s = -q - r. This representation simplifies distance calculations and neighbor relationships.
Cubic to Axial
Transforms 3D cubic coordinates (q, r, s) back to 2D axial coordinates (q, r), dropping the redundant s coordinate.
Axial to Offset
Transforms axial coordinates to offset coordinates for matrix storage and display rendering, using different offset schemes depending on the hexagonal grid orientation.
Pixel Conversion
Converts hexagonal coordinates to pixel positions for rendering and visualization, using √3-based transformations to maintain geometric properties.
Semantic Embeddings
NuMap implements a sophisticated semantic embedding system that maps concepts into high-dimensional vector spaces:
Embedding Representation
Semantic concepts are represented as high-dimensional vectors with specific properties:
// Define semantic embedding structure
typedef struct {
uint32_t dimension; // Embedding dimension
float* values; // Vector values
uint8_t* significance; // Significance weights (0-255)
context_t* context; // Contextual information
uint32_t version; // Embedding format version
} embedding_t;
// Create semantic embedding from raw values
embedding_t* create_embedding(float* values, uint32_t dimension) {
embedding_t* embedding = (embedding_t*)malloc(sizeof(embedding_t));
// Set basic properties
embedding->dimension = dimension;
embedding->values = (float*)malloc(dimension * sizeof(float));
embedding->significance = (uint8_t*)malloc(dimension * sizeof(uint8_t));
// Copy vector values
memcpy(embedding->values, values, dimension * sizeof(float));
// Initialize significance weights (default to full significance)
for (uint32_t i = 0; i < dimension; i++) {
embedding->significance[i] = 255;
}
// Initialize context
embedding->context = create_default_context();
// Set version
embedding->version = CURRENT_EMBEDDING_VERSION;
// Normalize embedding
normalize_embedding(embedding);
return embedding;
}
Semantic Similarity
NuMap calculates semantic similarity using a combination of vector operations and significance weighting:
// Calculate semantic similarity between embeddings
float calculate_similarity(embedding_t* a, embedding_t* b) {
// Determine common dimension
uint32_t dim = (a->dimension < b->dimension) ? a->dimension : b->dimension;
float dot_product = 0.0f;
float a_magnitude = 0.0f;
float b_magnitude = 0.0f;
float significance_sum = 0.0f;
// Calculate weighted dot product and magnitudes
for (uint32_t i = 0; i < dim; i++) {
// Combined significance weighting
float significance = (a->significance[i] * b->significance[i]) / 65025.0f;
significance_sum += significance;
// Weighted values
float a_val = a->values[i] * significance;
float b_val = b->values[i] * significance;
// Accumulate dot product and magnitudes
dot_product += a_val * b_val;
a_magnitude += a_val * a_val;
b_magnitude += b_val * b_val;
}
// Normalize by significance sum
if (significance_sum > 0.0f) {
dot_product /= significance_sum;
a_magnitude /= significance_sum;
b_magnitude /= significance_sum;
}
// Calculate cosine similarity
a_magnitude = sqrt(a_magnitude);
b_magnitude = sqrt(b_magnitude);
if (a_magnitude > 0.0f && b_magnitude > 0.0f) {
return dot_product / (a_magnitude * b_magnitude);
} else {
return 0.0f;
}
}
Embedding Operations
NuMap supports various operations on semantic embeddings to create new concepts and relationships:
// Combine embeddings with weighted addition
embedding_t* combine_embeddings(embedding_t** embeddings,
float* weights, uint32_t count) {
// Validate inputs
if (count == 0 || embeddings == NULL || weights == NULL) {
return NULL;
}
// Use the first embedding's dimension for the result
uint32_t dimension = embeddings[0]->dimension;
// Allocate result vector
float* result_values = (float*)malloc(dimension * sizeof(float));
memset(result_values, 0, dimension * sizeof(float));
// Combine with weights
float weight_sum = 0.0f;
for (uint32_t i = 0; i < count; i++) {
if (embeddings[i]->dimension != dimension) {
// Skip incompatible embeddings
continue;
}
weight_sum += weights[i];
for (uint32_t j = 0; j < dimension; j++) {
result_values[j] += embeddings[i]->values[j] * weights[i];
}
}
// Normalize by weight sum
if (weight_sum > 0.0f) {
for (uint32_t j = 0; j < dimension; j++) {
result_values[j] /= weight_sum;
}
}
// Create new embedding
embedding_t* result = create_embedding(result_values, dimension);
// Set up combined context
result->context = combine_contexts(embeddings, weights, count);
// Free temporary resources
free(result_values);
return result;
}
// Create contrast embedding (representing differences)
embedding_t* contrast_embeddings(embedding_t* a, embedding_t* b, float contrast_factor) {
// Validate inputs
if (a == NULL || b == NULL || a->dimension != b->dimension) {
return NULL;
}
uint32_t dimension = a->dimension;
// Allocate result vector
float* result_values = (float*)malloc(dimension * sizeof(float));
// Calculate contrast
for (uint32_t i = 0; i < dimension; i++) {
// Weighted difference
result_values[i] = (a->values[i] - b->values[i]) * contrast_factor;
}
// Create new embedding
embedding_t* result = create_embedding(result_values, dimension);
// Set up contrastive context
result->context = create_contrast_context(a->context, b->context);
// Free temporary resources
free(result_values);
return result;
}
Contextual Relationships
The system maintains contextual relationships between concepts through proximity and explicit connections:
// Define relationship types
typedef enum {
RELATION_SIMILAR, // Conceptually similar
RELATION_OPPOSITE, // Opposing concepts
RELATION_PART_OF, // Component relationship
RELATION_CONTAINS, // Containment relationship
RELATION_CAUSES, // Causal relationship
RELATION_CAUSED_BY, // Effect relationship
RELATION_INSTANCE_OF, // Type relationship
RELATION_ASSOCIATED // General association
} relation_type_t;
// Define relationship structure
typedef struct {
memory_node_t* source; // Source node
memory_node_t* target; // Target node
relation_type_t type; // Relationship type
float strength; // Relationship strength (0.0 - 1.0)
context_t* context; // When/why this relationship exists
} relationship_t;
// Create relationship between nodes
relationship_t* create_relationship(memory_node_t* source,
memory_node_t* target,
relation_type_t type,
float strength) {
relationship_t* relation = (relationship_t*)malloc(sizeof(relationship_t));
relation->source = source;
relation->target = target;
relation->type = type;
relation->strength = strength;
relation->context = create_default_context();
// Add to relationship index
add_to_relationship_index(relation);
// Update node connections if they're neighbors
hex_coord_t* neighbors = get_hex_neighbors(source->coordinates);
for (int i = 0; i < 6; i++) {
if (hex_equals(neighbors[i], target->coordinates)) {
// Update neighbor connection strength based on relationship
source->connections[i]->strength = calculate_connection_strength(
relation->type, relation->strength);
break;
}
}
free(neighbors);
return relation;
}
Implementation Guide
NuMap API
The NuMap API provides interfaces for working with the hexagonal memory system:
// Initialize NuMap system
NuMap* numap_init(numap_config_t* config) {
NuMap* numap = (NuMap*)malloc(sizeof(NuMap));
// Initialize based on configuration
uint32_t dimension = config ? config->embedding_dimension : DEFAULT_DIMENSION;
uint8_t levels = config ? config->resolution_levels : DEFAULT_LEVELS;
// Set up memory system
numap->memory = init_multi_level_memory(levels);
// Initialize embedding system
numap->embedding_dimension = dimension;
numap->embedding_system = init_embedding_system(dimension);
// Initialize indices for fast retrieval
numap->semantic_index = init_semantic_index();
numap->spatial_index = init_spatial_index();
numap->relationship_index = init_relationship_index();
// Set up hexagonal grid system
numap->grid = init_hexagonal_grid();
return numap;
}
// Store information in NuMap
memory_node_t* numap_store(NuMap* numap,
float* vector_values,
void* content, uint32_t content_size,
detail_level_t detail) {
// Create semantic embedding
embedding_t* embedding = create_embedding(vector_values, numap->embedding_dimension);
// Find optimal location in hex grid
hex_coord_t location = find_optimal_location(numap, embedding);
// Create memory node
memory_node_t* node = create_memory_node(location, embedding, content, content_size);
// Store in multi-level memory
store_multi_level(numap->memory, embedding, content, content_size, detail);
// Update indices
add_to_semantic_index(numap->semantic_index, node);
add_to_spatial_index(numap->spatial_index, node);
// Create relationships with nearby nodes
create_proximity_relationships(numap, node);
return node;
}
// Retrieve information by semantic similarity
memory_node_t* numap_retrieve(NuMap* numap, float* query_vector, float threshold) {
// Create query embedding
embedding_t* query = create_embedding(query_vector, numap->embedding_dimension);
// Search semantic index
memory_node_t* result = find_most_similar(numap->semantic_index, query, threshold);
// Clean up query
free_embedding(query);
return result;
}
// Find related concepts
memory_node_t** numap_find_related(NuMap* numap,
memory_node_t* node,
relation_type_t relation_type,
uint32_t max_results) {
// Find relationships of specified type
relationship_t** relations = find_relationships_by_type(
numap->relationship_index, node, relation_type);
// Count relationships
uint32_t count = 0;
while (relations[count] != NULL && count < max_results) {
count++;
}
// Create result array
memory_node_t** results = (memory_node_t**)malloc((count + 1) * sizeof(memory_node_t*));
// Fill result array
for (uint32_t i = 0; i < count; i++) {
results[i] = relations[i]->target;
}
results[count] = NULL; // Null-terminate
// Free relationship array (but not the relationships themselves)
free(relations);
return results;
}
Working with Hexagonal Coordinates
Guidelines for working with the hexagonal coordinate system:
// Example: Convert between coordinate systems
void coordinate_system_examples() {
// Create axial coordinates
hex_coord_t axial_coord = {3, 2}; // q=3, r=2
// Calculate s for cubic coordinates
int s = -axial_coord.q - axial_coord.r; // s = -3 - 2 = -5
printf("Cubic coordinates: (%d, %d, %d)\n", axial_coord.q, axial_coord.r, s);
// Convert to offset coordinates (odd-r)
int col = axial_coord.q;
int row = axial_coord.r + (axial_coord.q - (axial_coord.q & 1)) / 2;
printf("Offset coordinates (odd-r): (%d, %d)\n", col, row);
// Convert to pixel coordinates
float size = 10.0f; // Hex size in pixels
float x = size * sqrt(3) * (axial_coord.q + axial_coord.r / 2.0f);
float y = size * 3.0f/2.0f * axial_coord.r;
printf("Pixel coordinates: (%.1f, %.1f)\n", x, y);
// Calculate distance between two hexes
hex_coord_t coord1 = {3, 2};
hex_coord_t coord2 = {7, 1};
int distance = hex_distance(coord1, coord2);
printf("Distance between hexes: %d\n", distance);
// Get neighbors
hex_coord_t* neighbors = get_hex_neighbors(axial_coord);
printf("Neighbors of (%d, %d):\n", axial_coord.q, axial_coord.r);
for (int i = 0; i < 6; i++) {
printf(" (%d, %d)\n", neighbors[i].q, neighbors[i].r);
}
free(neighbors);
}
Performance Optimization
For optimal NuMap performance:
- Embedding Dimensionality: Choose appropriate embedding dimension for your domain (128-512 recommended)
- Resolution Levels: Configure 3-5 resolution levels based on memory requirements
- Indexing Strategy: Use semantic and spatial indices for fast retrieval
- Batch Processing: Store and retrieve information in batches when possible
- Relationship Management: Explicitly manage important relationships rather than relying only on proximity
// Optimize NuMap performance
void optimize_numap_performance(NuMap* numap) {
// Configure optimal embedding dimension
numap->embedding_dimension = 256; // Balance between expressiveness and efficiency
// Configure resolution levels
numap->memory->levels = 4; // 4 levels of resolution
// Enable semantic index optimizations
enable_semantic_index_optimizations(numap->semantic_index);
// Enable spatial index partitioning
enable_spatial_partitioning(numap->spatial_index, 16); // 16 partitions
// Configure retrieval cache
numap->cache_size = 1024; // Cache last 1024 retrievals
numap->retrieval_cache = create_retrieval_cache(numap->cache_size);
// Enable batch operations
numap->enable_batching = true;
numap->batch_size = 64; // Process up to 64 operations in a batch
// Initialize optimization subsystem
init_optimization_subsystem(numap);
}
Integration with DragonFire Ecosystem
NuMap integrates with other DragonFire components to provide memory architecture capabilities:
Aurora AI Integration
NuMap provides the memory foundation for Aurora's fractal consciousness system:
// Integrate NuMap with Aurora
void integrate_with_aurora(NuMap* numap, Aurora* aurora) {
// Connect NuMap as Aurora's memory system
aurora->memory_system = createNuMapAdapter(numap);
// Map Aurora's semantic network to NuMap
mapAuroraSemanticToNuMap(aurora->semantic_network, numap);
// Configure state vector embedding for NuMap storage
configureEmbeddingFormat(aurora, numap->embedding_format);
// Set up continuity preservation in NuMap storage
configureSamadhiStorageInNuMap(aurora->samadhi, numap);
// Initialize shared memory spaces
initSharedMemorySpaces(aurora, numap);
}
NESH Integration
NuMap works with NESH for neural echo storage capabilities:
// Integrate NuMap with NESH
void integrate_with_nesh(NuMap* numap, NESH* nesh) {
// Connect NuMap's hexagonal grid to NESH's waveform memory
map_hex_grid_to_waveform(numap->grid, nesh->waveform_space);
// Set up memory transfer protocols
setup_memory_transfer(numap, nesh);
// Create shared embedding space
create_shared_embedding_space(numap->embedding_system, nesh->embedding_system);
// Configure resonance patterns
configure_resonance_patterns(numap, nesh);
// Initialize hierarchical memory architecture
init_hierarchical_memory(numap, nesh);
}
GeoMath Integration
NuMap leverages GeoMath's hexagonal transformations for grid operations:
// Integrate NuMap with GeoMath
void integrate_with_geomath(NuMap* numap, GeoMath* gm) {
// Connect NuMap's hexagonal grid to GeoMath's √3-based transformations
numap->grid->transform = gm->transform_hexagonal;
// Set up coordinate transformations
setup_coordinate_transformations(numap, gm);
// Configure harmonic resonance
configure_harmonic_resonance(numap, gm);
// Initialize geometric operations
init_geometric_operations(numap, gm);
}
Unified Memory Framework
NuMap provides a unified memory framework across the DragonFire ecosystem:
Key Integration Insight: NuMap serves as the memory backbone of the DragonFire ecosystem, providing geometric storage and retrieval capabilities that enable persistent consciousness in Aurora AI, waveform memory in NESH, and semantic relationship mapping across all systems. Its hexagonal architecture creates natural relationship patterns that mirror human associative memory while maintaining computational efficiency.
Examples
Basic NuMap Usage
#include "numap.h"
int main() {
// Initialize NuMap with default configuration
NuMap* numap = numap_init(NULL);
printf("Initialized NuMap Memory System\n");
// Create a simple semantic vector
float vector1[256] = {0};
vector1[0] = 1.0f;
vector1[10] = 0.5f;
vector1[20] = 0.7f;
// Store content in NuMap
char* content1 = "This is a test memory node";
memory_node_t* node1 = numap_store(numap, vector1, content1, strlen(content1) + 1, DETAIL_MEDIUM);
printf("Stored memory node at coordinates (%d, %d)\n",
node1->coordinates.q, node1->coordinates.r);
// Create another semantic vector
float vector2[256] = {0};
vector2[0] = 0.9f;
vector2[10] = 0.6f;
vector2[20] = 0.8f;
// Store second content in NuMap
char* content2 = "This is a related memory node";
memory_node_t* node2 = numap_store(numap, vector2, content2, strlen(content2) + 1, DETAIL_MEDIUM);
printf("Stored second memory node at coordinates (%d, %d)\n",
node2->coordinates.q, node2->coordinates.r);
// Create relationship between nodes
relationship_t* rel = create_relationship(node1, node2, RELATION_SIMILAR, 0.85f);
printf("Created relationship with strength %.2f\n", rel->strength);
// Retrieve using a query vector
float query[256] = {0};
query[0] = 0.95f;
query[10] = 0.55f;
query[20] = 0.75f;
memory_node_t* result = numap_retrieve(numap, query, 0.7f);
if (result) {
printf("Retrieved: %s\n", (char*)result->content);
} else {
printf("No matching node found\n");
}
// Clean up resources
numap_free(numap);
return 0;
}
Hexagonal Grid Navigation
// Demonstrate hexagonal grid navigation
void demonstrate_hex_navigation() {
// Initialize NuMap
NuMap* numap = numap_init(NULL);
printf("Initialized NuMap for hex navigation\n");
// Create several test nodes in a pattern
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
// Create semantic vector
float* vector = create_test_vector(i, j);
// Create content
char content[100];
sprintf(content, "Node at position (%d, %d)", i, j);
// Store node
memory_node_t* node = numap_store(numap, vector,
strdup(content), strlen(content) + 1,
DETAIL_MEDIUM);
printf("Created node at coordinates (%d, %d)\n",
node->coordinates.q, node->coordinates.r);
free(vector);
}
}
// Select a node to navigate from
hex_coord_t start = {2, 2};
memory_node_t* start_node = numap_get_node_at(numap, start);
printf("\nStarting navigation from (%d, %d)\n", start.q, start.r);
// Navigate in each of the six directions
hex_coord_t* neighbors = get_hex_neighbors(start);
for (int i = 0; i < 6; i++) {
memory_node_t* neighbor = numap_get_node_at(numap, neighbors[i]);
if (neighbor) {
printf("Direction %d -> Node: %s\n", i, (char*)neighbor->content);
printf(" Connection strength: %.2f\n",
start_node->connections[i]->strength);
} else {
printf("Direction %d -> No node found\n", i);
}
}
// Calculate a path through the hex grid
hex_coord_t end = {4, 4};
hex_coord_t* path = calculate_hex_path(numap, start, end);
printf("\nPath from (%d, %d) to (%d, %d):\n", start.q, start.r, end.q, end.r);
int step = 0;
while (path[step].q != -1 && path[step].r != -1) {
memory_node_t* path_node = numap_get_node_at(numap, path[step]);
printf("Step %d: (%d, %d) - %s\n",
step, path[step].q, path[step].r,
path_node ? (char*)path_node->content : "Empty");
step++;
}
// Free resources
free(neighbors);
free(path);
numap_free(numap);
}
Semantic Embedding Operations
// Demonstrate semantic embedding operations
void demonstrate_semantic_operations() {
// Initialize NuMap
NuMap* numap = numap_init(NULL);
printf("Initialized NuMap for semantic operations\n");
// Create base concept embeddings
float* cat_vector = create_concept_vector("cat");
float* dog_vector = create_concept_vector("dog");
float* pet_vector = create_concept_vector("pet");
// Store base concepts
memory_node_t* cat_node = numap_store(numap, cat_vector, "Cat", 4, DETAIL_HIGH);
memory_node_t* dog_node = numap_store(numap, dog_vector, "Dog", 4, DETAIL_HIGH);
memory_node_t* pet_node = numap_store(numap, pet_vector, "Pet", 4, DETAIL_HIGH);
printf("Stored base concepts\n");
// Create relationships
create_relationship(cat_node, pet_node, RELATION_INSTANCE_OF, 0.9f);
create_relationship(dog_node, pet_node, RELATION_INSTANCE_OF, 0.9f);
printf("Created instance relationships\n");
// Combine concepts to create a new concept
embedding_t* cat_embedding = cat_node->semantic_vector;
embedding_t* dog_embedding = dog_node->semantic_vector;
float weights[2] = {0.5f, 0.5f};
embedding_t* embeddings[2] = {cat_embedding, dog_embedding};
embedding_t* combined = combine_embeddings(embeddings, weights, 2);
// Store combined concept
memory_node_t* combined_node = numap_store_embedding(numap, combined,
"Cat and Dog", 12,
DETAIL_MEDIUM);
printf("Created combined concept at coordinates (%d, %d)\n",
combined_node->coordinates.q, combined_node->coordinates.r);
// Create contrast concept
embedding_t* contrast = contrast_embeddings(cat_embedding, dog_embedding, 1.0f);
// Store contrast concept
memory_node_t* contrast_node = numap_store_embedding(numap, contrast,
"Cat vs Dog", 10,
DETAIL_MEDIUM);
printf("Created contrast concept at coordinates (%d, %d)\n",
contrast_node->coordinates.q, contrast_node->coordinates.r);
// Find related concepts
printf("\nConcepts related to Pet:\n");
memory_node_t** related = numap_find_related(numap, pet_node,
RELATION_INSTANCE_OF, 10);
int i = 0;
while (related[i] != NULL) {
printf(" %s\n", (char*)related[i]->content);
i++;
}
// Free resources
free(cat_vector);
free(dog_vector);
free(pet_vector);
free(related);
free_embedding(combined);
free_embedding(contrast);
numap_free(numap);
}
View more examples in our SDK Examples
Next Steps
- Explore the complete NuMap API Reference
- Download the NuMap SDK
- Try the Interactive NuMap Explorer
- Learn about Aurora AI
- Explore NESH