yinsong1986 commited on
Commit
42572e5
1 Parent(s): ee03ba6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -0
README.md CHANGED
@@ -157,6 +157,42 @@ predictor.predict(
157
 
158
  ```
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
  ## Limitations ##
162
  Before using the MegaBeam-Mistral-7B-300k model, it is important to perform your own independent assessment, and take measures to ensure that your use would comply with your own specific quality control practices and standards, and that your use would comply with the local rules, laws, regulations, licenses and terms that apply to you, and your content.
 
157
 
158
  ```
159
 
160
+ ### Invoke the model on a SageMaker Endpoint ###
161
+ To use MegaBeam-Mistral-7B-300k on a SageMaker endpoint, please try following this example:
162
+
163
+ ```python
164
+ import boto3
165
+ import json
166
+
167
+ def call_endpoint(text:str, endpoint_name:str):
168
+ client = boto3.client("sagemaker-runtime")
169
+
170
+ parameters = {
171
+ "max_new_tokens": 450,
172
+ "do_sample": True,
173
+ "temperature": 0.7,
174
+ }
175
+
176
+ payload = {"inputs": text, "parameters": parameters}
177
+
178
+ response = client.invoke_endpoint(
179
+ EndpointName=endpoint_name, Body=json.dumps(payload), ContentType="application/json"
180
+ )
181
+
182
+ output = json.loads(response["Body"].read().decode())
183
+
184
+ result = output["generated_text"]
185
+ return result
186
+
187
+ # please insert your long prompt/document content here
188
+ prompt = """<s>[INST] What are the main challenges to support long contexts for a Large Language Model? [/INST]"""
189
+
190
+ #print(prompt)
191
+ endpoint_name = "megaBeam-mistral-7b-300k-2024-05-13-14-23-41-219" # please use a valid endpoint name
192
+ result = call_endpoint(prompt, endpoint_name)
193
+ print(result)
194
+ ```
195
+
196
 
197
  ## Limitations ##
198
  Before using the MegaBeam-Mistral-7B-300k model, it is important to perform your own independent assessment, and take measures to ensure that your use would comply with your own specific quality control practices and standards, and that your use would comply with the local rules, laws, regulations, licenses and terms that apply to you, and your content.