SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1904.02343 · 2019

Density Matching for Bilingual Word Embedding

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/1904.02343.json · badge: /api/ran/1904.02343.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
violet-zct/DeMa-BWE canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
get_spearman_rho Ran
ran on a synthesized input
violet-zct/DeMa-BWE/evaluation/wordsim.py
code served (permissive licence) · get_code("29add1e2a2ffaad2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import io
import numpy as np
import tempfile

# Create a temporary word similarity file
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "word_sim.txt")

with io.open(temp_file, 'w', encoding='utf-8') as f:
    f.write("word1 word2 0.8\n")
    f.write("apple banana 0.6\n")
    f.write("cat dog 0.7\n")

# Create word2id dictionaries and embeddings
word2id1 = {
    "word1": 0,
    "word2": 1,
    "apple": 2,
    "banana": 3,
    "cat": 4,
    "dog": 5
}

word2id2 = {
    "word1": 0,
    "word2": 1,
    "apple": 2,
    "banana": 3,
    "cat": 4,
    "dog": 5
}

# Create embeddings with shape (6, 4) - 6 words, 4 dimensions
np.random.seed(0)
embeddings1 = np.random.randn(6, 4).astype(np.float32)
embeddings2 = np.random.randn(6, 4).astype(np.float32)

# Normalize embeddings for better similarity scores
embeddings1 = embeddings1 / (np.linalg.norm(embeddings1, axis=1, keepdims=True) + 1e-8)
embeddings2 = embeddings2 / (np.linalg.norm(embeddings2, axis=1, keepdims=True) + 1e-8)

ARGS = {
    "word2id1": word2id1,
    "embeddings1": embeddings1,
    "path": temp_file,
    "lower": True,
    "word2id2": word2id2,
    "embeddings2": embeddings2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_word_id Ran
ran on a synthesized input
violet-zct/DeMa-BWE/evaluation/wordsim.py
code served (permissive licence) · get_code("742da524e2a80e61")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

# Construct word2id dictionary - maps words to integer IDs
word2id = {
    "hello": 1,
    "world": 2,
    "Hello": 3,
    "World": 4,
    "Python": 5,
    "python": 6,
    "Title": 7,
}

ARGS = {
    "word": "hello",
    "word2id": word2id,
    "lower": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_word_pairs Ran
ran on a synthesized input
violet-zct/DeMa-BWE/evaluation/wordsim.py
code served (permissive licence) · get_code("ef171abe6042f8cc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import io
import tempfile

# Create a temporary file with word similarity data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt', encoding='utf-8')
temp_file.write("word1 word2 0.85\n")
temp_file.write("cat dog 0.72\n")
temp_file.write("king queen 0.90\n")
temp_file.close()

ARGS = {
    'path': temp_file.name,
    'lower': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_dictionary Ran
ran on a synthesized input
violet-zct/DeMa-BWE/evaluation/word_translation.py
code served (permissive licence) · get_code("ced1df321958d53f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family int, shape (3, 2) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import tempfile
import os

torch.manual_seed(0)

# Create temporary dictionary file with word pairs
temp_dir = tempfile.mkdtemp()
dict_path = os.path.join(temp_dir, "dictionary.txt")

# Write test dictionary file with lowercase word pairs
with open(dict_path, 'w', encoding='utf-8') as f:
    f.write("hello world\n")
    f.write("cat dog\n")
    f.write("apple fruit\n")

# Create word2id mappings for language 1
word2id1 = {
    "hello": 0,
    "cat": 1,
    "apple": 2,
}

# Create word2id mappings for language 2
word2id2 = {
    "world": 0,
    "dog": 1,
    "fruit": 2,
}

ARGS = {
    "path": dict_path,
    "word2id1": word2id1,
    "word2id2": word2id2,
    "reverse": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family int, shape (3, 2) — shape (3, 2) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_identical_char_dico Ran
ran on a synthesized input
violet-zct/DeMa-BWE/evaluation/word_translation.py
code served (permissive licence) · get_code("15228360a0667199")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 3, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from logging import getLogger

torch.manual_seed(0)
logger = getLogger()

# Create two word-to-id dictionaries with some overlapping words
word2id1 = {
    'hello': 0,
    'world': 1,
    'python': 2,
    'code': 3,
}

word2id2 = {
    'hello': 0,
    'world': 1,
    'test': 2,
    'data': 3,
}

ARGS = {
    'word2id1': word2id1,
    'word2id2': word2id2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
logsumexp Ran
ran; our contract draft was wrong, not the code
violet-zct/DeMa-BWE/modules/flows/mog_flow.py
code served (permissive licence) · get_code("e805f303d844a45d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Test case 1: logsumexp over all dimensions
x1 = torch.randn(2, 4)
dim1 = None

# Test case 2: logsumexp over specific dimension
x2 = torch.randn(2, 4)
dim2 = 1

# We'll use the first test case as the primary one
ARGS = {
    "x": x1,
    "dim": dim1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
select_subset Ran
ran on a synthesized input
violet-zct/DeMa-BWE/evaluation/export_embs.py
code served (permissive licence) · get_code("56fa2e05fd35f1df")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Analyzing the function:
# - word_list: iterable of words (strings)
# - max_vocab: integer controlling maximum vocabulary size
# - freqs: iterable of frequencies (numeric values)
# The function iterates through zip(word_list, freqs) and processes them

ARGS = {
    "word_list": ["the", "The", "cat", "Cat", "dog", "a", "A"],
    "max_vocab": 5,
    "freqs": [100, 95, 80, 75, 60, 50, 45]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_europarl_data Not yet run
unverified (harvested, no recorded run)
violet-zct/DeMa-BWE/evaluation/sent_translation.py
code served (permissive licence) · get_code("976c6045a425e913")
How it ran

no invocation recorded.

load_fasttext_model Not yet run
unverified (harvested, no recorded run)
violet-zct/DeMa-BWE/evaluation/export_embs.py
code served (permissive licence) · get_code("2b93faa3b4ec4872")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 2 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
load_fasttext_model 1 other paper
1 dated earlier
1711.00043 (2017-11)
Unsupervised Machine Translation Using Monolingual Corpora Only
logsumexp 1 other paper
1 later
2010.02014 (2020-10)
Self-Supervised Variational Auto-Encoders

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Recent approaches to cross-lingual word embedding have generally been based on linear transformations between the sets of embedding vectors in the two languages. In this paper, we propose an approach that instead expresses the two monolingual embedding spaces as probability densities defined by a Gaussian mixture model, and matches the two densities using a method called normalizing flow. The method requires no explicit supervision, and can be learned with only a seed dictionary of words that have identical strings. We argue that this formulation has several intuitively attractive properties, particularly with the respect to improving robustness and generalization to mappings between difficult language pairs or word pairs. On a benchmark data set of bilingual lexicon induction and cross-lingual word similarity, our approach can achieve competitive or superior performance compared to state-of-the-art published results, with particularly strong results being found on etymologically distant and/or morphologically rich languages.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("1904.02343")
get_code_for_paper("1904.02343")
have("1904.02343")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/1904.02343.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/1904.02343.svg)](https://syntology.ai/paper/1904.02343)

Connect an agent — have() is free.