File size: 1,094 Bytes
c0510b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
import os,gc,shutil
from util.conversation_rag import Conversation_RAG
from util.index import *
import torch

class ModelSetup:
    def __init__(self, hf_token, embedding_model, llm):

        self.hf_token = hf_token
        self.embedding_model = embedding_model
        self.llm = llm

    def setup(self):

        if self.embedding_model == "all-roberta-large-v1_1024d":
            embedding_model_repo_id = "sentence-transformers/all-roberta-large-v1"
        elif self.embedding_model == "all-mpnet-base-v2_768d":
            embedding_model_repo_id = "sentence-transformers/all-mpnet-base-v2"


        if self.llm == "Llamav2-7B-Chat":
            llm_repo_id = "meta-llama/Llama-2-7b-chat-hf"
        elif self.llm == "Falcon-7B-Instruct":
            llm_repo_id = "tiiuae/falcon-7b-instruct"


        conv_rag = Conversation_RAG(self.hf_token,
                                    embedding_model_repo_id,
                                    llm_repo_id)

        self.model, self.tokenizer, self.vectordb = conv_rag.load_model_and_tokenizer()
        return "Model Setup Complete"