jerpint commited on
Commit
6498684
1 Parent(s): 3adcc08

Update cfg.py

Browse files
Files changed (1) hide show
  1. cfg.py +33 -15
cfg.py CHANGED
@@ -4,7 +4,10 @@ from buster.formatters.documents import DocumentsFormatterJSON
4
  from buster.formatters.prompts import PromptFormatter
5
  from buster.retriever import DeepLakeRetriever, Retriever
6
  from buster.tokenizers import GPTTokenizer
7
- from buster.validators import QuestionAnswerValidator, Validator
 
 
 
8
 
9
  buster_cfg = BusterConfig(
10
  retriever_cfg={
@@ -57,16 +60,18 @@ buster_cfg = BusterConfig(
57
  "Now answer the following question:\n"
58
  ),
59
  },
60
- validator_cfg={
61
- "unknown_response_templates": [
62
- "I'm sorry, but I am an AI language model trained to assist with questions related to AI. I cannot answer that question as it is not relevant to the library or its usage. Is there anything else I can assist you with?",
63
- ],
64
- "unknown_threshold": 0.85,
65
- "embedding_model": "text-embedding-ada-002",
66
- "use_reranking": True,
67
- "invalid_question_response": "This question does not seem relevant to my current knowledge. If you think this is a mistake, you can modify the question validation prompt.",
68
- "check_question_prompt": """You are an chatbot answering questions about the Mila cluster, a compute cluster used by Mila students.
69
 
 
 
 
 
 
 
 
 
 
 
 
70
  Your job is to determine wether or not a question is valid, and should be answered. The question is valid if it is related to cluster usage and anything related to AI.
71
  A user will submit a question. Respond 'true' if it is valid, respond 'false' if it is invalid.
72
 
@@ -82,11 +87,24 @@ Q: What is the meaning of life?
82
  false
83
 
84
  A user will submit a question. Respond 'true' if it is valid, respond 'false' if it is invalid.""",
85
- "completion_kwargs": {
86
- "model": "gpt-3.5-turbo",
87
- "stream": False,
88
- "temperature": 0,
89
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  },
91
  )
92
 
@@ -105,7 +123,7 @@ def setup_buster(buster_cfg: BusterConfig):
105
  ),
106
  **buster_cfg.documents_answerer_cfg,
107
  )
108
- validator: Validator = QuestionAnswerValidator(**buster_cfg.validator_cfg)
109
  buster: Buster = Buster(
110
  retriever=retriever, document_answerer=document_answerer, validator=validator
111
  )
 
4
  from buster.formatters.prompts import PromptFormatter
5
  from buster.retriever import DeepLakeRetriever, Retriever
6
  from buster.tokenizers import GPTTokenizer
7
+ from buster.validators import Validator
8
+ from buster.llm_utils import get_openai_embedding_constructor
9
+
10
+ embedding_fn = get_openai_embedding_constructor(client_kwargs=client_kwargs)
11
 
12
  buster_cfg = BusterConfig(
13
  retriever_cfg={
 
60
  "Now answer the following question:\n"
61
  ),
62
  },
 
 
 
 
 
 
 
 
 
63
 
64
+ validator_cfg={
65
+ "question_validator_cfg": {
66
+ "invalid_question_response": "This question does not seem relevant to my current knowledge.",
67
+ "completion_kwargs": {
68
+ "model": "gpt-3.5-turbo",
69
+ "stream": False,
70
+ "temperature": 0,
71
+ },
72
+ "client_kwargs": client_kwargs,
73
+ "check_question_prompt": """You are an chatbot answering questions about the Mila cluster, a compute cluster used by Mila students.
74
+
75
  Your job is to determine wether or not a question is valid, and should be answered. The question is valid if it is related to cluster usage and anything related to AI.
76
  A user will submit a question. Respond 'true' if it is valid, respond 'false' if it is invalid.
77
 
 
87
  false
88
 
89
  A user will submit a question. Respond 'true' if it is valid, respond 'false' if it is invalid.""",
 
 
 
 
90
  },
91
+ "answer_validator_cfg": {
92
+ "unknown_response_templates": [
93
+ "I'm sorry, but I am an AI language model trained to assist with questions related to AI. I cannot answer that question as it is not relevant to the library or its usage. Is there anything else I can assist you with?",
94
+ ],
95
+ "unknown_threshold": 0.85,
96
+ "embedding_fn": embedding_fn,
97
+ },
98
+ "documents_validator_cfg": {
99
+ "completion_kwargs": {
100
+ "model": "gpt-3.5-turbo",
101
+ "stream": False,
102
+ "temperature": 0,
103
+ },
104
+ "client_kwargs": client_kwargs,
105
+ },
106
+ "use_reranking": True,
107
+ "validate_documents": False,
108
  },
109
  )
110
 
 
123
  ),
124
  **buster_cfg.documents_answerer_cfg,
125
  )
126
+ validator: Validator = Validator(**buster_cfg.validator_cfg)
127
  buster: Buster = Buster(
128
  retriever=retriever, document_answerer=document_answerer, validator=validator
129
  )