Code Monkey home page Code Monkey logo

akbc-lab08's Introduction

Lab 08: Knowledge Base Construction from Language Models

This repository contains the dataset and scripts for Lab 08 of AKBC course

Download the dataset and scripts

$ git clone https://github.com/snehasinghania/akbc-lab08.git
cd akbc-lab08

Usage

  1. Install the required dependencies to run the baseline and evaluate scripts.
pip install -r requirements.txt
  1. To run the baseline script:
python baseline.py [-h] [--model_type MODEL_TYPE] [--input_dir INPUT_DIR] 
                  [--prompt_output_dir PROMPT_OUTPUT_DIR] 
                  [--baseline_output_dir BASELINE_OUTPUT_DIR]

Probe a Language Model and Run the Baseline Method on Prompt Outputs

optional arguments:
  -h, --help            show this help message and exit
  --model_type MODEL_TYPE
                        HuggingFace model name
  --input_dir INPUT_DIR
                        input directory containing the subject-entities for each relation to probe the language model
  --prompt_output_dir PROMPT_OUTPUT_DIR
                        output directory to store the prompt output
  --baseline_output_dir BASELINE_OUTPUT_DIR
                        output directory to store the baseline output                        
  1. To run the evaluation script:
python evaluate.py [-h] [--input_dir INPUT_DIR] [--ground_truth_dir GROUND_TRUTH_DIR] 
                    [--results_dir RESULTS_DIR]

optional arguments:
  -h, --help            show this help message and exit
  --input_dir INPUT_DIR
                        input directory containing the baseline or your method output
  --ground_truth_dir GROUND_TRUTH_DIR
                        ground truth directory containing true object-entities for the subject-entities for which the LM was probed and then baseline or your
                        method was applied
  --results_dir RESULTS_DIR
                        results directory for storing the F1 scores for baseline or your method

The baseline method achieves the following scores after running the evaluate.py script:

Relation Precision Recall F1-score
CountryBordersWithCountry 0.02 0.007 0.01
RiverBasinsCountry 0.28 0.192 0.215
PersonLanguage 0.12 0.0817 0.0913
PersonProfession 0.0 0.0 0.0
PersonInstrument 0.0 0.0 0.0
macro average 0.084 0.056 0.063
  1. Implement your idea in the your_solution function in the solution.py file.

akbc-lab08's People

Contributors

snehasinghania avatar

Watchers

James Cloos avatar  avatar

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.