Martialis is a next-generation framework designed to enhance the performance of Large Language Models (LLMs) in solving complex linguistic tasks in domain-specific contexts (e.g., healthcare, legal, manufacturing). By integrating Knowledge Graphs (KGs) and Ontologies, Martialis provides accurate answers and generates structured, domain-specific texts.
- Domain-Specific Knowledge Integration: combines sub-symbolic (LLMs) and symbolic AI (Knowledge Graphs) for enhanced reasoning.
- Advanced Retrieval-Augmented Generation (RAG): augments traditional RAG techniques with domain-specific KGs for precise responses.
- Ontology-Based Validation: ensures generated outputs align with predefined ontologies, improving consistency and reliability.
- Open-Source and Modular: fully customizable for diverse domains and use cases.
The framework is built with a modular architecture, enabling customization and adaptability to various use cases. Each module can be replaced or extended to meet specific requirements.
The core components of Martialis are:
-
Automatic KG-Extractor: automatically generates domain-specific KGs from unstructured documents, providing a structured representation of the domain's knowledge.
-
Advanced Retrieval-Augmented-Generation (RAG): enhances the standard RAG pipeline by integrating domain-specific KGs to support reasoning and generate accurate responses to complex queries.
-
Ontology-Based Validator: ensures the generated outputs align with predefined ontologies, validating their structure and content to guarantee consistency and compliance.
Complete Martialis' architecture is presented below:
Martialis is designed to address two primary types of domain-specific linguistic tasks:
Martialis can answer complex questions by leveraging its Advanced Retrieval-Augmented-Generation (RAG) Module.
When a user poses a question, the framework retrieves relevant context from the domain-specific documents stored in its Vector Database. It then integrates this context with the structured information in the Domain Knowledge Graph to enhance reasoning and generate precise answers.
Martialis has great capability in generating structured, domain-specific texts using its Ontology-Based Validator Module.
Users can request detailed outputs. The framework first retrieves relevant entities and properties from the domain ontology to construct a blueprint for the requested text. It then validates the generated text by comparing its structure and content against the ontology, assigning a confidence score to indicate compliance.
This guide will help you set up Martialis and run your first tasks for question answering and text generation.
First of all, clone the repository:
git clone https://github.com/DIAG-Sapienza-BPM-Smart-Spaces/Martialis.gitcd MartialisBefore starting, ensure you have the required libraries listed in the requirements.txt file:
pip install -r requirements.txtAfter cloning the repository, you need to configure the .env file with the correct values for your environment. Follow these steps:
- copy the file
.env.sampleas file.envusing the following command
cp .env.sample .env- Update variables in the
.envfile:
OPEN_API_KEY: your openai api keyLLAMA_API_KEY: your llama api key (check: https://cloud.llamaindex.ai/login)MISTRAL_API_KEY: your mistral api keyNEO4J_USERNAME: username from neo4j DBNEO4J_PASSWORD: password from neo4j DBNEO4J_URL: bolt://localhost:7687
Coming soon
Coming soon
For more detailed information on the underlying concepts and methodologies that Martialis is based on, please refer to the following papers:
-
Bianchini F., Calamo M., De Luzi F., Macrì M and Mecella M. (2024) - Enhancing Complex Linguistic Tasks Resolution through Fine-tuning LLMs, RAG, and Knowledge Graphs This paper introduces the integration of Knowledge Graphs into the RAG framework to solve complex linguistic tasks in domain-specific contexts. It lays the foundation for the approach used in Martialis, focusing on improving LLM capabilities by incorporating structured knowledge.
-
Bianchini F., Calamo M., De Luzi F., Macrì M and Mecella M. (2024) - A Service-Based Pipeline for Complex Linguistic Tasks Adopting LLMs and Knowledge Graphs
This work presents a service-based framework that adapts LLMs and Knowledge Graphs to provide precise answers and domain-specific text generation. It discusses the modular architecture and the potential for applying Martialis across various industries, including healthcare and law.
