Pipeline
Pipeline ¶
Bases: BaseModel
Pipeline class for the demo.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
retriever |
SemanticRetriever
|
The semantic retriever. |
required |
answerer |
AnswerGenerator
|
The answer generator. |
required |
sections_map |
dict
|
The mapping of section headings to their content. |
required |
Source code in docqa/demo/pipeline.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
process ¶
Processes a question and returns the answer along with related references and metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
question |
str
|
The question to process. |
required |
certainty_threshold |
float
|
The threshold for considering a question as certain. Defaults to 0.9. |
0.9
|
uncertainty_threshold |
float
|
The threshold for considering a question as uncertain. Defaults to 0.6. |
0.6
|
temperature |
float
|
The temperature parameter for generating the answer. Defaults to 1.0. |
1.0
|
Returns:
Name | Type | Description |
---|---|---|
dict |
PipelineOutput
|
A dictionary containing the answer, references, and metadata. |
Output dict format
- answer (str): The answer to the question.
- references (list): A list of dictionaries containing the related
references.
- source (str): The source of the reference.
- content (str): The content of the reference.
- metadata (dict): Additional metadata associated with the answer.
Source code in docqa/demo/pipeline.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
create_chroma_db ¶
Creates a Chroma database given the data directory, database directory, collection name, and embedding model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dir |
Path
|
The directory containing the data files. |
required |
db_dir |
Path
|
The directory where the database will be created. |
required |
collection_name |
str
|
The name of the collection in the database. |
required |
embedding_model |
Any
|
The embedding model used to encode the corpus. |
required |
Returns:
Type | Description |
---|---|
Collection
|
chromadb.Collection: The created Chroma database. |
Source code in docqa/demo/pipeline.py
get_pipeline ¶
Initializes and returns a pipeline for processing text-based questions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dir |
Path
|
The directory containing the data files. |
required |
openai_key |
str
|
The API key for OpenAI. |
required |
openai_model |
str
|
The name of the OpenAI model to use. |
required |
Returns:
Name | Type | Description |
---|---|---|
Pipeline |
Pipeline
|
The initialized pipeline for processing text-based questions. |