Coder Social home page Coder Social logo

mohammedabdalqader / araelectra-questionanswering Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 10.22 MB

Fine-tuning / pre-training AraElectra on a specific domain for QA system.

Jupyter Notebook 59.85% Python 40.15%
arabert bert bert-fine-tuning pretraining

araelectra-questionanswering's Introduction

Pretraining/Finetuning AraElectra ๐Ÿ˜Š

In this repository, I show how to pre-train the AraElectra model on a specific domain and then how to use it for downstream tasks, such as question answering system. There are 2 notebooks:

1- Pretrain_AraElectra.ipynb

used to pretrain the AraElectra model on a user-defined dataset. In this notebook, the dataset is first prepared for training in the expected format and then the pretraining can be started. At the end of the training process, you can convert the Tensorflow checkpoint to a Pytorch model and store it in a suitable location namly: "araelectra-base-discriminator/" to be used later for fine-tuning this model on a question answering system.

The expexted dataset structure is a text-file in which each line represent a single sentence ends with '.' and between the paragraphs there is an empty line. An example for the dataset will be found in dataset/pretraining-dataset/iskan.txt.

2- Finetune-AraElectra-QA.ipynb

Through this notebook you can fine-tune the AraElectra model for a question-answer system. This notebook contains all the necessary processes from preparing the dataset to performing the inference. The dataset must be in this format:

QA_data.json
โ”œโ”€โ”€ "data"
โ”‚ย ย  โ””โ”€โ”€ [i]
โ”‚ย ย      โ”œโ”€โ”€ "paragraphs"
โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ [j]
โ”‚ย ย      โ”‚ย ย      โ”œโ”€โ”€ "context": "paragraph text"
โ”‚ย ย      โ”‚ย ย      โ””โ”€โ”€ "qas"
โ”‚ย ย      โ”‚ย ย          โ””โ”€โ”€ [k]
โ”‚ย ย      โ”‚ย ย              โ”œโ”€โ”€ "answers"
โ”‚ย ย      โ”‚ย ย              โ”‚ย ย  โ””โ”€โ”€ [l]
โ”‚ย ย      โ”‚ย ย              โ”‚ย ย      โ”œโ”€โ”€ "answer_start": N
โ”‚ย ย      โ”‚ย ย              โ”‚ย ย      โ””โ”€โ”€ "text": "answer"
โ”‚ย ย      โ”‚ย ย              โ”œโ”€โ”€ "id": "<uuid>"
โ”‚ย ย      โ”‚ย ย              โ””โ”€โ”€ "question": "paragraph question?"
โ”‚ย ย      โ””โ”€โ”€ "title": "document id"
โ””โ”€โ”€ "version": 1.1

As an annotation tool for the Question Answering System I recommend Haystack from here: https://annotate.deepset.ai/

Getting Started

Clone das Repo

git clone https://github.com/Mohammedabdalqader/AraElectra-QuestionAnswering.git
cd AraElectra-QuestionAnswering

Create Conda Environment (Recommended)

conda create -n [env name] python=3.7
conda activate [env name]
pip install -r requirements.txt

Install python Requirements without Conda Environment (Not Recommended)

pip3 install -requirements.txt

Install pre-commit Hooks

pre-commit install

Install the Git LFS client:

Now you need to run this line:

git lfs install

Download pretrained AraElectra Model which trained on SQuAD & arcd datasets

You can download the model from here: https://drive.google.com/file/d/1-l2-rNnui7UulEEdUdG-POSbKyNb6DHk/view?usp=sharing The model must be saved in araelectra-QA-model/

Run the Flask app

gunicorn -k gevent -b 0.0.0.0:8080 app.api.routes:app -t 300

Use Postman to ask questions and upload new dokuments

References

araelectra-questionanswering's People

Contributors

mohammedabdalqader avatar

Watchers

Ameen Altajer 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.