Code Monkey home page Code Monkey logo

lsar's Introduction

LSAR: Low-rank Subspaces for language-Agnostic Representations

This repository contains code for our EMNLP 2022 paper:

Discovering Low-rank Subspaces for Language-agnostic Multilingual Representations

Zhihui Xie, Handong Zhao, Tong Yu, Shuai Li

Shanghai Jiao Tong University, Adobe Research

EMNLP 2022

In this work, we propose LSAR (Low-rank Subspaces for language-Agnostic Representations), a simple but effective unsupervised method to project away language-specific factors from a multilingual embedding space. Specifically, LSAR is finetuning-free and keeps the original embeddings space intact. We systematically evaluate LSAR on various tasks including the challenging language-agnostic QA retrieval task. Empirical results show that applying LSAR consistently leads to improvements over commonly used ML-LMs. Here is the poster.

Prerequisites

  • Python 3.7+
  • Nvidia GPU w/ CUDA
  • Anaconda

Getting Started

Installation

In order to run experiments, it is also required to install several dependencies using:

bash scripts/install_tools.sh

Note that to run the experiments of LaBSE, a higher PyTorch version compatible with transformers and sentence-transformers is required. We create another Conda environment with Python3.9 and torch==1.12.1, transformers==4.5.1, sentence-transformers==1.2.1.

Preparing the Source Corpora

Run the following command to download the source monolingual corpora (OSCAR and Wikipedia) that are used in the paper for extracting low-rank subspaces:

bash scripts/$source/download_$source.sh

Preparing the Datasets

Run the following command to download the datasets (Tatoeba, LAReQA, and Amazon Reviews) used in the paper:

bash scripts/$task/download_$task.sh

Reproducing the Results

To reproduce our main results, make sure the source corpora and datasets are already downloaded and then:

  • Extract multilingual embeddings by running

    bash scripts/$source/extract_$source.sh
    bash scripts/$task/extract_$task.sh
    
  • Evaluate cross-lingual performance of language-agnostic embeddings by running

    bash scripts/$task/evaluate_$task.sh
    

Acknowledgements

This repository is built on top of xtreme and LIR.

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.