Skip to content

ALLAN-DIP/diplomacy_translation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

diplomacy_translation

To get the app working, you’ll need an API key. You can get one by signing up for an account. Note that OpenAI has a $18 free trial usage limit.

If you need to see how it works and play with it, you can check out the demo. The following content is a Python API setup to use the model.

Installation

git clone [email protected]:SiddarGu/diplomacy_translation.git
cd diplomacy_translation
pip install -r requirements.txt
pip install -e .

Additional Setup

Create a .env file in the root directory of the project and add your API key to it:

OPENAI_API_KEY=YOUR_API_KEY

Functions

def toDAIDE(eng_msg: str, temperature=0, top_p=1, frequency_penalty=0, presence_penalty=0) -> str:
def toEnglish(daide_msg: str, temperature=0, top_p=1, frequency_penalty=0, presence_penalty=0) -> str:

Usage

Examples without changing hyperparameters

from translation.translation import toDAIDE, toEnglish

daide_translation = toDAIDE("Can your army in Warsaw support my army in Ukraine?")
english_translation = toEnglish("PRP ((RUS FLT ION) CVY (TUR AMY TUN) CTO TRI)")

Each function also have some optional parameters, which can be used to change the hyperparameters of the translation.

  • temperature (float): defaults to 1. Refers to what sampling temperature to use.
  • top_p (float): defaults to 1. An alternative to sampling with temperature, called nucleus sampling.
  • frequency_penalty (float between -2.0 and 2.0)
  • presence_penalty=0 (float between -2.0 and 2.0)

See more info about these parameters here

Advanced usage

daide_translation = toDAIDE("Can your army in Warsaw support my army in Ukraine?", temperature=0.5)

Current limitations

  • The dataset is too small. One annotation file from here has < 600 full DAIDEs. There is only four other files. In addition, most full DAIDEs annotated does not pass the current daidepp parser.
  • The prompt is not always working as intended. Sometimes the model does not generate translations at all. Sometimes the model simply repeats (part of) the prompt. Sometimes the model generates a translation that is not related to the prompt at all. The details of the problems generating DAIDE from English can be found in comments in utils.py.
  • Third, using data from human games for generating DAIDE -> English translation is not ideal. The English reference does not always correspond to the DAIDE order. Discrepancy between translation and the reference is expected.

Future work

  • Prompt refinement
  • Evaluation of the model
  • Compare traditional NLP models with GPT-3

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published