{"id":25177832,"url":"https://github.com/mariocosenza/kgsum","last_synced_at":"2026-04-11T07:43:42.866Z","repository":{"id":276626995,"uuid":"929812322","full_name":"mariocosenza/kgsum","owner":"mariocosenza","description":"Thesis project on knowledge graph summarization","archived":false,"fork":false,"pushed_at":"2025-11-19T21:27:52.000Z","size":7556,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-19T23:19:11.996Z","etag":null,"topics":["ai","artificial-intelligence","asyncio","classification","flask","knowledge-graph","python","python3","rdf","rdflib","rest-api","scikit-learn","spacy","sparql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mariocosenza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-09T13:17:38.000Z","updated_at":"2025-09-13T20:32:13.000Z","dependencies_parsed_at":"2025-03-03T19:22:45.655Z","dependency_job_id":"f0e47fe1-604a-4395-ba87-97e1e8823f65","html_url":"https://github.com/mariocosenza/kgsum","commit_stats":null,"previous_names":["mariocosenza/kgsum"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mariocosenza/kgsum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocosenza%2Fkgsum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocosenza%2Fkgsum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocosenza%2Fkgsum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocosenza%2Fkgsum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mariocosenza","download_url":"https://codeload.github.com/mariocosenza/kgsum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocosenza%2Fkgsum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31673067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","asyncio","classification","flask","knowledge-graph","python","python3","rdf","rdflib","rest-api","scikit-learn","spacy","sparql"],"created_at":"2025-02-09T14:49:39.472Z","updated_at":"2026-04-11T07:43:42.861Z","avatar_url":"https://github.com/mariocosenza.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca id=\"readme-top\"\u003e\u003c/a\u003e\n\n\u003c!-- PROJECT SHIELDS --\u003e\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![project_license][license-shield]][license-url]\n[![LinkedIn][linkedin-shield]][linkedin-url]\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/mariocosenza/kgsum\"\u003e\n    \u003cimg src=\"images/logo.png\" alt=\"Logo\" width=\"100\" height=\"80\"\u003e\n  \u003c/a\u003e\n\n\u003ch3 align=\"center\"\u003eKgSum\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    A Python application for extracting, preparing, and classifying Knowledge Graphs, leveraging LLMs and traditional machine learning.\u003cbr\u003e\n    \u003cb\u003eThesis Project, University of Salerno, ISISLab\u003c/b\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/mariocosenza/kgsum/wiki\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/mariocosenza/kgsum/issues/new?labels=bug\u0026template=bug-report---.md\"\u003eReport Bug\u003c/a\u003e\n    \u0026middot;\n    \u003ca href=\"https://github.com/mariocosenza/kgsum/issues/new?labels=enhancement\u0026template=feature-request---.md\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#prerequisites\"\u003ePrerequisites\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#configuration\"\u003eConfiguration\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#docker-deployment\"\u003eDocker Deployment\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#roadmap\"\u003eRoadmap\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgments\"\u003eAcknowledgments\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\n[![Product Name Screen Shot][product-screenshot]](https://github.com/mariocosenza/kgsum)\n\n**KgSum** is a Python application for extracting, preparing, and classifying Knowledge Graphs (KGs). It combines Large Language Models (such as Mistral Instructor 7B with QLoRA) and traditional machine learning for effective graph classification and profiling.\n\nThesis Project for Bachelor's Degree  \nUniversity of Salerno  \nLab: ISISLab  \nAuthor: Mario Cosenza  \nSupervisor: Maria Angela Pellegrino  \n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### Built With\n\n* [Python 3.12](https://www.python.org/)\n* [PyTorch](https://pytorch.org/)\n* [Transformers](https://huggingface.co/docs/transformers)\n* [spaCy](https://spacy.io/)\n* [Flask](https://flask.palletsprojects.com/)\n* [Next.js](https://nextjs.org/)\n* [React](https://reactjs.org/)\n* [TailwindCSS](https://tailwindcss.com/)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\nFollow these steps to set up KgSum locally.\n\n### Prerequisites\n\n#### For Local Machine Learning Backend:\n- **Miniconda** (required)\n- **Python 3.12** (suggested)\n- **CUDA 12.8** (for transformer models like Mistral)\n- **NVIDIA GPU** (recommended: RTX 3070 or higher)\n\n#### For Frontend:\n- **Node.js** \n- **npm**\n\n#### For Docker Deployment:\n- **Docker**\n- **Docker Compose**\n\n### Installation\n\n#### Local Setup (Machine Learning Backend)\n\n1. Clone the repository:\n   ```sh\n   git clone https://github.com/mariocosenza/kgsum.git\n   cd kgsum\n   ```\n\n2. Create and activate conda environment:\n   ```sh\n   conda env create -f environment.yml\n   conda activate kgsum\n   ```\n\n3. **For GPU/Transformer Models (Mistral):**\n   - Comment out CUDA libraries in `environment.yml`\n   - Change TensorFlow version to GPU-compatible version as suggested in comments\n\n#### Frontend Setup\n\n1. Install dependencies:\n   ```sh\n   npm install\n   ```\n\n2. Run the frontend:\n   ```sh\n   npm run dev\n   ```\n\n3. **For GraphDB embedding visualization:**\n   - Replace GraphDB's `security-config.xml` with the one in `/docker/graphdb`\n\n### Configuration\n\n#### Environment Variables\n\nSet the following environment variables in your shell:\n\n```sh\nexport GEMINI_API_KEY=your_gemini_api_key_here\nexport LOCAL_ENDPOINT_LOV=http://your-local-endpoint\nexport LOCAL_ENDPOINT=http://your-local-endpoint\nexport SECRET_KEY=your_secret_key_here\nexport UPLOAD_FOLDER=/path/to/uploads\nexport NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key\nexport CLERK_MIDDLEWARE_ENABLED=true  # Set false if authentication not required\nexport CLERK_SECRET_KEY=your_clerk_secret_key\nexport CLASSIFICATION_API_URL=http://localhost:5000\nexport GITHUB_TOKEN=your_github_token_here\n```\n\n#### Backend Configuration\n\nConfigure the backend by editing `config.json`:\n\n```json\n{\n  \"labeling\" : {\n    \"use_gemini\": false,\n    \"search_zenodo\": true,\n    \"search_github\": true,\n    \"search_lod_cloud\": true,\n    \"stop_before_merging\": false\n  },\n  \"extraction\": {\n    \"start_offset\": 0,\n    \"step_numbers\": 10,\n    \"step_range\": 16,\n    \"extract_sparql\": true,\n    \"query_lov\": false\n  },\n  \"processing\" : {\n    \"use_ner\": false,\n    \"use_filter\": true\n  },\n  \"training\" : {\n     \"classifier\": \"NAIVE_BAYES\",\n     \"feature\": [\"CURI\", \"PURI\"],\n     \"oversample\": false,\n     \"max_token\": 256,\n     \"use_tfidf_autoencoder\": true\n  },\n  \"profile\": {\n    \"store_profile_after_training\": false,\n    \"base_domain\": \"https://example.org\"\n  },\n  \"general_settings\": {\n    \"info\": \"Possible classifiers: SVM, NAIVE_BAYES, KNN, J48, MISTRAL, MLP, DEEP, BATCHNORM, Phase: LABELING, EXTRACTION, PROCESSING, TRAINING, STORE\",\n    \"start_phase\": \"labeling\",\n    \"stop_phase\": \"training\",\n    \"allow_upload\": \"false\"\n  }\n}\n```\n\n**Available Classifiers:** SVM, NAIVE_BAYES, KNN, J48, MISTRAL, MLP, DEEP, BATCHNORM  \n**Available Features:** CURI, PURI  \n**Processing Phases:** LABELING, EXTRACTION, PROCESSING, TRAINING, STORE\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n\n### Training Process\n\n#### Full Training Pipeline\nRun the complete training process from extraction to model training:\n```sh\npython train.py\n```\n\n#### Individual Script Training\nFor more fine-tuned control, run individual scripts in `/src`:\n```sh\n# Run scripts in /src directory for specific phases\n```\n\n### Running the Application\n\n#### Local Flask Server\nAfter completing training, start the WSGI Flask server on port 5000:\n```sh\npython app.py\n```\n\n#### Prerequisites for Complete Profiling\n- **Linked Open Vocabularies (LOV) instance** is required for complete profiling and initial data extraction\n\n### API Usage\n\nSend POST requests to:\n- `/api/v1/profile/sparql`\n- `/api/v1/profile/file`\n\nRefer to the Swagger documentation for detailed request and response formats.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- DOCKER DEPLOYMENT --\u003e\n## Docker Deployment\n\n### Quick Setup with Pre-trained Model\n\nFor a simpler deployment using the pre-trained Naive Bayes model:\n\n1. Navigate to the docker directory:\n   ```sh\n   cd /docker\n   ```\n\n2. Fill the `.env` file with your configuration\n\n3. Run with Docker Compose:\n   ```sh\n   docker-compose up\n   ```\n\n### Individual Docker Services\n\nThree individual Dockerfiles are provided for custom deployments:\n- **Backend** service\n- **Frontend** service  \n- **GraphDB** configuration\n\n### Hardware Requirements\n\n#### Tested Configuration\n| Component | Specification                    |\n|-----------|----------------------------------|\n| CPU       | AMD Ryzen 5800x                 |\n| RAM       | 32 GB DDR4 3600MHz             |\n| GPU       | NVIDIA RTX 3070                |\n\n#### Recommended Configuration\n| Component | Specification                    |\n|-----------|----------------------------------|\n| RAM       | 64+ GB (larger size suggested)  |\n| GPU       | High-performance GPU for better LLM performance |\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- ROADMAP --\u003e\n## Roadmap\n\n- [x] Add Swagger API documentation\n- [x] Expand coverage for more LLMs\n- [x] Improve Docker deployment documentation\n- [ ] Add more dataset preparation examples\n- [ ] Add performance optimization guides\n- [ ] Enhance frontend visualization features\n\nSee the [open issues](https://github.com/mariocosenza/kgsum/issues) for a full list of proposed features (and known issues).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### Top contributors:\n\n\u003ca href=\"https://github.com/mariocosenza/kgsum/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=mariocosenza/kgsum\" alt=\"contrib.rocks image\" /\u003e\n\u003c/a\u003e\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the MIT License. See `LICENSE.txt` for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nMario Cosenza - [@mario_cosenza_](https://x.com/mario_cosenza_) - cosenzamario@proton.me  \nSupervisor: Maria Angela Pellegrino\n\nProject Link: [https://github.com/mariocosenza/kgsum](https://github.com/mariocosenza/kgsum)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- ACKNOWLEDGMENTS --\u003e\n## Acknowledgments\n\n* University of Salerno, ISISLab\n* [Mistral LLM](https://mistral.ai/)\n* [LOD Cloud](https://lod-cloud.net/)\n* [Zenodo](https://zenodo.org/)\n* [Linked Open Vocabularies](https://lov.linkeddata.es/)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/mariocosenza/kgsum.svg?style=for-the-badge\n[contributors-url]: https://github.com/mariocosenza/kgsum/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/mariocosenza/kgsum.svg?style=for-the-badge\n[forks-url]: https://github.com/mariocosenza/kgsum/network/members\n[stars-shield]: https://img.shields.io/github/stars/mariocosenza/kgsum.svg?style=for-the-badge\n[stars-url]: https://github.com/mariocosenza/kgsum/stargazers\n[issues-shield]: https://img.shields.io/github/issues/mariocosenza/kgsum.svg?style=for-the-badge\n[issues-url]: https://github.com/mariocosenza/kgsum/issues\n[license-shield]: https://img.shields.io/github/license/mariocosenza/kgsum.svg?style=for-the-badge\n[license-url]: https://github.com/mariocosenza/kgsum/blob/master/LICENSE.txt\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://linkedin.com/in/mariocosenza\n[product-screenshot]: images/logo_isis.png","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariocosenza%2Fkgsum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariocosenza%2Fkgsum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariocosenza%2Fkgsum/lists"}