ความคล้ายคลึงกันข้ามภาษาและเครื่องมือค้นหาความหมายที่มีตัวเข้ารหัสประโยคสากลหลายภาษา

ดูบน TensorFlow.org ทำงานใน Google Colab ดูบน GitHub ดาวน์โหลดโน๊ตบุ๊ค ดูรุ่น TF Hub

สมุดบันทึกนี้แสดงวิธีเข้าถึงโมดูล Multilingual Universal Sentence Encoder และใช้สำหรับความคล้ายคลึงของประโยคในหลายภาษา โมดูลนี้จะเป็นส่วนขยายของ เดิมโมดูลยูนิเวอร์แซ Encoder

สมุดบันทึกแบ่งออกเป็น:

  • ส่วนแรกแสดงภาพประโยคระหว่างคู่ภาษา นี้เป็นแบบฝึกหัดวิชาการมากขึ้น
  • ในส่วนที่สอง เราจะแสดงวิธีสร้างเครื่องมือค้นหาเชิงความหมายจากตัวอย่างคลังข้อมูล Wikipedia ในหลายภาษา

การอ้างอิง

เอกสารการวิจัยที่ใช้แบบจำลองที่สำรวจใน colab นี้ควรกล่าวถึง:

ตัวเข้ารหัสประโยคสากลหลายภาษาสำหรับการดึงความหมาย

Yinfei Yang, Daniel Cer, Amin Ahmad, Mandy Guo, Jax Law, Noah Constant, Gustavo Hernandez Abrego, Steve Yuan, Chris Tar, Yun-Hsuan Sung, Brian Strope และ Ray Kurzweil 2019. พิมพ์ล่วงหน้า arXiv arXiv:1907.04307

ติดตั้ง

ส่วนนี้ตั้งค่าสภาพแวดล้อมสำหรับการเข้าถึง Multilingual Universal Sentence Encoder Module และยังเตรียมชุดประโยคภาษาอังกฤษและคำแปลอีกด้วย ในส่วนต่อไปโมดูลพูดได้หลายภาษาจะใช้ในการคำนวณความคล้ายคลึงกันในหลายภาษา

ตั้งค่าสภาพแวดล้อม

%%capture
# Install the latest Tensorflow version.
!pip install tensorflow_text
!pip install bokeh
!pip install simpleneighbors[annoy]
!pip install tqdm

ตั้งค่าการนำเข้าและฟังก์ชันทั่วไป

import bokeh
import bokeh.models
import bokeh.plotting
import numpy as np
import os
import pandas as pd
import tensorflow.compat.v2 as tf
import tensorflow_hub as hub
from tensorflow_text import SentencepieceTokenizer
import sklearn.metrics.pairwise

from simpleneighbors import SimpleNeighbors
from tqdm import tqdm
from tqdm import trange

def visualize_similarity(embeddings_1, embeddings_2, labels_1, labels_2,
                         plot_title,
                         plot_width=1200, plot_height=600,
                         xaxis_font_size='12pt', yaxis_font_size='12pt'):

  assert len(embeddings_1) == len(labels_1)
  assert len(embeddings_2) == len(labels_2)

  # arccos based text similarity (Yang et al. 2019; Cer et al. 2019)
  sim = 1 - np.arccos(
      sklearn.metrics.pairwise.cosine_similarity(embeddings_1,
                                                 embeddings_2))/np.pi

  embeddings_1_col, embeddings_2_col, sim_col = [], [], []
  for i in range(len(embeddings_1)):
    for j in range(len(embeddings_2)):
      embeddings_1_col.append(labels_1[i])
      embeddings_2_col.append(labels_2[j])
      sim_col.append(sim[i][j])
  df = pd.DataFrame(zip(embeddings_1_col, embeddings_2_col, sim_col),
                    columns=['embeddings_1', 'embeddings_2', 'sim'])

  mapper = bokeh.models.LinearColorMapper(
      palette=[*reversed(bokeh.palettes.YlOrRd[9])], low=df.sim.min(),
      high=df.sim.max())

  p = bokeh.plotting.figure(title=plot_title, x_range=labels_1,
                            x_axis_location="above",
                            y_range=[*reversed(labels_2)],
                            plot_width=plot_width, plot_height=plot_height,
                            tools="save",toolbar_location='below', tooltips=[
                                ('pair', '@embeddings_1 ||| @embeddings_2'),
                                ('sim', '@sim')])
  p.rect(x="embeddings_1", y="embeddings_2", width=1, height=1, source=df,
         fill_color={'field': 'sim', 'transform': mapper}, line_color=None)

  p.title.text_font_size = '12pt'
  p.axis.axis_line_color = None
  p.axis.major_tick_line_color = None
  p.axis.major_label_standoff = 16
  p.xaxis.major_label_text_font_size = xaxis_font_size
  p.xaxis.major_label_orientation = 0.25 * np.pi
  p.yaxis.major_label_text_font_size = yaxis_font_size
  p.min_border_right = 300

  bokeh.io.output_notebook()
  bokeh.io.show(p)

นี่คือรหัสต้นแบบเพิ่มเติมที่เรานำเข้าโมเดล ML ที่ผ่านการฝึกอบรมล่วงหน้า ซึ่งเราจะใช้ในการเข้ารหัสข้อความตลอดทั้งสมุดบันทึกนี้

# The 16-language multilingual module is the default but feel free
# to pick others from the list and compare the results.
module_url = 'https://tfhub.dev/google/universal-sentence-encoder-multilingual/3'

model = hub.load(module_url)

def embed_text(input):
  return model(input)

เห็นภาพความคล้ายคลึงของข้อความระหว่างภาษา

ด้วยการฝังประโยคที่มีอยู่ตอนนี้ เราจึงสามารถเห็นภาพความคล้ายคลึงกันของความหมายในภาษาต่างๆ

การฝังข้อความคอมพิวเตอร์

ขั้นแรกเราจะกำหนดชุดประโยคที่แปลเป็นภาษาต่างๆ ควบคู่กันไป จากนั้น เราคำนวณการฝังไว้ล่วงหน้าสำหรับประโยคทั้งหมดของเรา

# Some texts of different lengths in different languages.
arabic_sentences = ['كلب', 'الجراء لطيفة.', 'أستمتع بالمشي لمسافات طويلة على طول الشاطئ مع كلبي.']
chinese_sentences = ['狗', '小狗很好。', '我喜欢和我的狗一起沿着海滩散步。']
english_sentences = ['dog', 'Puppies are nice.', 'I enjoy taking long walks along the beach with my dog.']
french_sentences = ['chien', 'Les chiots sont gentils.', 'J\'aime faire de longues promenades sur la plage avec mon chien.']
german_sentences = ['Hund', 'Welpen sind nett.', 'Ich genieße lange Spaziergänge am Strand entlang mit meinem Hund.']
italian_sentences = ['cane', 'I cuccioli sono carini.', 'Mi piace fare lunghe passeggiate lungo la spiaggia con il mio cane.']
japanese_sentences = ['犬', '子犬はいいです', '私は犬と一緒にビーチを散歩するのが好きです']
korean_sentences = ['개', '강아지가 좋다.', '나는 나의 개와 해변을 따라 길게 산책하는 것을 즐긴다.']
russian_sentences = ['собака', 'Милые щенки.', 'Мне нравится подолгу гулять по пляжу со своей собакой.']
spanish_sentences = ['perro', 'Los cachorros son agradables.', 'Disfruto de dar largos paseos por la playa con mi perro.']

# Multilingual example
multilingual_example = ["Willkommen zu einfachen, aber", "verrassend krachtige", "multilingüe", "compréhension du langage naturel", "модели.", "大家是什么意思" , "보다 중요한", ".اللغة التي يتحدثونها"]
multilingual_example_in_en =  ["Welcome to simple yet", "surprisingly powerful", "multilingual", "natural language understanding", "models.", "What people mean", "matters more than", "the language they speak."]
# Compute embeddings.
ar_result = embed_text(arabic_sentences)
en_result = embed_text(english_sentences)
es_result = embed_text(spanish_sentences)
de_result = embed_text(german_sentences)
fr_result = embed_text(french_sentences)
it_result = embed_text(italian_sentences)
ja_result = embed_text(japanese_sentences)
ko_result = embed_text(korean_sentences)
ru_result = embed_text(russian_sentences)
zh_result = embed_text(chinese_sentences)

multilingual_result = embed_text(multilingual_example)
multilingual_in_en_result = embed_text(multilingual_example_in_en)

การแสดงภาพความคล้ายคลึงกัน

ด้วยการฝังข้อความ เราสามารถนำ dot-product ของพวกเขามาแสดงให้เห็นภาพว่าประโยคที่คล้ายคลึงกันระหว่างภาษาต่างๆ เป็นอย่างไร สีเข้มขึ้นแสดงว่าการฝังมีความหมายคล้ายกัน

ความคล้ายคลึงกันหลายภาษา

visualize_similarity(multilingual_in_en_result, multilingual_result,
                     multilingual_example_in_en, multilingual_example,  "Multilingual Universal Sentence Encoder for Semantic Retrieval (Yang et al., 2019)")

ความคล้ายคลึงกันระหว่างภาษาอังกฤษกับภาษาอาหรับ

visualize_similarity(en_result, ar_result, english_sentences, arabic_sentences, 'English-Arabic Similarity')

ความคล้ายคลึงกันระหว่างภาษาอังกฤษกับรัสเซีย

visualize_similarity(en_result, ru_result, english_sentences, russian_sentences, 'English-Russian Similarity')

ความคล้ายคลึงกันระหว่างภาษาอังกฤษกับสเปน

visualize_similarity(en_result, es_result, english_sentences, spanish_sentences, 'English-Spanish Similarity')

ความคล้ายคลึงกันระหว่างภาษาอังกฤษกับอิตาลี

visualize_similarity(en_result, it_result, english_sentences, italian_sentences, 'English-Italian Similarity')

ความคล้ายคลึงกันของอิตาลี-สเปน

visualize_similarity(it_result, es_result, italian_sentences, spanish_sentences, 'Italian-Spanish Similarity')

ความคล้ายคลึงกันระหว่างภาษาอังกฤษกับจีน

visualize_similarity(en_result, zh_result, english_sentences, chinese_sentences, 'English-Chinese Similarity')

ความคล้ายคลึงกันระหว่างภาษาอังกฤษกับเกาหลี

visualize_similarity(en_result, ko_result, english_sentences, korean_sentences, 'English-Korean Similarity')

ความคล้ายคลึงกันระหว่างจีนกับเกาหลี

visualize_similarity(zh_result, ko_result, chinese_sentences, korean_sentences, 'Chinese-Korean Similarity')

และอื่น ๆ...

ตัวอย่างข้างต้นสามารถขยายไปยังคู่ภาษาใด ๆ จากอังกฤษ, อาหรับ, จีน, ดัตช์, ฝรั่งเศส, เยอรมัน, อิตาลี, ญี่ปุ่น, เกาหลี, โปแลนด์, โปรตุเกส, รัสเซีย, สเปน, ไทยและตุรกี มีความสุขในการเข้ารหัส!

การสร้างเครื่องมือค้นหาความคล้ายคลึงกันในหลายภาษา

ในขณะที่ในตัวอย่างก่อนหน้านี้ เราเห็นภาพประโยคจำนวนหนึ่ง ในส่วนนี้ เราจะสร้างดัชนีการค้นหาเชิงความหมายประมาณ 200,000 ประโยคจาก Wikipedia Corpus ประมาณครึ่งหนึ่งจะเป็นภาษาอังกฤษและอีกครึ่งหนึ่งเป็นภาษาสเปนเพื่อแสดงความสามารถหลายภาษาของ Universal Sentence Encoder

ดาวน์โหลดข้อมูลเพื่อจัดทำดัชนี

ครั้งแรกที่เราจะดาวน์โหลดประโยคข่าวในภาษาทวีคูณจาก อรรถกถาข่าวคอร์ปัส [1] แนวทางนี้ควรทำงานเพื่อสร้างดัชนีภาษาที่รองรับที่เหลือโดยไม่สูญเสียความทั่วไป

เพื่อเร่งความเร็วการสาธิต เราจำกัดไว้ที่ 1,000 ประโยคต่อภาษา

corpus_metadata = [
    ('ar', 'ar-en.txt.zip', 'News-Commentary.ar-en.ar', 'Arabic'),
    ('zh', 'en-zh.txt.zip', 'News-Commentary.en-zh.zh', 'Chinese'),
    ('en', 'en-es.txt.zip', 'News-Commentary.en-es.en', 'English'),
    ('ru', 'en-ru.txt.zip', 'News-Commentary.en-ru.ru', 'Russian'),
    ('es', 'en-es.txt.zip', 'News-Commentary.en-es.es', 'Spanish'),
]

language_to_sentences = {}
language_to_news_path = {}
for language_code, zip_file, news_file, language_name in corpus_metadata:
  zip_path = tf.keras.utils.get_file(
      fname=zip_file,
      origin='http://opus.nlpl.eu/download.php?f=News-Commentary/v11/moses/' + zip_file,
      extract=True)
  news_path = os.path.join(os.path.dirname(zip_path), news_file)
  language_to_sentences[language_code] = pd.read_csv(news_path, sep='\t', header=None)[0][:1000]
  language_to_news_path[language_code] = news_path

  print('{:,} {} sentences'.format(len(language_to_sentences[language_code]), language_name))
Downloading data from http://opus.nlpl.eu/download.php?f=News-Commentary/v11/moses/ar-en.txt.zip
24715264/24714354 [==============================] - 2s 0us/step
1,000 Arabic sentences
Downloading data from http://opus.nlpl.eu/download.php?f=News-Commentary/v11/moses/en-zh.txt.zip
18104320/18101984 [==============================] - 2s 0us/step
1,000 Chinese sentences
Downloading data from http://opus.nlpl.eu/download.php?f=News-Commentary/v11/moses/en-es.txt.zip
28106752/28106064 [==============================] - 2s 0us/step
1,000 English sentences
Downloading data from http://opus.nlpl.eu/download.php?f=News-Commentary/v11/moses/en-ru.txt.zip
24854528/24849511 [==============================] - 2s 0us/step
1,000 Russian sentences
1,000 Spanish sentences

การใช้แบบจำลองที่ได้รับการฝึกอบรมล่วงหน้าเพื่อแปลงประโยคเป็นเวกเตอร์

เราคำนวณ embeddings ใน batches เพื่อให้พวกเขาพอดีในแรม GPU ของ

# Takes about 3 minutes

batch_size = 2048
language_to_embeddings = {}
for language_code, zip_file, news_file, language_name in corpus_metadata:
  print('\nComputing {} embeddings'.format(language_name))
  with tqdm(total=len(language_to_sentences[language_code])) as pbar:
    for batch in pd.read_csv(language_to_news_path[language_code], sep='\t',header=None, chunksize=batch_size):
      language_to_embeddings.setdefault(language_code, []).extend(embed_text(batch[0]))
      pbar.update(len(batch))
0%|          | 0/1000 [00:00<?, ?it/s]
Computing Arabic embeddings
83178it [00:30, 2768.60it/s]
  0%|          | 0/1000 [00:00<?, ?it/s]
Computing Chinese embeddings
69206it [00:18, 3664.60it/s]
  0%|          | 0/1000 [00:00<?, ?it/s]
Computing English embeddings
238853it [00:37, 6319.00it/s]
  0%|          | 0/1000 [00:00<?, ?it/s]
Computing Russian embeddings
190092it [00:34, 5589.16it/s]
  0%|          | 0/1000 [00:00<?, ?it/s]
Computing Spanish embeddings
238819it [00:41, 5754.02it/s]

การสร้างดัชนีของเวกเตอร์ความหมาย

เราใช้ SimpleNeighbors ห้องสมุด --- ซึ่งเป็นเสื้อคลุมสำหรับที่ รำคาญ ห้องสมุด --- ได้อย่างมีประสิทธิภาพขึ้นไปดูผลที่ได้จากคลัง

%%time

# Takes about 8 minutes

num_index_trees = 40
language_name_to_index = {}
embedding_dimensions = len(list(language_to_embeddings.values())[0][0])
for language_code, zip_file, news_file, language_name in corpus_metadata:
  print('\nAdding {} embeddings to index'.format(language_name))
  index = SimpleNeighbors(embedding_dimensions, metric='dot')

  for i in trange(len(language_to_sentences[language_code])):
    index.add_one(language_to_sentences[language_code][i], language_to_embeddings[language_code][i])

  print('Building {} index with {} trees...'.format(language_name, num_index_trees))
  index.build(n=num_index_trees)
  language_name_to_index[language_name] = index
0%|          | 1/1000 [00:00<02:21,  7.04it/s]
Adding Arabic embeddings to index
100%|██████████| 1000/1000 [02:06<00:00,  7.90it/s]
  0%|          | 1/1000 [00:00<01:53,  8.84it/s]
Building Arabic index with 40 trees...

Adding Chinese embeddings to index
100%|██████████| 1000/1000 [02:05<00:00,  7.99it/s]
  0%|          | 1/1000 [00:00<01:59,  8.39it/s]
Building Chinese index with 40 trees...

Adding English embeddings to index
100%|██████████| 1000/1000 [02:07<00:00,  7.86it/s]
  0%|          | 1/1000 [00:00<02:17,  7.26it/s]
Building English index with 40 trees...

Adding Russian embeddings to index
100%|██████████| 1000/1000 [02:06<00:00,  7.91it/s]
  0%|          | 1/1000 [00:00<02:03,  8.06it/s]
Building Russian index with 40 trees...

Adding Spanish embeddings to index
100%|██████████| 1000/1000 [02:07<00:00,  7.84it/s]
Building Spanish index with 40 trees...
CPU times: user 11min 21s, sys: 2min 14s, total: 13min 35s
Wall time: 10min 33s

%%time

# Takes about 13 minutes

num_index_trees = 60
print('Computing mixed-language index')
combined_index = SimpleNeighbors(embedding_dimensions, metric='dot')
for language_code, zip_file, news_file, language_name in corpus_metadata:
  print('Adding {} embeddings to mixed-language index'.format(language_name))
  for i in trange(len(language_to_sentences[language_code])):
    annotated_sentence = '({}) {}'.format(language_name, language_to_sentences[language_code][i])
    combined_index.add_one(annotated_sentence, language_to_embeddings[language_code][i])

print('Building mixed-language index with {} trees...'.format(num_index_trees))
combined_index.build(n=num_index_trees)
0%|          | 1/1000 [00:00<02:00,  8.29it/s]
Computing mixed-language index
Adding Arabic embeddings to mixed-language index
100%|██████████| 1000/1000 [02:06<00:00,  7.92it/s]
  0%|          | 1/1000 [00:00<02:24,  6.89it/s]
Adding Chinese embeddings to mixed-language index
100%|██████████| 1000/1000 [02:05<00:00,  7.95it/s]
  0%|          | 1/1000 [00:00<02:05,  7.98it/s]
Adding English embeddings to mixed-language index
100%|██████████| 1000/1000 [02:06<00:00,  7.88it/s]
  0%|          | 1/1000 [00:00<02:18,  7.20it/s]
Adding Russian embeddings to mixed-language index
100%|██████████| 1000/1000 [02:04<00:00,  8.03it/s]
  0%|          | 1/1000 [00:00<02:17,  7.28it/s]
Adding Spanish embeddings to mixed-language index
100%|██████████| 1000/1000 [02:06<00:00,  7.90it/s]
Building mixed-language index with 60 trees...
CPU times: user 11min 18s, sys: 2min 13s, total: 13min 32s
Wall time: 10min 30s

ตรวจสอบว่าเครื่องมือค้นหาความคล้ายคลึงความหมายทำงาน

ในส่วนนี้เราจะสาธิต:

  1. ความสามารถในการค้นหาความหมาย: ดึงประโยคจากคลังข้อมูลที่มีความหมายคล้ายกับข้อความค้นหาที่กำหนด
  2. ความสามารถหลายภาษา: ทำได้ในหลายภาษาเมื่อค้นหาภาษาและดัชนีตรงกัน
  3. ความสามารถข้ามภาษา: ออกคำสั่งในภาษาที่แตกต่างจากคลังข้อมูลที่ทำดัชนี
  4. คลังข้อมูลภาษาผสม: ทั้งหมดข้างต้นในดัชนีเดียวที่มีรายการจากทุกภาษา

ความสามารถข้ามภาษาค้นหาความหมาย

ในส่วนนี้ เราจะแสดงวิธีการดึงประโยคที่เกี่ยวข้องกับชุดตัวอย่างประโยคภาษาอังกฤษ สิ่งที่ต้องลอง:

  • ลองประโยคตัวอย่างที่แตกต่างกันสองสามประโยค
  • ลองเปลี่ยนจำนวนผลลัพธ์ที่ส่งคืน (ส่งคืนตามลำดับความคล้ายคลึงกัน)
  • ลองความสามารถในการข้ามภาษาโดยการกลับผลลัพธ์ในภาษาที่แตกต่างกัน (อาจต้องการใช้ Google Translate ผลการบางอย่างเพื่อให้ภาษาพื้นเมืองของคุณสำหรับการตรวจสอบสติ)

English sentences similar to: "The stock market fell four points."
['Nobel laureate Amartya Sen attributed the European crisis to four failures – political, economic, social, and intellectual.',
 'Just last December, fellow economists Martin Feldstein and Nouriel Roubini each penned op-eds bravely questioning bullish market sentiment, sensibly pointing out gold’s risks.',
 'His ratings have dipped below 50% for the first time.',
 'As a result, markets were deregulated, making it easier to trade assets that were perceived to be safe, but were in fact not.',
 'Consider the advanced economies.',
 'But the agreement has three major flaws.',
 'This “predetermined equilibrium” thinking – reflected in the view that markets always self-correct – led to policy paralysis until the Great Depression, when John Maynard Keynes’s argument for government intervention to address unemployment and output gaps gained traction.',
 'Officials underestimated tail risks.',
 'Consider a couple of notorious examples.',
 'Stalin was content to settle for an empire in Eastern Europe.']

ความสามารถผสมคอร์ปัส

ตอนนี้เราจะออกแบบสอบถามเป็นภาษาอังกฤษ แต่ผลลัพธ์จะมาจากภาษาใด ๆ ที่จัดทำดัชนีไว้

English sentences similar to: "The stock market fell four points."
['Nobel laureate Amartya Sen attributed the European crisis to four failures – political, economic, social, and intellectual.',
 'It was part of the 1945 consensus.',
 'The end of the East-West ideological divide and the end of absolute faith in markets are historical turning points.',
 'Just last December, fellow economists Martin Feldstein and Nouriel Roubini each penned op-eds bravely questioning bullish market sentiment, sensibly pointing out gold’s risks.',
 'His ratings have dipped below 50% for the first time.',
 'As a result, markets were deregulated, making it easier to trade assets that were perceived to be safe, but were in fact not.',
 'Consider the advanced economies.',
 'Since their articles appeared, the price of gold has moved up still further.',
 'But the agreement has three major flaws.',
 'Gold prices even hit a record-high $1,300 recently.',
 'This “predetermined equilibrium” thinking – reflected in the view that markets always self-correct – led to policy paralysis until the Great Depression, when John Maynard Keynes’s argument for government intervention to address unemployment and output gaps gained traction.',
 'What Failed in 2008?',
 'Officials underestimated tail risks.',
 'Consider a couple of notorious examples.',
 'One of these species, orange roughy, has been caught commercially for only around a quarter-century, but already is being fished to the point of collapse.',
 'Meanwhile, policymakers were lulled into complacency by the widespread acceptance of economic theories such as the “efficient-market hypothesis,” which assumes that investors act rationally and use all available information when making their decisions.',
 'Stalin was content to settle for an empire in Eastern Europe.',
 'Intelligence assets have been redirected.',
 'A new wave of what the economist Joseph Schumpeter famously called “creative destruction” is under way: even as central banks struggle to maintain stability by flooding markets with liquidity, credit to business and households is shrinking.',
 'It all came about in a number of ways.',
 'The UN, like the dream of European unity, was also part of the 1945 consensus.',
 'The End of 1945',
 'The Global Economy’s New Path',
 'But this scenario failed to materialize.',
 'Gold prices are extremely sensitive to global interest-rate movements.',
 'Fukushima has presented the world with a far-reaching, fundamental choice.',
 'It was Japan, the high-tech country par excellence (not the latter-day Soviet Union) that proved unable to take adequate precautions to avert disaster in four reactor blocks.',
 'Some European academics tried to argue that there was no need for US-like fiscal transfers, because any desired degree of risk sharing can, in theory, be achieved through financial markets.',
 '$10,000 Gold?',
 'One answer, of course, is a complete collapse of the US dollar.',
 '1929 or 1989?',
 'The goods we made were what economists call “rival" and “excludible" commodities.',
 'This dream quickly faded when the Cold War divided the world into two hostile blocs. But in some ways the 1945 consensus, in the West, was strengthened by Cold War politics.',
 'The first flaw is that the spending reductions are badly timed: coming as they do when the US economy is weak, they risk triggering another recession.',
 'One successful gold investor recently explained to me that stock prices languished for a more than a decade before the Dow Jones index crossed the 1,000 mark in the early 1980’s.',
 'Eichengreen traces our tepid response to the crisis to the triumph of monetarist economists, the disciples of Milton Friedman, over their Keynesian and Minskyite peers – at least when it comes to interpretations of the causes and consequences of the Great Depression.',
 "However, America's unilateral options are limited.",
 'Once it was dark, a screen was set up and Mark showed home videos from space.',
 'These aspirations were often voiced in the United Nations, founded in 1945.',
 'Then I got distracted for about 40 years.']

ลองสอบถามของคุณเอง:

English sentences similar to: "The stock market fell four points."
['(Chinese) 新兴市场的号角',
 '(English) It was part of the 1945 consensus.',
 '(Russian) Брюссель. Цунами, пронёсшееся по финансовым рынкам, является глобальной катастрофой.',
 '(Arabic) هناك أربعة شروط مسبقة لتحقيق النجاح الأوروبي في أفغانستان:',
 '(Spanish) Su índice de popularidad ha caído por primera vez por debajo del 50 por ciento.',
 '(English) His ratings have dipped below 50% for the first time.',
 '(Russian) Впервые его рейтинг опустился ниже 50%.',
 '(English) As a result, markets were deregulated, making it easier to trade assets that were perceived to be safe, but were in fact not.',
 '(Arabic) وكانت التطورات التي شهدتها سوق العمل أكثر تشجيعا، فهي على النقيض من أسواق الأصول تعكس النتائج وليس التوقعات. وهنا أيضاً كانت الأخبار طيبة. فقد أصبحت سوق العمل أكثر إحكاما، حيث ظلت البطالة عند مستوى 3.5% وكانت نسبة الوظائف إلى الطلبات المقدمة فوق مستوى التعادل.',
 '(Russian) Это было частью консенсуса 1945 года.',
 '(English) Consider the advanced economies.',
 '(English) Since their articles appeared, the price of gold has moved up still further.',
 '(Russian) Тогда они не только смогут накормить свои семьи, но и начать получать рыночную прибыль и откладывать деньги на будущее.',
 '(English) Gold prices even hit a record-high $1,300 recently.',
 '(Chinese) 另一种金融危机',
 '(Russian) Европейская мечта находится в кризисе.',
 '(English) What Failed in 2008?',
 '(Spanish) Pero el acuerdo alcanzado tiene tres grandes defectos.',
 '(English) Officials underestimated tail risks.',
 '(English) Consider a couple of notorious examples.',
 '(Spanish) Los mercados financieros pueden ser frágiles y ofrecen muy poca capacidad de compartir los riesgos relacionados con el ingreso de los trabajadores, que constituye la mayor parte de la renta de cualquier economía avanzada.',
 '(Chinese) 2008年败在何处?',
 '(Spanish) Consideremos las economías avanzadas.',
 '(Spanish) Los bienes producidos se caracterizaron por ser, como señalaron algunos economistas, mercancías “rivales” y “excluyentes”.',
 '(Arabic) إغلاق الفجوة الاستراتيجية في أوروبا',
 '(English) Stalin was content to settle for an empire in Eastern Europe.',
 '(English) Intelligence assets have been redirected.',
 '(Spanish) Hoy, envalentonados por la apreciación continua, algunos están sugiriendo que el oro podría llegar incluso a superar esa cifra.',
 '(Russian) Цены на золото чрезвычайно чувствительны к мировым движениям процентных ставок.',
 '(Russian) Однако у достигнутой договоренности есть три основных недостатка.']

หัวข้อเพิ่มเติม

พูดได้หลายภาษา

สุดท้ายเราขอแนะนำให้คุณลองแบบสอบถามในใด ๆ ของภาษาที่รองรับ: อังกฤษ, อาหรับ, จีน, ดัตช์, ฝรั่งเศส, เยอรมัน, อิตาลี, ญี่ปุ่น, เกาหลี, โปแลนด์, โปรตุเกส, รัสเซีย, สเปน, ไทยและตุรกี

นอกจากนี้ แม้ว่าเราจะจัดทำดัชนีเฉพาะในกลุ่มย่อยของภาษา คุณยังสามารถจัดทำดัชนีเนื้อหาในภาษาที่รองรับได้

รูปแบบต่างๆ

เรานำเสนอรุ่นต่างๆ ของ Universal Encoder ที่ได้รับการปรับแต่งสำหรับสิ่งต่างๆ เช่น หน่วยความจำ เวลาแฝง และ/หรือคุณภาพ โปรดทดลองกับพวกเขาเพื่อค้นหาสิ่งที่เหมาะสม

ห้องสมุดเพื่อนบ้านที่ใกล้ที่สุด

เราใช้ Annoy เพื่อค้นหาเพื่อนบ้านที่ใกล้ที่สุดอย่างมีประสิทธิภาพ ดู ส่วนความสมดุล ในการอ่านเกี่ยวกับจำนวนของต้นไม้ (หน่วยความจำขึ้นอยู่กับ) และจำนวนของรายการในการค้นหา (ขึ้นอยู่กับความล่าช้า) --- SimpleNeighbors เพียงช่วยให้การควบคุมจำนวนของต้นไม้ แต่ refactoring รหัสเพื่อใช้รำคาญโดยตรงควรจะเป็น ง่าย ๆ เราแค่ต้องการให้รหัสนี้ง่ายที่สุดสำหรับผู้ใช้ทั่วไป

ถ้ารำคาญไม่ได้ระดับกับการใช้งานของคุณโปรดตรวจสอบออก FAISS

สิ่งที่ดีที่สุดในการสร้างแอปพลิเคชันความหมายหลายภาษาของคุณ!

[1] เจแมนน์, 2012, Parallel ข้อมูลเครื่องมือและการเชื่อมต่อใน OPUS ในการดำเนินการของการประชุมนานาชาติครั้งที่ 8 ด้านทรัพยากรภาษาและการประเมินผล (LREC 2012)