AI术语词典

A comprehensive multilingual AI terminology dictionary

Definition

这些模型将高维数据映射到低维连续向量空间中,其中相似的项目彼此靠得更近。这种转换捕捉了语义关系,使得…(原文截断)

Summary

嵌入模型将文本或图像等原始数据转换为表示语义意义的稠密数值向量。

Key Concepts

Use Cases

Code Example

1
2
3
4
5
6
7
from transformers import AutoTokenizer, AutoModel
import torch

model = AutoModel.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
inputs = tokenizer('Hello world', return_tensors='pt')
embeddings = model(**inputs).last_hidden_state.mean(dim=1)