【发布时间】:2021-03-01 11:12:59
【问题描述】:
我在以下网址看到了 TF 1.x 的英法 USE 模型:https://tfhub.dev/google/universal-sentence-encoder-xling/en-fr/1
此模型可用于 TF 2.x 吗?我找不到升级。
谢谢!
【问题讨论】:
标签: tensorflow2.0
我在以下网址看到了 TF 1.x 的英法 USE 模型:https://tfhub.dev/google/universal-sentence-encoder-xling/en-fr/1
此模型可用于 TF 2.x 吗?我找不到升级。
谢谢!
【问题讨论】:
标签: tensorflow2.0
您可以在此链接中找到所有 TF 2.x 模型,这些模型在法语文本上进行了训练:https://tfhub.dev/s?language=fr&tf-version=tf2
其中一个结果模型是USE multilingual large v3,可以像这样使用:
import tensorflow_hub as hub
import numpy as np
import tensorflow_text
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."]
embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder-multilingual-large/3")
en_result = embed(english_sentences)
fr_result = embed(french_sentences)
np.inner(en_result, fr_result)
# array([[0.99073195, 0.3755554 , 0.2772888 ],
# [0.40345296, 0.8896688 , 0.30821913],
# [0.26346597, 0.2500368 , 0.8951807 ]], dtype=float32)
【讨论】: