Giter Site home page Giter Site logo

davidpomerenke / scitext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexanderprochnow/scitext

0.0 2.0 0.0 79.29 MB

An automatic Text-to-Knowledge-Graph pipeline that was built to create knowledge graphs from scientific papers and evaluate them automatically.

Python 77.82% Jupyter Notebook 22.18%

scitext's Introduction

SciText

An automatic Text-to-Knowledge-Graph pipeline that was built to create knowledge graphs from scientific papers and evaluate them automatically.

This project was conducted as part of the Building and Mining Knowledge Graphs course at Maastricht University. The project report can be found here.

First use

On first use, the required models are downloaded, which may take up to 1h in total (around 10min for REBEL and 50min for ReFinEd).

Before first use, install the package requirements:

python -m venv kg-env
source kg-env/bin/activate
pip install -r requirements.txt

Use

To run this pipeline on a single paper:

python -m scitext.main --paper <path_to_pdf> [--evaluate]

This returns a knowledge graph in Turtle format.


To run this pipeline on a folder containing multiple PDF files:

python -m scitext.main --folder <path_to_folder> [--evaluate]

Using the optional --evaluate flag requires an OpenAI API key set as an environment variable, and returns an evaluation CSV file containing an evaluation generated by GPT-4 (however GPT-3.5 can be used as well) of each triple in the knowledge graph. Since the evaluation module both queries Wikidata and sends requests GPT-4, there may be connection interruptions or the GPT-4 API may be overloaded with other requests. In both cases, executing the evaluation module separately after waiting a few seconds can solve this issue. To do this, run the following command.

Running evaluation separately on a single knowledge graph:

python scitext/eval.py --ttl <path_to_turtle_kg>

Running evaluation separately on a folder containing multiple knowledge graphs:

python scitext/eval.py --folder <path_to_folder>

For example usages, inspect the help description of a command using -h.

Repo overview

data/rebel_dataset/rebel_vocab.csv contains the vocabulary used to map extracted relations to their rdfs:labels.

papers contains all papers used to evaluate the pipeline

results contains both the extracted knowledge graphs in Turtle format as well as the evaluation CSV files resulting from the automatic evaluation for each paper in the papers folder.

scitext contains the pipeline code, with each function's docstring explaining it's functionality.

mapping_dict.ipynb contains the code used to generate the rebel_vocab.csv, with the required REBEL dataset downloaded from within the rebel_dataset.zip at https://huggingface.co/datasets/Babelscape/rebel-dataset/tree/main .

requirements.txt for environment installation as explained above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.