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
2dd1b8f0
"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "3cdf8b7ec2ac7b638bac7495870f1fd152314251"
Unverified
Commit
2dd1b8f0
authored
Oct 20, 2022
by
Rohit Gupta
Committed by
GitHub
Oct 20, 2022
Browse files
adding key pair dataset (#19765)
parent
17d7aec8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
docs/source/en/main_classes/pipelines.mdx
docs/source/en/main_classes/pipelines.mdx
+1
-1
src/transformers/pipelines/pt_utils.py
src/transformers/pipelines/pt_utils.py
+13
-0
No files found.
docs/source/en/main_classes/pipelines.mdx
View file @
2dd1b8f0
...
...
@@ -91,7 +91,7 @@ pipe = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-96
dataset = datasets.load_dataset("superb", name="asr", split="test")
# KeyDataset (only *pt*) will simply return the item in the dict returned by the dataset item
# as we're not interested in the *target* part of the dataset.
# as we're not interested in the *target* part of the dataset.
For sentence pair use KeyPairDataset
for out in tqdm(pipe(KeyDataset(dataset, "file"))):
print(out)
# {"text": "NUMBER TEN FRESH NELLY IS WAITING ON YOU GOOD NIGHT HUSBAND"}
...
...
src/transformers/pipelines/pt_utils.py
View file @
2dd1b8f0
...
...
@@ -293,3 +293,16 @@ class KeyDataset(Dataset):
def
__getitem__
(
self
,
i
):
return
self
.
dataset
[
i
][
self
.
key
]
class
KeyPairDataset
(
Dataset
):
def
__init__
(
self
,
dataset
:
Dataset
,
key1
:
str
,
key2
:
str
):
self
.
dataset
=
dataset
self
.
key1
=
key1
self
.
key2
=
key2
def
__len__
(
self
):
return
len
(
self
.
dataset
)
def
__getitem__
(
self
,
i
):
return
{
"text"
:
self
.
dataset
[
i
][
self
.
key1
],
"text_pair"
:
self
.
dataset
[
i
][
self
.
key2
]}
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