-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_llm.py
23 lines (18 loc) · 917 Bytes
/
simple_llm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from ibm_watson_machine_learning.foundation_models import Model
from ibm_watson_machine_learning.foundation_models.extensions.langchain import WatsonxLLM
from ibm_watson_machine_learning.metanames import GenTextParamsMetaNames as GenParams
my_credentials = {
"url" : "https://us-south.ml.cloud.ibm.com"
}
params = {
GenParams.MAX_NEW_TOKENS: 800, # The maximum number of tokens that the model can generate in a single run.
GenParams.TEMPERATURE: 0.1, # A parameter that controls the randomness of the token generation. A lower value makes the generation more deterministic, while a higher value introduces more randomness.
}
LLAMA2_model = Model(
model_id= 'meta-llama/llama-2-70b-chat',
credentials=my_credentials,
params=params,
project_id="skills-network",
)
llm = WatsonxLLM(LLAMA2_model)
print(llm("How to read a book effectively?"))