← 开源
facebookresearch

InferSent

InferSent sentence embeddings

ModelsDomain-specific modelsJupyter Notebook
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
2.28k
Star
464
Fork
+2
本周
8
贡献者
创建于 2017-05-18 · 更新于 2026-10-13 · 今日第 8778 名
主要开发者
aconneauellabee7cdelahousse

facebookresearch/InferSent 排名第 8,778,有 2,281 个星标。

同类别比较

facebookresearch/InferSent 排名第 8,778,此处有 8 个同类条目;Tencent/MedicalNet 排名第 8,788。

同类别比较
名称排名指标
LAION-AI/CLAP8,739
语言:
Python
星标数:
2,307
分叉数:
213
简介:
Contrastive Language-Audio Pretraining
buaacyw/MeshAnything8,741
语言:
Python
星标数:
2,306
分叉数:
108
简介:
[ICLR 2025] From anything to mesh like human artists. Official impl. of "MeshAnything: Artist-Created Mesh Generation with Autoregressive Transformers"
facebookresearch/frankmocap8,757
语言:
Python
星标数:
2,294
分叉数:
389
简介:
A Strong and Easy-to-use Single View 3D Hand+Body Pose Estimator
opendatalab/DocLayout-YOLO8,761
语言:
Python
星标数:
2,292
分叉数:
178
简介:
DocLayout-YOLO: Enhancing Document Layout Analysis through Diverse Synthetic Data and Global-to-Local Adaptive Perception
Tencent/MedicalNet8,788
语言:
Python
星标数:
2,272
分叉数:
464
简介:
Many studies have shown that the performance on deep learning is significantly affected by volume of training data. The MedicalNet project provides a series of 3D-ResNet pre-trained models and relative code.
aixcoder-plugin/aiXcoder-7B8,790
语言:
Python
星标数:
2,271
分叉数:
357
简介:
official repository of aiXcoder-7B Code Large Language Model
stepfun-ai/Step1X-Edit8,795
语言:
Python
星标数:
2,268
分叉数:
106
简介:
A SOTA open-source image editing model, which aims to provide comparable performance against the closed-source models like GPT-4o and Gemini 2 Flash.
Alpha-VLLM/Lumina-T2X8,816
语言:
Python
星标数:
2,248
分叉数:
98
简介:
Lumina-T2X is a unified framework for Text to Any Modality Generation
关键参数与规格
关键参数与规格
参数值
语言Jupyter Notebook
类别Models
子类别Domain-specific models
星标数2,281
分叉数464
贡献者8
创建日期2017-05-18
更新日期2026-10-13
1 天星标数0
7 天星标数2
排名8,778
上次排名8,839
排名变化61
7 天星标排名7,814
上次 7 天星标排名7,838
7 天星标排名变化24
总星标排名5,697
上次总星标排名5,692
总星标排名变化-5
国家USA
README 摘录

InferSent *InferSent* is a *sentence embeddings* method that provides semantic representations for English sentences. It is trained on natural language inference data and generalizes well to many different tasks. We provide our pre-trained English sentence encoder from our paper and our SentEval evaluation toolkit. py and only kept pretrained models for simplicity. Reason is I do not have time anymore to maintain the repo beyond simple scripts to get sentence embeddings. Dependencies This code is written in python. Dependencies

include: Python 2/3 Pytorch (recent version) NLTK >= 3 Download word vectors Download GloVe (V1) or fastText (V2) vectors: Use our sentence encoder We provide a simple interface to encode English sentences. ** Get started with the following steps: *0. 0) Download our InferSent models (V1 trained with GloVe, V2 trained with fastText)[147MB]:* Note that infersent1 is trained with GloVe (which have been trained on text preprocessed with the PTB tokenizer) and infersent2 is trained with fastText (which have been

trained on text preprocessed with the MOSES tokenizer). The latter also removes the padding of zeros with max-pooling which was inconvenient when embedding sentences outside of their batches. 1) Make sure you have the NLTK tokenizer by running the following once:* *1) Load our pre-trained model (in encoder/):* *2) Set word vector path for the model:* *3) Build the vocabulary of word vectors (i. e keep only those needed):* where *sentences* is your list of **n** sentences. You

can update your vocabulary using *infersent. update_vocab(sentences)*, or directly load the **K** most common English words with *infersent. If **tokenize** is True (by default), sentences will be tokenized using NTLK. *4) Encode your sentences (list of *n* sentences):* This outputs a numpy array with *n* vectors of dimension **4096**. Speed is around *1000 sentences per second* with batch size 128 on a single GPU. *5) Visualize the importance that our model attributes to each word:* We provide a

function to visualize the importance of each word in the encoding of a sentence: Evaluate the encoder on transfer tasks To evaluate the model on transfer tasks, see SentEval. Be mindful to choose the same tokenization used for training the encoder. 4 Reference Please consider citing [[1]]( if you found this code useful. Supervised Learning of Universal Sentence Representations from Natural Language Inference Data (EMNLP 2017) [1] A. Bordes, *Supervised Learning of Universal Sentence Representations from Natural Language Inference Data

* Related work J. Fidler - SkipThought Vectors, NIPS 2015 S. Ma - A Simple but Tough-to-Beat Baseline for Sentence Embeddings, ICLR 2017 Y. Goldberg - Fine-grained analysis of sentence embeddings using auxiliary prediction tasks, ICLR 2017 A. Kiela - SentEval: An Evaluation Toolkit for Universal Sentence Representations, LREC 2018 S. J Pal - Learning General Purpose Distributed Sentence Representations via Large Scale Multi-task Learning, ICLR 2018 A. Goodman - DisSent: Sentence Representation Learning from Explicit Discourse Relations, 2018 D. Kurzweil - Universal Sentence

Encoder, 2018 A. Baroni - What you can cram into a single vector: Probing sentence embeddings for linguistic properties, ACL 2018

常见问题

记录了多少星标和分叉?

facebookresearch/InferSent 有 2,281 个星标和 464 个分叉。

仓库排名是多少?

facebookresearch/InferSent 排名第 8,778。

记录的语言和类别是什么?

facebookresearch/InferSent 有 2,281 个星标,语言为 Jupyter Notebook,类别为 Models。

哪个仓库排名最接近?

facebookresearch/InferSent 与 Tencent/MedicalNet 比较,后者排名第 8,788,有 2,272 个星标。

README

InferSent

InferSent is a sentence embeddings method that provides semantic representations for English sentences. It is trained on natural language inference data and generalizes well to many different tasks.

We provide our pre-trained English sentence encoder from our paper and our SentEval evaluation toolkit.

Recent changes: Removed train_nli.py and only kept pretrained models for simplicity. Reason is I do not have time anymore to maintain the repo beyond simple scripts to get sentence embeddings.

Dependencies

This code is written in python. Dependencies include:

  • Python 2/3
  • Pytorch (recent version)
  • NLTK >= 3

Download word vectors

Download GloVe (V1) or fastText (V2) vectors:

mkdir GloVe
curl -Lo GloVe/glove.840B.300d.zip http://nlp.stanford.edu/data/glove.840B.300d.zip
unzip GloVe/glove.840B.300d.zip -d GloVe/
mkdir fastText
curl -Lo fastText/crawl-300d-2M.vec.zip https://dl.fbaipublicfiles.com/fasttext/vectors-english/crawl-300d-2M.vec.zip
unzip fastText/crawl-300d-2M.vec.zip -d fastText/

Use our sentence encoder

We provide a simple interface to encode English sentences. See demo.ipynb for a practical example. Get started with the following steps:

0.0) Download our InferSent models (V1 trained with GloVe, V2 trained with fastText)[147MB]:

mkdir encoder
curl -Lo encoder/infersent1.pkl https://dl.fbaipublicfiles.com/infersent/infersent1.pkl
curl -Lo encoder/infersent2.pkl https://dl.fbaipublicfiles.com/infersent/infersent2.pkl

Note that infersent1 is trained with GloVe (which have been trained on text preprocessed with the PTB tokenizer) and infersent2 is trained with fastText (which have been trained on text preprocessed with the MOSES tokenizer). The latter also removes the padding of zeros with max-pooling which was inconvenient when embedding sentences outside of their batches.

0.1) Make sure you have the NLTK tokenizer by running the following once:

import nltk
nltk.download('punkt')

1) Load our pre-trained model (in encoder/):

from models import InferSent
V = 2
MODEL_PATH = 'encoder/infersent%s.pkl' % V
params_model = {'bsize': 64, 'word_emb_dim': 300, 'enc_lstm_dim': 2048,
                'pool_type': 'max', 'dpout_model': 0.0, 'version': V}
infersent = InferSent(params_model)
infersent.load_state_dict(torch.load(MODEL_PATH))

2) Set word vector path for the model:

W2V_PATH = 'fastText/crawl-300d-2M.vec'
infersent.set_w2v_path(W2V_PATH)

3) Build the vocabulary of word vectors (i.e keep only those needed):

infersent.build_vocab(sentences, tokenize=True)

where sentences is your list of n sentences. You can update your vocabulary using infersent.update_vocab(sentences), or directly load the K most common English words with infersent.build_vocab_k_words(K=100000). If tokenize is True (by default), sentences will be tokenized using NTLK.

4) Encode your sentences (list of n sentences):

embeddings = infersent.encode(sentences, tokenize=True)

This outputs a numpy array with n vectors of dimension 4096. Speed is around 1000 sentences per second with batch size 128 on a single GPU.

5) Visualize the importance that our model attributes to each word:

We provide a function to visualize the importance of each word in the encoding of a sentence:

infersent.visualize('A man plays an instrument.', tokenize=True)

Evaluate the encoder on transfer tasks

To evaluate the model on transfer tasks, see SentEval. Be mindful to choose the same tokenization used for training the encoder. You should obtain the following test results for the baselines and the InferSent models:

Model MR CR SUBJ MPQA STS14 STS Benchmark SICK Relatedness SICK Entailment SST TREC MRPC
InferSent1 81.1 86.3 92.4 90.2 .68/.65 75.8/75.5 0.884 86.1 84.6 88.2 76.2/83.1
InferSent2 79.7 84.2 92.7 89.4 .68/.66 78.4/78.4 0.888 86.3 84.3 90.8 76.0/83.8
SkipThought 79.4 83.1 93.7 89.3 .44/.45 72.1/70.2 0.858 79.5 82.9 88.4 -
fastText-BoV 78.2 80.2 91.8 88.0 .65/.63 70.2/68.3 0.823 78.9 82.3 83.4 74.4/82.4

Reference

Please consider citing [1] if you found this code useful.

Supervised Learning of Universal Sentence Representations from Natural Language Inference Data (EMNLP 2017)

[1] A. Conneau, D. Kiela, H. Schwenk, L. Barrault, A. Bordes, Supervised Learning of Universal Sentence Representations from Natural Language Inference Data

@InProceedings{conneau-EtAl:2017:EMNLP2017,
  author    = {Conneau, Alexis  and  Kiela, Douwe  and  Schwenk, Holger  and  Barrault, Lo\"{i}c  and  Bordes, Antoine},
  title     = {Supervised Learning of Universal Sentence Representations from Natural Language Inference Data},
  booktitle = {Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing},
  month     = {September},
  year      = {2017},
  address   = {Copenhagen, Denmark},
  publisher = {Association for Computational Linguistics},
  pages     = {670--680},
  url       = {https://www.aclweb.org/anthology/D17-1070}
}

Related work

排名相邻
同类项目