-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllm.py
27 lines (22 loc) · 772 Bytes
/
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
24
25
26
27
'''
===========================================
Module: Open-source LLM Setup
===========================================
'''
from langchain.llms import CTransformers
from dotenv import find_dotenv, load_dotenv
import box
import yaml
# Load environment variables from .env file
load_dotenv(find_dotenv())
# Import config vars
with open('config/config.yml', 'r', encoding='utf8') as ymlfile:
cfg = box.Box(yaml.safe_load(ymlfile))
def build_llm():
# Local CTransformers model
llm = CTransformers(model=cfg.MODEL_BIN_PATH,
model_type=cfg.MODEL_TYPE,
config={'max_new_tokens': cfg.MAX_NEW_TOKENS,
'temperature': cfg.TEMPERATURE}
)
return llm