Code Monkey home page Code Monkey logo

cxt2vec's Introduction

cxt2vec

About

This repository contains the code to vectorise contexts to use in models such as MTCue and LMCue.

Getting Started

Prerequisites

To run the software, you need to install the following packages (preferably in an Anaconda environment or similar):

  • sentence_transformers: pip install sentence-transformers

Installation

  1. Clone the repo
    git clone https://github.com/st-vincent1/cxt2vec.git
  2. Navigate to the repository
    cd cxt2vec
  3. Run the embedding code:
    python main.py --path [path to data] --dest_path [path to output embeddings] --suffixes [comma-separated suffixes of data to embed] --model [context model]

Usage

For a data folder which looks like this:

data
 |- en-pl
     |- train.en
     |- train.pl
     |- valid.en
     |- valid.pl
     |- test.en
     |- test.pl
     |- context
         |- valid.speaker_gender.cxt
         |- valid.formality.cxt
         |- valid.writer_names.cxt
         |- ...
         |- valid.0.en
         |- valid.1.en
         |- ...
         |- test.0.en
         |- ...
         |- train.speaker_gender.cxt
         |- train.plot.cxt
         |- ...
 |- en-de
 |- ...

The following code

python main.py --paths data/en-pl --dest_path data/en-pl/embeddings --suffixes cxt,pl --model minilm

Finds all contexts at data/en-pl/context which match the given suffixes in order (cxt, then pl), embeds all found contexts into a single file per split (train/valid/test) per suffix. A .json file is also produced which contains metadata necessary to later interpret the files in training code.

The result will therefore look like so:

data
 |- en-pl
     |- embeddings
         |- train.minilm.cxt.bin
         |- train.minilm.cxt.idx
         |- train.minilm.en.bin
         |- train.minilm.en.idx
         |- train.minilm.json
         |- valid.minilm.cxt.bin
         |- valid.minilm.cxt.idx
         |- valid.minilm.en.bin
         |- valid.minilm.en.idx
         |- valid.minilm.json
         |- test.minilm.cxt.bin
         |- test.minilm.cxt.idx
         |- test.minilm.en.bin
         |- test.minilm.en.idx
         |- test.minilm.json

Training models on this data

See examples in e.g. [github.com/st-vincent1/MTCue](MTCue repository) for how to use the embeddings to train models.

License

Distributed under the MIT License. See LICENSE.txt for more information.

cxt2vec's People

Contributors

st-vincent1 avatar

Watchers

 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.