Doc Pooler[source]
The eds.doc_pooler component aggregates the word embeddings of a document into a single embedding per document, to be consumed by a document-level component such as eds.doc_classifier. When the document is split into several contexts, they are pooled together into a single embedding.
Examples
import edsnlp, edsnlp.pipes as eds
embedding = eds.doc_pooler(
pooling_mode="attention",
embedding=eds.transformer(
model="hf-internal-testing/tiny-random-bert",
window=128,
stride=96,
),
)
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
nlp | The pipeline object
|
name | Name of the component
|
embedding | The word embedding component TYPE: |
pooling_mode | How the embeddings are aggregated into a single embedding per document:
DEFAULT: |
use_cls | Pool the embeddings of the first wordpiece of each transformer window (the DEFAULT: |