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
OpenDAS
Megatron-LM
Commits
1016e98a
Commit
1016e98a
authored
Feb 18, 2023
by
zhuww
Browse files
megatron-lm0.3.2 based on dtk-22.10
parent
6c3f6c7b
Changes
241
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
tools/text_generation_cli.py
tools/text_generation_cli.py
+34
-0
No files found.
tools/text_generation_cli.py
0 → 100644
View file @
1016e98a
# coding=utf-8
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
json
import
sys
import
urllib2
class
PutRequest
(
urllib2
.
Request
):
'''class to handling putting with urllib2'''
def
get_method
(
self
,
*
args
,
**
kwargs
):
return
'PUT'
if
__name__
==
"__main__"
:
url
=
sys
.
argv
[
1
]
while
True
:
sentence
=
raw_input
(
"Enter prompt: "
)
tokens_to_generate
=
int
(
input
(
"Enter number of tokens to generate: "
))
data
=
json
.
dumps
({
"prompts"
:
[
sentence
],
"tokens_to_generate"
:
tokens_to_generate
})
req
=
PutRequest
(
url
,
data
,
{
'Content-Type'
:
'application/json'
})
response
=
urllib2
.
urlopen
(
req
)
resp_sentences
=
json
.
load
(
response
)
print
(
"Megatron Response: "
)
print
(
resp_sentences
[
"text"
][
0
])
Prev
1
…
9
10
11
12
13
Next
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