Skip to content

Commit

Permalink
Adding doctest for feature-extraction. (huggingface#20240)
Browse files Browse the repository at this point in the history
* Adding doctest for `feature-extraction`.

* Update feature_extraction.py
  • Loading branch information
Narsil authored Nov 16, 2022
1 parent 529037f commit e434627
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/transformers/pipelines/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ class FeatureExtractionPipeline(Pipeline):
Feature extraction pipeline using no model head. This pipeline extracts the hidden states from the base
transformer, which can be used as features in downstream tasks.
Example:
```python
>>> from transformers import pipeline
>>> extractor = pipeline(model="bert-base-uncased", task="feature-extraction")
>>> result = extractor("This is a simple test.", return_tensors=True)
>>> result.shape # This is a tensor of shape [1, sequence_lenth, hidden_dimension] representing the input string.
torch.Size([1, 8, 768])
```
[Using pipelines in a webserver or with a dataset](../pipeline_tutorial)
This feature extraction pipeline can currently be loaded from [`pipeline`] using the task identifier:
`"feature-extraction"`.
Expand Down

0 comments on commit e434627

Please sign in to comment.