Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Amazon KDD Cup 2024 Starter Kit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lei_ding5
Amazon KDD Cup 2024 Starter Kit
Commits
1b65447a
Commit
1b65447a
authored
11 months ago
by
yilun_jin
Browse files
Options
Downloads
Patches
Plain Diff
Update models/dummy_model.py
parent
c593f6f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
models/dummy_model.py
+0
-26
0 additions, 26 deletions
models/dummy_model.py
with
0 additions
and
26 deletions
models/dummy_model.py
+
0
−
26
View file @
1b65447a
...
...
@@ -50,29 +50,3 @@ class DummyModel(ShopBenchBaseModel):
# Note: As this is dummy model, we are returning random responses for non-multiple choice tasks.
# For generation tasks, this should ideally return an unconstrained string.
class
Vicuna2ZeroShot
(
ShopBenchBaseModel
):
"""
A baseline solution that uses Vicuna-7B to generate answers with zero-shot prompting.
"""
def
__init__
(
self
):
random
.
seed
(
AICROWD_RUN_SEED
)
### model_path = 'lmsys/vicuna-7b-v1.5'
### Before submitting, please put necessary files to run Vicuna-7B at the corresponding path, and submit them with `git lfs`.
self
.
tokenizer
=
AutoTokenizer
.
from_pretrained
(
'
./models/vicuna-7b-v1.5/
'
,
trust_remote_code
=
True
)
self
.
model
=
AutoModelForCausalLM
.
from_pretrained
(
'
./models/vicuna-7b-v1.5/
'
,
device_map
=
'
auto
'
,
torch_dtype
=
'
auto
'
,
trust_remote_code
=
True
,
do_sample
=
True
)
self
.
system_prompt
=
"
You are a helpful online shopping assistant. Please answer the following question about online shopping and follow the given instructions.
\n\n
"
def
predict
(
self
,
prompt
:
str
,
is_multiple_choice
:
bool
)
->
str
:
prompt
=
self
.
system_prompt
+
prompt
inputs
=
self
.
tokenizer
(
prompt
,
return_tensors
=
'
pt
'
)
inputs
.
input_ids
=
inputs
.
input_ids
.
cuda
()
if
is_multiple_choice
:
# only one token for multiple choice questions.
generate_ids
=
self
.
model
.
generate
(
inputs
.
input_ids
,
max_new_tokens
=
1
,
temperature
=
0
)
else
:
# 100 tokens for non-multiple choice questions.
generate_ids
=
self
.
model
.
generate
(
inputs
.
input_ids
,
max_new_tokens
=
100
,
temperature
=
0
)
result
=
self
.
tokenizer
.
batch_decode
(
generate_ids
,
skip_special_tokens
=
True
,
clean_up_tokenization_spaces
=
False
)[
0
]
generation
=
result
[
len
(
prompt
):]
return
generation
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