Skip to content

gsi-upm/kgem-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KGEM-API + News Recommendation Microservice

A project focused on exploiting Knowledge Graph Embeddings for tasks related to news recommendation.

This work is part of the AMOR project by the Intelligent Systems Group (GSI-UPM).

Main Component: kgem_api/

The core component of this project is a FastAPI-based backend that provides advanced operations on knowledge graphs using embedding models like TransE, ComplEx, and more. Some of the main features are:

  • Retrieve entity embeddings in different graphs.
  • Calculate cosine similarity between entity groups.
  • Compute centroid and geometric overlaps between groups of entities.
  • Measure distances in embedding space.
  • List available graph datasets and trained model.

Explore the full API at kgem_api/.

Use Case: recommendation_service/

A microservice that consumes the KGEM-API to power a straightforward news recommendation use case.
It takes two sets of graph entity IDs (one for each article) and performs:

  • Feature extraction using kgem_api
  • ML-based classification (good/bad recommendation) or regression (relevance score)

🧾 Based on the work in: Implementation and Evaluation of Knowledge Graph-Based Models for News Recommendation (Undergraduate Thesis)

More details in recommendation_service/.

⚙️ Getting started

Recommended: Docker Compose

git clone https://github.com/your-user/kgem-api-gsi.git
cd kgem-api-gsi
docker-compose up --build

Once running:


Run Independently (for local dev or debugging)

You can also run each service separately using uv, a modern Python package manager:

# From inside each service folder:
cd kgem_api
uv run python -m uvicorn main:app --reload --port 8000

# Or for the recommender:
cd recommendation_service
uv run python -m uvicorn main:app --reload --port 8002

💡 Use different ports (default is 8000).

The command uvicorn main:app --reload starts a development server for the FastAPI application. It tells Uvicorn to look for the app instance in the main.py file and serves it on the default port (8000). The --reload flag enables auto-reloading, so the server restarts automatically whenever you make changes to the code. Check FastAPI documentation for further information.


API Interactive Documentation

FastAPI provides an interactive documentation available at:

After clicking on the link you should see something like this:

image

This interface allows you to explore all available endpoints, see what data each one accepts, and view the expected responses. You can even test the API directly from your browser by sending requests and seeing the results in real-time, in a user-friendly way :)

Visit fastAPI Interactive Docs Page for further details on this topic.

About

An api for easy access to Knowledge Graphs and operations with Knowledge Graph Embedding Models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published