Skip to content

Commit be50116

Browse files
committed
Synalinks version 0.3.0
1 parent 5bd751b commit be50116

File tree

161 files changed

+9952
-1199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+9952
-1199
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ jobs:
2929
run: ./shell/install.sh
3030
- name: Install pytest
3131
run: uv pip install pytest pytest-cov
32+
- name: Start Neo4J
33+
run: docker run --publish=7474:7474 --publish=7687:7687 --volume=$HOME/neo4j/data:/data --env=NEO4J_AUTH=none neo4j
3234
- name: Run the tests
3335
run: ./shell/test.sh

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55

66
<div align="center">
77

8-
98
<p align="center">
109
<a href="https://synalinks.github.io/synalinks" target="_blank"><strong>Documentation</strong></a> ·
1110
<a href="https://synalinks.github.io/synalinks/FAQ/" target="_blank"><strong>FAQ</strong></a> ·
1211
<a href="https://discord.gg/82nt97uXcM" target="_blank"><strong>Discord</strong></a> ·
13-
<a href="https://huggingface.co/spaces/YoanSallami/synalinks-noteboooks" target="_blank"><strong>Code Examples</strong></a>
12+
<a href="https://synalinks.github.io/synalinks" target="_blank"><strong>Code Examples</strong></a>
1413
</p>
1514

1615
<b>Synalinks:</b> <em>A production-first LM framework built with decade old Deep Learning best practices</em>
@@ -21,7 +20,7 @@
2120

2221
![Beta](https://img.shields.io/badge/Release-Beta-blue.svg)
2322
![Coverage Badge](https://raw.githubusercontent.com/SynaLinks/synalinks/refs/heads/main/coverage-badge.svg)
24-
[![Pypi Downloads](https://img.shields.io/pypi/dm/synalinks)](https://pypistats.org/packages/synalinks)
23+
[![Downloads](https://static.pepy.tech/badge/synalinks)](https://pepy.tech/project/synalinks)
2524
[![Discord](https://img.shields.io/discord/1118241178723291219)](https://discord.gg/82nt97uXcM)
2625
[![Python package](https://github.com/SynaLinks/Synalinks/actions/workflows/tests.yml/badge.svg)](https://github.com/SynaLinks/SynaLinks/actions/workflows/tests.yml)
2726
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://opensource.org/license/apache-2-0)
@@ -42,15 +41,15 @@ Synalinks is designed for a diverse range of users, from professionals and AI re
4241

4342
Developping a successful LM application in a profesional context, beyond stateless chatbots, is difficult and typically include:
4443

45-
- **Building optimized prompts with examples/instructions at each step**: Synalinks uses advanced In-Context Reinforcement Learning techniques to optimize each prompt.
44+
- **Building optimized prompts with examples/instructions at each step**: Synalinks uses advanced In-Context Reinforcement Learning techniques to optimize **each** prompt of your workflow/agent.
4645
- **Pipelines that change over time**: Easily edit your pipelines, re-run your training, and you're good to go.
47-
- **Ensuring the correctness of the LMs output**: Synalinks combines constrained structured output with In-Context RL to ensure both format and content correctness.
48-
- **Async Optimization**: Synalinks automatically optimizes your pipelines by detecting parallel processes.
46+
- **Ensuring the correctness of the LMs output**: Synalinks combines *constrained structured output* with In-Context RL to ensure **both format and content correctness**.
47+
- **Async Optimization**: Synalinks automatically optimizes your pipelines by detecting parallel processes, so you don't have to worry about it.
4948
- **Assessing the performance of your application**: Synalinks provides built-in metrics and rewards to evaluate your workflows.
50-
- **Configuring Language & Embedding Models**: Seamlessly integrate multiple LM providers like Ollama, OpenAI, Anthropic, Mistral or Groq.
49+
- **Configuring Language & Embedding Models**: Seamlessly integrate multiple LM providers like Ollama, OpenAI, Azure, Anthropic, Mistral or Groq.
5150
- **Documenting your ML workflows**: Plot your workflows, training history, and evaluations; document everything.
5251
- **Versioning the prompts/pipelines**: Each program is serializable into JSON so you can version it with git.
53-
- **Deploying REST APIs**: Compatible out-of-the-box with FastAPI so your Data Scientists and Web Developers can stop tearing each other apart.
52+
- **Deploying REST APIs**: Compatible out-of-the-box with FastAPI and FastMPC so your Data Scientists and Web Developers can stop tearing each other apart.
5453

5554
Synalinks can help you simplify these tasks by leveraging decade old practices in Deep Learning frameworks. We provide a comprehensive suite of tools and features designed to streamline the development process, making it easier to create, evaluate, train, document and deploy robust neuro-symbolic LMs applications.
5655

@@ -83,7 +82,7 @@ class Query(synalinks.DataModel):
8382

8483
class AnswerWithThinking(synalinks.DataModel):
8584
thinking: str = synalinks.Field(
86-
description="Your step by step thinking process",
85+
description="Your step by step thinking",
8786
)
8887
answer: float = synalinks.Field(
8988
description="The correct numerical answer",
@@ -292,7 +291,7 @@ class Query(synalinks.DataModel):
292291

293292
class AnswerWithThinking(synalinks.DataModel):
294293
thinking: str = synalinks.Field(
295-
description="Your step by step thinking process",
294+
description="Your step by step thinking",
296295
)
297296
answer: float = synalinks.Field(
298297
description="The correct numerical answer",
@@ -404,6 +403,19 @@ Beware that every additional metric/module/optimizer should be approved by the c
404403

405404
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.
406405

406+
### Citing our work
407+
408+
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:
409+
410+
```bibtex
411+
@misc{sallami2025synalinks,
412+
title={Synalinks},
413+
author={Sallami, Yoan and Chollet, Fran\c{c}ois},
414+
year={2025},
415+
howpublished={\url{https://github.com/SynaLinks/Synalinks}},
416+
}
417+
```
418+
407419
### Credit
408420

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

coverage-badge.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# First Knowledge Graph Schema
2+
3+
A knowledge graph schema is like a blueprint that defines the structure and rules for organizing information in a graph format. Just as a database schema defines tables and their relationships, a knowledge graph schema defines entities (nodes) and relations (edges) that can exist in your graph.
4+
This tutorial will teach you how to analyze information domains and translate them into structured schema definitions using the synalinks framework.
5+
6+
### Entities
7+
8+
Entities represent the "things" in your domain - people, places, objects, concepts, or events.
9+
10+
Each entity type has:
11+
12+
- A `label`: A unique identifier that distinguishes this entity type from all others?
13+
- Properties: Attributes that capture the entity's characteristics.
14+
- Descriptions: Clear, specific descriptions that guide the LMs for accurate data extraction and understanding.
15+
16+
When designing entities, consider both current needs and future extensibility. Properties should be atomic (single-valued) when possible, but flexible enough to accommodate variations in your data.
17+
18+
Example:
19+
20+
```python
21+
import synalinks
22+
from typing import Literal, List, Union
23+
24+
class City(synalinks.Entity):
25+
label: Literal["City"]
26+
name: str = synalinks.Field(
27+
description="The name of a city, such as 'Paris' or 'New York'.",
28+
)
29+
30+
class Country(synalinks.Entity):
31+
label: Literal["Country"]
32+
name: str = synalinks.Field(
33+
description="The name of a country, such as 'France' or 'Canada'.",
34+
)
35+
36+
class Place(synalinks.Entity):
37+
label: Literal["Place"]
38+
name: str = synalinks.Field(
39+
description="The name of a specific place, which could be a landmark, building, or any point of interest, such as 'Eiffel Tower' or 'Statue of Liberty'.",
40+
)
41+
42+
class Event(synalinks.Entity):
43+
label: Literal["Event"]
44+
name: str = synalinks.Field(
45+
description="The name of an event, such as 'Summer Olympics 2024' or 'Woodstock 1969'.",
46+
)
47+
```
48+
49+
### Relations
50+
51+
Relations are the connective tissue of your knowledge graph, representing how entities interact, depend on, or relate to each other. They transform isolated data points into a rich, interconnected web of knowledge.
52+
53+
Each relations has:
54+
55+
- A subject (`subj`): The source entity of the relation.
56+
- A label (`label`): The type of relationship.
57+
- A target (`obj`): The target entity of the relation.
58+
- Properties: Attributes that describe/enrich the relation.
59+
- Descriptions: Clear explanations of what each property represents to help extraction.
60+
61+
Example:
62+
63+
```python
64+
class IsCapitalOf(synalinks.Relation):
65+
subj: City = synalinks.Field(
66+
description="The city entity that serves as the capital.",
67+
)
68+
label: Literal["IsCapitalOf"]
69+
obj: Country = synalinks.Field(
70+
description="The country entity for which the city is the capital.",
71+
)
72+
73+
74+
class IsCityOf(synalinks.Relation):
75+
subj: City = synalinks.Field(
76+
description="The city entity that is a constituent part of a country.",
77+
)
78+
label: Literal["IsCityOf"]
79+
obj: Country = synalinks.Field(
80+
description="The country entity that the city is part of.",
81+
)
82+
83+
84+
class IsLocatedIn(synalinks.Relation):
85+
subj: Union[Place] = synalinks.Field(
86+
description="The place entity that is situated within a larger geographical area.",
87+
)
88+
label: Literal["IsLocatedIn"]
89+
obj: Union[City, Country] = synalinks.Field(
90+
description="The city or country entity where the place is geographically located.",
91+
)
92+
93+
94+
class TookPlaceIn(synalinks.Relation):
95+
subj: Event = synalinks.Field(
96+
description="The event entity that occurred in a specific location.",
97+
)
98+
label: Literal["TookPlaceIn"]
99+
obj: Union[City, Country] = synalinks.Field(
100+
description="The city or country entity where the event occurred.",
101+
)
102+
```
103+
104+
### Schema Design Strategy and Best Practices
105+
106+
Start with Domain Analysis
107+
Before writing any code, invest time in understanding your domain thoroughly:
108+
109+
1. **Identify Core Concepts**: List the most important "things" in your domain
110+
2. **Map Natural Relationships**: Observe how these concepts connect in real-world scenarios
111+
3. **Consider Use Cases**: Think about the questions your knowledge graph should answer
112+
4. **Plan for Growth**: Design schemas that can evolve with your understanding
113+
114+
### Balance Granularity and Usability
115+
116+
Finding the right level of detail is crucial:
117+
118+
- **Too Generic**: Loses important nuances and becomes less useful
119+
- **Too Specific**: Creates maintenance overhead and reduces flexibility
120+
- **Just Right**: Captures essential distinctions while remaining manageable
121+
122+
### Implement Iterative Refinement
123+
124+
Schema development is rarely a one-shot process, always:
125+
126+
- **Start Simple**: Begin with basic entities and core relationships
127+
- **Test with Real Data**: Validate your schema against actual use cases
128+
- **Identify Gaps**: Notice what your current schema cannot represent
129+
- **Refine Gradually**: Add complexity only when justified by real needs
130+
- **Document Decisions**: Keep track of why you made specific design choices
131+
132+
### Conclusion
133+
134+
Creating effective knowledge graph schemas is both an art and a science. Success comes from understanding your domain deeply, designing with use-case in mind, and remaining flexible as requirements evolve. Your schema serves as the foundation for all downstream applications—from search and recommendation systems to complex analytics and AI applications.
135+
136+
With these foundations in place, your knowledge graph schema will serve as a robust platform for organizing, connecting, and leveraging information in powerful new ways.
137+
138+
### Key Takeaways
139+
140+
- **Knowledge Graph Schema Basics**: A knowledge graph schema defines the structure and rules for organizing information in a graph format, consisting of entities (nodes) and relations (edges).
141+
142+
- **Entities**: Represent "things" in your domain such as people, places, objects, concepts, or events. Each entity type has a unique `label`, properties, and descriptions. Properties should be atomic and flexible to accommodate variations in data.
143+
144+
- **Relations**: Represent how entities interact or relate to each other. Each relation has a subject (`subj`), a label (`label`), a target (`obj`), properties, and descriptions.
145+
146+
- **Schema Design Strategy**: Start with a thorough domain analysis to identify core concepts and map natural relationships. Consider use cases and plan for future growth.
147+
148+
- **Balance Granularity and Usability**: Avoid being too generic or too specific; aim for a balance that captures essential distinctions while remaining manageable.
149+
150+
- **Iterative Refinement**: Begin with simple entities and core relationships. Test with real data, identify gaps, and refine gradually. Document design decisions for future reference.

0 commit comments

Comments
 (0)