2 पॉइंट द्वारा GN⁺ 2025-06-29 | 1 टिप्पणियां | WhatsApp पर शेयर करें
  • SymbolicAI एक neuro-symbolic framework है जो classic Python programming को LLM की differentiable और programmable प्रकृति के साथ जोड़ता है, और इसका लक्ष्य इसे Python के भीतर स्वाभाविक रूप से इस्तेमाल करने योग्य बनाना है
  • मुख्य अवधारणा Symbol object आधारित primitives और LLM results को validate व correct करने वाले contracts हैं; default behavior safety और speed के लिए syntactic mode से शुरू होता है
  • Symbol syntactic mode में सामान्य Python value की तरह काम करता है, और semantic mode में context व meaning को संभालता है; semantic=True, .sem, .map() जैसे semantic function calls से mode बदला जा सकता है
  • contract system Design by Contract सिद्धांत को LLM workflows पर लागू करता है, जिसमें input validation, state change, LLM generation, output validation और failure पर fallback response तक सब कुछ decorator-based flow में संभाला जाता है
  • installation pip install symbolicai से शुरू होती है; असली उपयोग के लिए symconfig और symai.config.json configuration चाहिए, और neuro-symbolic engine symai package के उपयोग के लिए अनिवार्य है

SymbolicAI जिस model की ओर लक्षित है

  • SymbolicAI एक neuro-symbolic framework है, जो सामान्य Python code और LLM-based semantic processing को साथ में संभालता है
  • modular design के ज़रिए इसे जरूरत के अनुसार extend और customize किया जा सकता है
  • यह अपना engine लिखने, local engine host करने, web search और image generation जैसे tool integrations को support करता है
  • project name Allen Newell और Herbert Simon के foundational work को credit देने के इरादे से रखा गया है

Symbol primitive

  • SymbolicAI के केंद्र में Symbol object है, जिसके साथ छोटे, composable operations को Python-native syntax की तरह इस्तेमाल किया जा सकता है
  • Symbol के दो behavior modes हैं
    • Syntactic: दी गई string, list, integer जैसी सामान्य Python values की तरह काम करता है
    • Semantic: neuro-symbolic engine से जुड़कर meaning और context को संभालता है
  • default syntactic mode है
    • ==, ~, & जैसे Python operators symai में overloaded हैं
    • हर comparison या bitshift पर तुरंत engine call करने से system धीमा हो सकता है और अप्रत्याशित side effects आ सकते हैं
    • सिर्फ जरूरत वाली जगहों पर semantic behavior enable करके safety और speed बनाए रखी जाती है

semantic mode में switch करने का तरीका

  • creation के समय semantic=True set करने पर यह शुरुआत से ही semantic Symbol की तरह काम करता है
    • उदाहरण में Symbol("Cats are adorable", semantic=True) "feline" in S को True के रूप में process करता है
  • जरूरत पड़ने पर .sem projection का उपयोग करके semantic behavior में switch किया जा सकता है, और .syn से फिर syntactic behavior में लौटा जा सकता है
    • वही "Cats are adorable" value भी S.sem में "feline" in S.sem के लिए True है, जबकि default S में False है
  • .map() जैसे dot-notation operations या अन्य semantic function calls Symbol को automatically semantic mode में switch कर देते हैं
    • उदाहरण में fruits list पर convert all fruits to vegetables लागू करने से केवल fruits vegetables में बदलते हैं और cat, dog वैसे ही रहते हैं
  • .sem और .syn projections उसी underlying object पर अलग behavior layers चढ़ाने का तरीका हैं, इसलिए एक ही Symbol पर syntactic और semantic operations को chain किया जा सकता है

उपलब्ध operations के उदाहरण

  • SymbolicAI कई तरह के primitives support करता है, और documentation primitives पर है
  • == syntactic mode में literal match check करता है, जबकि semantic mode में "Hi" और "Hello" जैसी fuzzy/conceptual equivalence को संभालता है
  • + syntactic mode में number, string और list addition है, जबकि semantic mode में meaningful composition, blending और concept merging करता है
  • & syntactic mode में bit/logical AND है, जबकि semantic mode में logical conjunction, inference और context merging को संभालता है
  • semantic-only features में .choice(cases, default), .foreach(condition, apply), .cluster(**clustering_kwargs?), .similarity(other, metric?, normalize?) आदि शामिल हैं
    • .cluster() data को semantically group करता है और sklearn का DBSCAN इस्तेमाल करता है
    • .similarity() embeddings के बीच similarity calculate करता है

contracts के ज़रिए LLM output संभालने का तरीका

  • SymbolicAI इस सोच से Design by Contract सिद्धांत को LLM की दुनिया में लागू करता है कि LLM hallucinate कर सकता है, लेकिन code ऐसा नहीं कर सकता
  • contracts सिर्फ post-hoc tests पर निर्भर नहीं रहते, बल्कि data model और validation constraints को decorator में बांधकर design stage पर correctness संभालते हैं
  • example code का contract decorator ये options इस्तेमाल करता है
    • pre_remedy=True: गलत input को automatically correct करने की कोशिश करता है
    • post_remedy=True: गलत LLM output को automatically correct करने की कोशिश करता है
    • accumulate_errors=True: हर retry में error history pass करता है
    • verbose=True: terminal में progress दिखाता है
    • remedy_retry_params: tries=3, delay=0.4, max_delay=4.0, jitter=0.15, backoff=1.8, graceful=False इस्तेमाल करता है
  • contract applied Expression class का high-level flow इस प्रकार है
    • prompt: LLM को क्या करना है, यह define करने वाला static description; यह required है
    • pre: input check करता है; optional है
    • act: state change करता है; optional है
    • LLM: SymbolicAI engine expected answer generate करता है
    • post: जांचता है कि answer semantic rules satisfy करता है या नहीं; optional है
    • forward: required है; contract success पर type-validated LLM object return करता है और failure पर graceful fallback answer return करता है
  • contract documentation DeepWiki के contract validation system और features/contracts में है

installation और optional features

  • basic installation pip से की जाती है
pip install symbolicai
  • repository clone करके uv >= 0.9.17 से Python virtual environment भी configure किया जा सकता है
git clone git@github.com:ExtensityAI/symbolicai.git
cd symbolicai
uv sync --python x.xx
source ./.venv/bin/activate
  • SymbolicAI text, speech और images process करने के लिए कई engines इस्तेमाल करता है, और web information search के लिए search engine access भी शामिल करता है
  • optional dependencies को feature-wise extras के रूप में install किया जा सकता है
    • bitsandbytes, hf, lean, llama_cpp, ocr, qdrant, scrape, search, serpapi, services, solver, whisper, wolframalpha
  • सभी optional dependencies एक साथ install की जा सकती हैं
pip install "symbolicai[all]"
  • uv sync --frozen provided lock file में pinned dependencies install करता है
  • कुछ optional dependencies के लिए अतिरिक्त installation steps की जरूरत हो सकती है, और कुछ अभी केवल experimental रूप से supported हैं, इसलिए expected behavior न मिल सकता है

configuration management और required engine

  • SymbolicAI priority-based configuration management system इस्तेमाल करता है
  • configuration तीन locations से priority order में load होती है
    • current working directory का debug mode: highest priority, और केवल symai.config.json पर लागू होता है
    • Python environment की environment-specific settings: {python_env}/.symai/ में स्थित, project-specific settings के लिए उपयुक्त
    • home directory की global settings: ~/.symai/ में स्थित, default fallback की भूमिका निभाती हैं
  • managed configuration files तीन हैं
    • symai.config.json: SymbolicAI main configuration
    • symsh.config.json: shell configuration
    • symserver.config.json: server configuration
  • symconfig configuration location, active configuration path और sensitive information truncate की हुई current configuration दिखाता है, और initial package caching व configuration file initialization शुरू करता है
  • symai package इस्तेमाल करने के लिए neuro-symbolic engine अनिवार्य है
  • project path के symai.config.json में engine properties specify करने से environment variables replace हो जाते हैं
    • example configuration में NEUROSYMBOLIC_ENGINE_MODEL value के रूप में claude-sonnet-4-6, embedding model के रूप में text-embedding-3-small, TTS model के रूप में tts-1, OCR model के रूप में mistral-ocr-latest, indexing engine के रूप में qdrant आदि शामिल हैं
  • default रूप से user warnings enabled हैं, और environment variable SYMAI_WARNINGS=0 से इन्हें disable किया जा सकता है

tests, documentation और license

  • tests run करने के examples ये हैं
pytest tests
pytest -m mandatory
pytest --cov=symbolicai tests
  • tests से पहले configuration correctly configured होना चाहिए
  • अगले steps के लिए SymbolicAI DeepWiki page, paper, video tutorials देखे जा सकते हैं
  • citation information Symbolicai: A framework for logic-based approaches combining generative models and solvers नामक 2024 arXiv preprint को संदर्भित करती है
  • project license BSD-3-Clause License है

1 टिप्पणियां

 
GN⁺ 2025-06-29
Hacker News की राय
  • ऐसी वूडू जैसी सुविधाएँ सबसे दिलचस्प हैं
    उदाहरण के लिए, semantic map के साथ ['apple', 'banana', 'cherry', 'cat', 'dog'] पर “सभी फलों को सब्जियों में बदलो” लागू करने पर आउटपुट ['carrot', 'broccoli', 'spinach', 'cat', 'dog'] जैसा आता है, और equals() में context='greeting context' या context='politeness level' जैसे context के आधार पर तुलना का परिणाम बदल जाता है
    bit operators भी semantic logical composition की तरह इस्तेमाल होते हैं, जहाँ horn_rule & observation inference तक ले जाता है, इसलिए interpret() काफी शक्तिशाली लगता है
    इसे बनाने की प्रेरणा, वास्तविक use cases, और अब तक का सबसे पसंदीदा उपयोग उदाहरण जानना चाहूँगा

    • Lotus भी दिलचस्प हो सकता है: https://github.com/lotus-data/lotus
      इसका मूल विचार प्रमुख relational operators के semantic versions को Python dataframe library extension के रूप में बनाना है, और हर call बाद में learning-based approach जैसे अधिक जटिल कामों के लिए “model” point बन जाता है
      Snowflake जैसे cloud SQL क्षेत्र भी इसी दिशा में जाते दिखते हैं, और louie.ai में भी AI notebooks/dashboards/API(MCP आदि) के जरिए Splunk, Databricks, graph DB जैसे डेटा से बात करने पर context के हिसाब से symbolic+semantic operators पहचानने का मिलता-जुलता तरीका अपनाया गया, जो असल इस्तेमाल में काफी उपयोगी रहा
      मुख्य 80% use case यह flow है: “Splunk index xyz से सभी alerts लाओ और suspicious items को दिखाने वाला column तथा कारण समझाने वाला column जोड़ो” जैसे semantic map से augmented dataframe बनाना, फिर “जो मिला उसे summarize करो” जैसे semantic reduce से natural-language explanation पाना
    • सोच रहा हूँ कि apple को सब्जी में बदलने पर carrot क्यों बनता है
    • जवाब शायद बहुत लंबा होगा
      2022 के अंत में project शुरू करने के समय से बहुत कुछ मूल रूप से नहीं बदला है; बस models बेहतर हुए हैं, जबकि GPT-3 के दौर से ही काफी primitive operations मौजूद थे
      हाल में ज़्यादा महत्वपूर्ण DbC contribution है: contracts को chain किया जा सकता है और guardrails अच्छी तरह propagate होते हैं, इसलिए agents से जुड़े लगभग हर problem को इसने हल कर दिया जो मैंने इस पर फेंका—यही इसकी खास बात है
      OpenAI web search की वजह से Perplexity की उपयोगिता कम हो गई, और OpenAI web search भी मेरे खुद के custom setup जितना पर्याप्त नहीं था, इसलिए मैंने अपना deep research agent बनाया: https://x.com/futurisold/status/1931751644233945216
      कंपनी में भी 3 contracts को chain करके end-to-end document generation बनाया, और output example यहाँ है: https://drive.google.com/file/d/1Va7ALq_N-fTYeumKhH4jSxsTrWD...
      input एक अनुरोध था कि प्रमुख AI providers के system prompts की तुलनात्मक analysis की जाए, XML/Markdown/JSON जैसे formats, sycophancy और manipulative instructions, tool-use constraints, ethical guardrails, तथा alignment design में अंतर खोजकर उन्हें technical report में synthesize किया जाए; generated instructions OpenAI, Google, Anthropic, xAI आदि के system prompt structures और linguistic frameworks तथा operational constraints की तुलना करने वाले ठोस सवालों में expand हो गए
      contracts का परिचय मार्च वाली post में दिया गया था और तब से वे काफी विकसित हुए हैं, लेकिन आधार और motivation वही हैं: https://futurisold.github.io/2025-03-01-dbc/
  • paper और example notebook को साथ में link करने से समझने में मदद मिलेगी
    https://github.com/ExtensityAI/symbolicai/blob/main/examples...
    https://arxiv.org/pdf/2402.00854

  • शानदार
    अगर ==, + जैसे operators को syntax नहीं बल्कि semantic operators की तरह इस्तेमाल किया जा सके, तो यह नए ideas के लिए खाद जैसा हो सकता है; कुछ वैसा ही एहसास जैसा word embeddings पहली बार आने पर “King - Man + Woman = Queen” जैसी loose conceptual algebra बनी थी
    हालांकि यहाँ neural network + symbolic integration ज़्यादातर systems की तरह काफी shallow और firewall वाली structure लगती है, और classification के हिसाब से Type 3 / Neuro;Symbolic के करीब है: https://harshakokel.com/posts/neurosymbolic-systems
    असली magic शायद तब आएगा जब integration और ज्यादा fundamental होगा, और हमारी company(https://onton.com) में भी हम LLM के बाद वाले system पर सोच रहे हैं—जिसमें ऐसा unified representation हो जो न pure symbolic हो न dense floating-point matrix, थोड़े से noisy data से incremental learning करते हुए catastrophic forgetting से बचने की क्षमता हो, math और symbolic operations में पक्की reliability हो, और hallucination न हो
    मौजूदा systems को glue gun की तरह जोड़ना भी उपयोगी है, लेकिन लगता है unified architecture सब कुछ बदल देगा

  • correctness contract वाले हिस्से में bug है
    valid_opts = ['A', 'B', 'C'] के बाद if v not in valid_sizes: आता है, लेकिन valid_sizes defined नहीं है

    • यह refactoring का बचा हुआ निशान था, अब ठीक कर दिया है
  • “Symbolic AI” पहले से ही well-defined term है, इसलिए थोड़ा अफसोस होता है: https://en.m.wikipedia.org/wiki/Symbolic_artificial_intellig...

    • यह बात समझता हूँ
      नाम बदला भी जा सकता है, और paper में नाम चुनने पर एक footnote है
      इरादा इस project को inspire करने वाले Newell और Simon के foundational work को credit देने का था
  • लागत संरचना को लेकर जिज्ञासा है
    क्या natural language computation वाली लाइन चलाने पर हर बार LLM inference की लागत देनी पड़ती है, और अगर बाहरी API इस्तेमाल करें तो क्या सचमुच हर बार बिलिंग होती है—यह जानना चाहता हूँ
    उदाहरण के लिए, अगर loop के अंदर “symbolic” function call करें तो क्या होता है?

    • सही है
      उदाहरण के लिए, OpenAI इस्तेमाल करने पर हर meaning-based operation OpenAI API call बन जाता है
      अगर llama.cpp से local LLM host कर रहे हैं, तो model hosting cost के अलावा inference billing नहीं है
    • इसके लिए किसी न किसी रूप में cache की ज़रूरत लगेगी
  • आजकल code LLM ही generate करता है, तो context रखने और Python operators से manipulate किए जा सकने वाले Symbol जैसे खास syntax structure से क्या मदद मिलती है, इसकी जिज्ञासा है—बनाम सामान्य Python code जिसे इंसान checks और balance conditions बताकर बनवाता है
    उदाहरण के लिए, fruits को vegetables में बदलने वाली grammar लिखने के बजाय, LLM को prompt करके ऐसा program बनवाया जा सकता है जो fruits की list लेकर अंदर LLM call करे और corresponding vegetables return करे
    फर्क समझना चाहता हूँ

    • शायद hallucination suppression के लिए
      अगर LLM से formal system बनवाया जाए, तो generic program की तुलना में उसे verify करना कहीं आसान होता है
  • क्या evolve कर सकने वाली neural-symbolic AI पर भी विचार किया है?
    https://deepwiki.com/dubprime/mythral/3.2-genome-system
    या emotions महसूस करने वाली दिशा कैसी है?
    https://deepwiki.com/search/how-do-emotives-work_193cb616-54...
    यह भी जानना चाहता हूँ कि क्या Marvin Minsky की Society of Mind पढ़ी है

    • छोटा जवाब यह है कि हाँ, सब पर
      theory of mind से emotions तक जाने वाले experiments भी किए, लेकिन अभी लगता है कि models अभी उस स्तर तक पर्याप्त नहीं पहुँचे हैं, इसलिए effort के मुकाबले return घटने लगा और काम रुका हुआ है
      इसे आसानी से revive किया जा सकता है, लेकिन Minsky मेरे favorite नहीं हैं; उस पीढ़ी में मुझे Newell/Simon ज़्यादा आकर्षित करते हैं
    • फिर भी अहम बात यह है कि क्या यह explainable है, या जादू जैसा black box
  • LLM से documents review कराकर GitHub के PySR(github.com/MilesCranmer/PySR) में डालने के लिए primitive operators—यानी operators—बनवाने वाली symbolic regression को थोड़ा आज़माया था
    पूरी चीज़ को जोड़ना मुश्किल था, इसलिए बहुत आगे नहीं बढ़ पाया, लेकिन ऐसा tool हो तो शायद फिर कोशिश कर सकता हूँ

    • निश्चित रूप से संभव है
      contracts इस्तेमाल करने की सलाह दूँगा
      टूटे हुए ontology graph को बार-बार “जोड़ने” वाले contracts में मैंने मिलता-जुलता तरीका इस्तेमाल किया था
      inspiration देने वाले data model के तौर पर Merge, Bridge, Prune, Operation जैसी structures रखीं, और हर एक में merge किए जाने वाले cluster indices, parent-child class relationships, और prune की जाने वाली classes की list define की; फिर validator से binary/unary operation conditions enforce कीं
      इसी तरह operators के लिए model बनाया जा सकता है, contract से एक बार में एक operator solve कराया जाए, और फिर उस operator को apply किया जाए