Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
8bb166db
Commit
8bb166db
authored
Dec 18, 2019
by
Morgan Funtowicz
Browse files
Expose more information in the output of TextClassificationPipeline
parent
04b602f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
transformers/pipelines.py
transformers/pipelines.py
+3
-1
No files found.
transformers/pipelines.py
View file @
8bb166db
...
...
@@ -283,7 +283,9 @@ class TextClassificationPipeline(Pipeline):
self
.
_nb_classes
=
nb_classes
def
__call__
(
self
,
*
args
,
**
kwargs
):
return
super
().
__call__
(
*
args
,
**
kwargs
).
tolist
()
outputs
=
super
().
__call__
(
*
args
,
**
kwargs
)
scores
=
np
.
exp
(
outputs
)
/
np
.
exp
(
outputs
).
sum
(
-
1
)
return
[{
'label'
:
self
.
model
.
config
.
id2label
[
item
.
argmax
()],
'score'
:
item
.
max
()}
for
item
in
scores
]
class
NerPipeline
(
Pipeline
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment