consists of DVCSteps to embedd files and save them as for example as csv.
Embedded
Bases: TypedDict
dict definition of a embedded document.
Source code in wurzel/steps/embedding/step.py
33 34 35 36 37 38 |
|
EmbeddingStep
Bases: SimpleSplitterStep
, TypedStep[EmbeddingSettings, list[MarkdownDataContract], DataFrame[EmbeddingResult]]
Step for consuming list[MarkdownDataContract] and returning DataFrame[EmbeddingResult].
Source code in wurzel/steps/embedding/step.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
__md_to_plain(element, stream=None)
classmethod
Converts a markdown element into plain text.
Parameters
element : Element The markdown element to convert. stream : StringIO, optional The stream to which the plain text is written. If None, a new stream is created.
Returns
str The plain text representation of the markdown element.
Source code in wurzel/steps/embedding/step.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
get_embedding_input_from_document(doc)
Clean the document such that it can be used as input to the embedding model.
Parameters
doc : MarkdownDataContract The document containing the page content in Markdown format.
Returns
str Cleaned text that can be used as input to the embedding model.
Source code in wurzel/steps/embedding/step.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
get_simple_context(text)
Simple function to create a context from a text.
Source code in wurzel/steps/embedding/step.py
160 161 162 163 164 |
|
is_stopword(word)
Stopword Detection Function.
Source code in wurzel/steps/embedding/step.py
151 152 153 |
|
run(inpt)
Executes the embedding step by processing input markdown files, generating embeddings, and saving them to a CSV file.
Source code in wurzel/steps/embedding/step.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
whitespace_word_tokenizer(text)
classmethod
Simple Regex based whitespace word tokenizer.
Source code in wurzel/steps/embedding/step.py
155 156 157 158 |
|
consists of DVCSteps to embedd files and save them as for example as csv.
EmbeddingMultiVectorStep
Bases: EmbeddingStep
, TypedStep[EmbeddingSettings, list[MarkdownDataContract], DataFrame[EmbeddingMultiVectorResult]]
Step for consuming list[MarkdownDataContract] and returning DataFrame[EmbeddingMultiVectorResult].
Source code in wurzel/steps/embedding/step_multivector.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 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 |
|
run(inpt)
Executes the embedding step by processing a list of MarkdownDataContract objects, generating embeddings for each document, and returning the results as a DataFrame.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Logs
- Warnings for documents skipped due to EmbeddingAPIException.
- A summary warning if some or all documents are skipped.
Source code in wurzel/steps/embedding/step_multivector.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
EmbeddingSettings
Bases: SplitterSettings
EmbeddingSettings is a configuration class for embedding-related settings.
Attributes: |
|
---|
Methods:
Name | Description |
---|---|
_wrap_validator_model_mapping |
dict[str, str], handler): A static method to wrap and validate the model mapping. It converts string regex keys in the input dictionary to compiled regex patterns and applies a handler function to the result. |
Source code in wurzel/steps/embedding/settings.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|