Skip to content

πŸ§ πŸ”— From idea to production in just few lines: Graph-Based Programmable Neuro-Symbolic LM Framework - a production-first LM framework built with decade old Deep Learning best practices

License

Notifications You must be signed in to change notification settings

SynaLinks/synalinks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

From idea to production in just few lines

The first neuro-symbolic Language Model (LM) framework leveraging the simplicity of Keras and the rigor of Deep Learning best practices.

Build RAGs, autonomous agents, multi-agents systems, self-evolving systems and more in just few lines

Documentation Β· FAQ Β· Discord Β· Code Examples

⭐ If you find Synalinks useful, please star the repo! Help us reach more AI/ML engineers and grow the community. ⭐

Beta Code style: black Coverage Badge Downloads Discord Python package License: Apache-2.0 Ask DeepWiki

Too busy to read the documentation? Give the llms.txt or llms-full.txt to you favorite LMs or AI coding tools

What Is Synalinks?

Synalinks is an open-source neuro-symbolic framework that makes it simple to create, train, evaluate, and deploy advanced LM-based applications, including graph RAGs, autonomous agents, and self-evolving reasoning systems.

Think Keras for Language Models applications, a clean, declarative API where:

  • 🧩 You compose modules like you would with layers.
  • βš™οΈ You train & optimize with in-context reinforcement learning.
  • 🌐 You deploy instantly as REST APIs or MCP servers.

Key Principles

  • Progressive complexity: Start simple and grow advanced naturally.
  • Neuro-symbolic learning: Combine logic, structure, and deep models.
  • In-context optimization: Improve model reasoning without retraining weights.

Who Is It For?

Role Why Synalinks Helps
πŸ§‘β€πŸ’» Developers Build complex LM apps without boilerplate.
🧠 Researchers Prototype neuro-symbolic and RL-in-context systems fast.
🏒 Data Scientists Integrate LM workflows with APIs & databases.
πŸŽ“ Students/Hobbyists Learn AI composition in a clean, intuitive framework.

Why Synalinks?

Building robust LM apps is hard. Synalinks simplifies it with:

  • Prompt/Anything optimization per module via In-Context RL
  • Versionable, JSON-serializable pipelines
  • Constrained structured outputs (JSON) for correctness
  • Automatic async & parallel execution
  • Metrics, rewards & evaluations built-in
  • Native integrations: OpenAI, Ollama, Anthropic, Mistral, Azure, Groq, Gemini, XAI
  • Graph DB support: Neo4J, MemGraph
  • API-ready: Deploy with FastAPI or FastMCP
  • KerasTuner compatibility for hyperparameter search
Framework MCP Graph DB Logical Flow Robust Branching Parallel Function Calling Hyperparameter Tuning Ease of Use
Synalinks βœ… Yes βœ… Yes βœ… Yes βœ… Yes βœ… Yes βœ… Yes πŸ˜€
DSPy βœ… Yes ❌ No ❌ No ❌ No ❌ No ❌ No 😒
AdalFlow βœ… Yes ❌ No ❌ No ❌ No ❌ No ❌ No 😒
TextGrad ❌ No ❌ No ❌ No ❌ No ❌ No ❌ No 😭
Trace ❌ No ❌ No ❌ No ❌ No ❌ No ❌ No 😭

Installation

uv pip install synalinks

Example

import synalinks
import asyncio

class Query(synalinks.DataModel):
    query: str = synalinks.Field(
        description="The user query",
    )

class NumericalAnswer(synalinks.DataModel):
    answer: float = synalinks.Field(
        description="The final numerical answer",
    )

language_model = synalinks.LanguageModel(
    model="gemini/gemini-2.5-pro",
)

@synalinks.saving.register_synalinks_serializable()
async def calculate(expression: str):
    """Calculate the result of a mathematical expression.

    Args:
        expression (str): The mathematical expression to calculate, such as
            '2 + 2'. The expression can contain numbers, operators (+, -, *, /),
            parentheses, and spaces.
    """
    if not all(char in "0123456789+-*/(). " for char in expression):
        return {
            "result": None,
            "log": "Error: invalid characters in expression",
        }
    try:
        # Evaluate the mathematical expression safely
        result = round(float(eval(expression, {"__builtins__": None}, {})), 2)
        return {
            "result": result,
            "log": "Successfully executed",
        }
    except Exception as e:
        return {
            "result": None,
            "log": f"Error: {e}",
        }

async def main():
    inputs = synalinks.Input(data_model=Query)

    outputs = await synalinks.FunctionCallingAgent(
        data_model=NumericalAnswer,
        tools=[
            synalinks.Tool(calculate),
        ],
        language_model=language_model,
    )(inputs)

    program = synalinks.Program(
        inputs=inputs,
        outputs=outputs,
        name="math_agent",
        description="A math agent",
    )

Getting a summary of your program

To print a tabular summary of your program:

program.summary()

Or a plot (Useful to document your system):

synalinks.utils.plot_program(
    program,
    show_module_names=True,
    show_trainable=True,
    show_schemas=True,
)

Running your program

To run your program use the following:

result = await program(
    Query(
        query=(
            "A bookstore receives a shipment of 135 new books."
            "They place the books evenly onto 9 shelves."
            "Later, they decide to move 3 books from each shelf to a display table"
            " at the front of the store. "
            "How many books are left on the shelves after the books are moved?"
        )
    ),
)

Training your program/agent

async def main():

    # ... your program definition

    (x_train, y_train), (x_test, y_test) = synalinks.datasets.gsm8k.load_data()

    program.compile(
        reward=synalinks.rewards.ExactMatch(
            in_mask=["answer"],
        ),
        optimizer=synalinks.optimizers.OMEGA(
            language_model=language_model,
            embedding_model=embedding_model,
        ),
    )

    batch_size=1
    epochs=10

    history = await program.fit(
        x_train,
        y_train,
        validation_split=0.2,
        batch_size=batch_size,
        epochs=epochs,
    )

if __name__ == "__main__":
    asyncio.run(main())

Saving & Loading

To save the entire architecture and variables (the program's state) into a JSON file, do:

program.save("my_program.json")

In order to load it, do:

loaded_program = synalinks.Program.load("my_program.json")

To save only the state your program (the variables) into JSON:

program.save_variables("my_program.variables.json")

To load its variables (needs a program with the same architecture), do:

program.load_variables("my_program.variables.json")

Logging

To enable logging, use the following at the beginning of your script:

synalinks.enable_logging()

Learn more

You can learn more by reading our documentation. If you have questions, the FAQ might help you.

Contributions

Contributions are welcome, either for the implementation of additional modules, metrics, or optimizers. For more information, or help for implementing your ideas (or ones from a paper), please join our discord.

Beware that every additional metric/module/optimizer should be approved by the core team, we want to keep the library minimal and clean as possible to avoid an uncontrolled growth leading to bad software practices like in most current leading LM frameworks.

If you have specific feedbacks or features request we invite you to open an issue.

Contributors

Your contributions, feedback, and support are what make this project thrive.

From small bug fixes to major features, thank you for believing in open collaboration and the future of neuro-symbolic AI.

Community

Join our community to learn more about neuro-symbolic systems and the future of AI. We welcome the participation of people from very different backgrounds or education levels.

Citing our work

This work have been done under the supervision of FranΓ§ois Chollet, the author of Keras. If this work is useful for your research please use the following bibtex entry:

@misc{sallami2025synalinks,
  title={Synalinks},
  author={Sallami, Yoan and Chollet, Fran\c{c}ois},
  year={2025},
  howpublished={\url{https://github.com/SynaLinks/Synalinks}},
}

Credit

Synalinks would not be possible without the great work of the following open-source projects:

  • Keras for the graph-based computation backbone, API and overall code, design and philosophy.
  • DSPy for the modules/optimizers inspiration.
  • Pydantic for the backend data layer.
  • LiteLLM for the LMs integrations.

About

πŸ§ πŸ”— From idea to production in just few lines: Graph-Based Programmable Neuro-Symbolic LM Framework - a production-first LM framework built with decade old Deep Learning best practices

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6