/* * parametry_demo.c — bind a SLeeLa LLM and a SLeeLa neural net to EITHER a * known/supported model (by name) OR a user's local model, via parametry. * * It then uses each resolved arrangement: the LLM params feed the capacity * layer (2..16 GB envelope); the neural-net params build a real slnn_* net and * run one inference. No weights are bundled; a "local" model is just a path the * user declares. * * Build: * cc -std=c11 -O2 -Wall -Wextra -pedantic \ * parametry.c ../large_language_models_capacity.c \ * ../../neural-nets/neural_nets.c parametry_demo.c -o parametry_demo */ #include "parametry.h" #include "../large_language_models_capacity.h" #include "../../neural-nets/neural_nets.h" #include #define GIB (1024ULL*1024ULL*1024ULL) static int fails=0; static void ok(int c,const char*w){ printf(" %s %s\n", c?"ok:":"FAIL:", w); if(!c) fails++; } /* Bind an LLM arrangement and report the capacity tier/budget it implies. */ static void bind_llm(const char* title, sllmp_binding* b){ sllmp_parameters p; sllmp_status st=sllmp_resolve(b,&p); printf("== %s ==\n status=%s source=%s name/path=%s\n", title, sllmp_status_string(st), sllmp_source_name(p.source), p.name_or_path? p.name_or_path : "(none)"); if(st!=SLLMP_OK){ fails++; return; } /* Feed the capacity layer. */ sllmc_profile cp; sllmc_profile_init(&cp); cp.weight_bytes=p.weight_bytes; cp.context_tokens=p.context_tokens; sllmc_budget bud; sllmc_derive_budget(&cp,&bud); printf(" LLM: %llu GB -> tier=%s ctx=%u steps=%u backtracks=%u\n\n", (unsigned long long)(p.weight_bytes/GIB), sllmc_tier_name(sllmc_tier_for_bytes(p.weight_bytes)), bud.context_tokens, bud.max_steps, bud.max_backtracks); } /* Bind a neural-net arrangement and actually build + run the slnn_* net. */ static void bind_nn(const char* title, sllmp_binding* b){ sllmp_parameters p; sllmp_status st=sllmp_resolve(b,&p); printf("== %s ==\n status=%s source=%s name/path=%s\n", title, sllmp_status_string(st), sllmp_source_name(p.source), p.name_or_path? p.name_or_path : "(none)"); if(st!=SLLMP_OK){ fails++; return; } printf(" NN shape:"); for(size_t i=0;i<=p.layer_count;i++) printf(" %zu", p.layer_sizes[i]); printf("\n"); slnn_network_config cfg; cfg.abi_version=SLNN_ABI_VERSION; cfg.layer_count=p.layer_count; cfg.layer_sizes=p.layer_sizes; cfg.hidden_activation=SLNN_ACTIVATION_TANH; cfg.output_activation=SLNN_ACTIVATION_SIGMOID; cfg.seed=1; slnn_network* net=NULL; if(slnn_network_create(&cfg,&net)!=SLNN_OK){ printf(" FAIL: slnn_network_create\n"); fails++; return; } double in[64]={0}, out[64]={0}; size_t ni=slnn_network_input_count(net), no=slnn_network_output_count(net); for(size_t i=0;i UNKNOWN_MODEL"); sllmp_binding none={0}; none.abi_version=SLLMP_ABI_VERSION; none.kind=SLLMP_KIND_LLM; ok(sllmp_resolve(&none,&tmp)==SLLMP_NO_SOURCE, "no name and no path -> NO_SOURCE"); sllmp_binding mism={0}; mism.abi_version=SLLMP_ABI_VERSION; mism.kind=SLLMP_KIND_NEURAL_NET; mism.name="sleela-code-standard"; ok(sllmp_resolve(&mism,&tmp)==SLLMP_KIND_MISMATCH, "LLM name bound as neural-net -> KIND_MISMATCH"); if(fails){ fprintf(stderr,"parametry_demo: %d FAIL\n",fails); return 1; } printf("\nparametry_demo: OK\n"); return 0; }