Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
evoprompt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grießhaber Daniel
evoprompt
Commits
36d6d073
Commit
36d6d073
authored
7 months ago
by
Max Kimmich
Browse files
Options
Downloads
Patches
Plain Diff
Add SAMSum dataset
parent
458e36ee
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
evoprompt/task/__init__.py
+1
-0
1 addition, 0 deletions
evoprompt/task/__init__.py
evoprompt/task/summarization.py
+75
-0
75 additions, 0 deletions
evoprompt/task/summarization.py
with
76 additions
and
0 deletions
evoprompt/task/__init__.py
+
1
−
0
View file @
36d6d073
...
...
@@ -11,6 +11,7 @@ from evoprompt.task.text_classification import TextClassification
from
evoprompt.task.sentiment_analysis
import
SentimentAnalysis
from
evoprompt.task.topic_classification
import
AGNews
,
TREC
from
evoprompt.task.subjectivity_classification
import
Subj
from
evoprompt.task.summarization
import
SAMSum
from
evoprompt.utils
import
get_all_subclasses
...
...
This diff is collapsed.
Click to expand it.
evoprompt/task/summarization.py
0 → 100644
+
75
−
0
View file @
36d6d073
from
abc
import
abstractmethod
from
functools
import
lru_cache
import
logging
from
typing
import
Mapping
from
evaluate
import
load
as
load_metric
from
llama_cpp
import
LlamaGrammar
from
evoprompt.models
import
LLMModel
from
evoprompt.task
import
Task
from
evoprompt.task.task
import
DatasetDatum
logger
=
logging
.
getLogger
(
__name__
)
class
Summarization
(
Task
):
def
__init__
(
self
,
*
args
,
**
kwargs
)
->
None
:
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
metric
=
load_metric
(
"
evaluate-metric/rouge
"
)
def
_evaluate_sample
(
self
,
prompt
:
str
,
datum
:
DatasetDatum
):
gold_label
=
self
.
_get_gold_label_for_datum
(
datum
)
response
,
usage
=
self
.
predict
(
prompt
=
prompt
,
datum
=
datum
)
response
=
response
.
lower
()
scores
=
self
.
metric
.
compute
(
predictions
=
[
response
],
references
=
[
gold_label
])
return
scores
[
"
rougeL
"
],
usage
@lru_cache
def
_get_grammer
(
self
,
datum
:
DatasetDatum
,
verbose
:
bool
=
False
):
return
None
def
_get_prompt_text_for_datum
(
self
,
datum
:
DatasetDatum
)
->
str
:
return
"
\n
Input:
"
+
'"'
+
self
.
_get_text_for_datum
(
datum
)
+
'"'
@abstractmethod
def
_get_text_for_datum
(
self
,
datum
:
DatasetDatum
)
->
str
:
pass
@abstractmethod
def
_get_gold_label_for_datum
(
self
,
datum
:
DatasetDatum
)
->
str
:
pass
def
_aggregate_result
(
self
,
results
:
list
[
str
])
->
float
:
return
sum
(
results
)
/
len
(
results
)
@property
def
metric_name
(
self
):
return
"
rougeL
"
@property
def
base_prompt
(
self
):
return
'
Please summarize the main context.
'
class
SAMSum
(
Summarization
):
shorthand
=
"
sams
"
def
__init__
(
self
,
*
args
,
**
kwargs
)
->
None
:
super
().
__init__
(
*
args
,
validation_dataset
=
"
Samsung/samsum
"
,
test_dataset
=
"
Samsung/samsum
"
,
validation_split
=
"
train
"
,
test_split
=
"
test
"
,
**
kwargs
)
def
_get_text_for_datum
(
self
,
datum
:
DatasetDatum
)
->
str
:
return
datum
[
"
dialogue
"
]
def
_get_gold_label_for_datum
(
self
,
datum
:
DatasetDatum
)
->
str
:
return
datum
[
"
summary
"
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment